Separated time logic into another file, cleaned up implementation.