Refactor timer.

Refactor timer.c and timer.h.