Added hash function, cleaned up bad Khaan impl