Added some documentation and fixed the hash function