Refactored for shared code.