End of day refactoring, to be continued