Fixed memory leaks - but not sure if operation impaired...