2.1.15b5
#240, #260 corrected
Prevent against infinite loop if screen size too small