Two major internal refactors that should have no effect on the way CC works. Multiple minor bug fixes