lots of cleaning up, add format_time utility