Compact nested classes into anonymous types