added rotate_grid method and static rebuild_lookup for internal use