Update both the chunk and the available space correctly

I had implemented some but not all possible chunk configurations yet
correctly. Fixed with this commit.
Don't restrict the initial chunk configuration for grid.

This is for testing purposes and might chance again later on.
Implement all cases for calculateItemRect and reduce

Visual inspection tells me that all work, though I probably should
implement tests at some point.
Update the generated files.
Simplify code by factoring out repeated lines.