Fix mem leaks
Merge pull request #32 from asmaloney/mem_leaks

Fix mem leaks (PLY)