Refactoring a bit.