bug fixes when parsing invalid code