More small fixes to generics branch (doesn't compile yet)