Made grid work again. Improved code.