added error checking for parser, misc bug fixes