Moved edge padding calculations to layout object
Fixed index counting bugs.
Cleanup of layout object code
Added explanatory comments