Housekeeping and refactoring