Minor refactoring, fixed epoch calculation