Fixing memory leaks in parser caught by Valgrind.