fixed a small memory leak and typo