code reorganization
renaming class
added generics support
some bugfixes