Fixed shift/reduce conflicts and added basic error checking.