Equals and hashcode refactoring