typo
More robust parser
fixed some memory leaks