added preliminary sanity check and renamed some rules in the parser