A bit of refactoring and reorganizing