all sorts of refactorings
more changes