Some more integrity checks and a fix in the parser