Generates hashkeys

Initializes hash arrays and computes a key for a given position, various
small improvements