Made cleanup more robust.
Replaced deleteApp method with version from cleanup.