Enhanced CID errors processing, and a little bit of code cleanup.