The LayoutContainer calculation was assuming that the last row was full when deciding which layout was the best, obviously this doesn't work every time. I have improved the algorithm to maximise the area taken up by the widgets (I'm sure I've done this before). This results in much better layouts.