Cleanup. Created proper private helper functions.
Moved `timeval` helper functions to `tvhelp.c`.