Check if grid sizes are a power of 2.
Added code to create grids.