increased failsafe threshold
removed/combined duplicated loops