More type correctness in generics