changed order of resizing and layout so that everything is resized correctly.