Add equals and hashcode method; fix minor issues