Fix some memory bugs in parse