Use correct datetime util
Minor refactoring and cleanup