done some refactoring, fix hashcode issues