Cleaned up code, widened scan window, added alarm when stuck.