Optimize some timer logic