Added generic types to improve understandability and compiler checking
Generic types are used wherever possible
Code improvements
Added some more generics
Added more generics