resizing bug fixes and further protection