Fixed bugs in timer.c and revised the example a little