Refactoring to prepare for having more stuff on the CPP side.