Fix some bugs in the Gui resizing code.