fix timer bugs and add macros