Refactor gridlines

Pulls out the gridline code into a separate drawing class.