A bit of refactoring here and there