Make window resizing more dynamic and accurate