Improved formatting and comments
Added comments for grid generation