ARRAY-2684: fixed memory leak issue by manually clearing data references. Also fixed unrelated db connection issue for audit logging.