Tidy up some code in cpmanager.cpp