Fixed more bugs when trying to merge cp.cpp