Refactoring, bug fixes, date interface improvements