Refactors the CPU code