Refactoring hw timers and optimizing fb code