Improved use of Java generics in collections