Some more refactoring work.