Second round of refactoring