More refactoring that got removed from the last commit