Made some refactorings to make ussage of generics more hevier