Adding comments and refactoring to use better hash syntax and more accurate hash codes