fix various refactoring mistakes