fix timer race conditions