Move the grid creation logic to a separate file since it's hideous code.
Merge branch 'master' into gh-pages