Fixed a couple of memory leaks on application redeploy