Fixed several issues with generics usage.