What is the actual type for handler_key.type ? It seems that you assign objects of many different types to it (Case1, Case2, ...). This might be an important point for the discussion.
handler_key.type
Case1
Case2