Relocate some potentially reusable code.