generics returned to case classes, some bugs fixed, all tests pases now