Fixed several bugs with resizing window