Fix bugs in parser