Several improvements to the code of CPController and its performance