Slight improvements to timer loop