Cleanup the code (at the expense of triggering multiple events per autorange)