Fixed problem with calculating correct grid hash index.