Added a margin for the two grids.
Refactored code used for drawing grids.