Fix stack overflow with unchecked generics