Some (hopefully) final refactorings