Refactorings and hashcodes
Fixed hash code issues and indexOf.