Added better resizing behavior.