Date fix and refactoring