Reduced number of classes with generics