Fix generics serialization.
Serialization is now more unknown-type-friendly.

Shouldn't result in worse perf a typecast count remains pretty much the same.