Moved layout_grid to its own func.  Removed dev code #4959