Some important memory leaks corrected.