all sorts of refactoring