Added better handling of generic types