Fix some bugs pointed out by coverity
Cleanup the CIFF parser and fix some coverity bugs