grid bugfixes and optimizations