added partly support for generic types.
Added support for Generic types.
refactoring.