Fixed several potential double-deletes, one memory leak and annotated deletes which require further investigations.