General refactoring work