pqfinish was called twice (when failed and then again in disconnect), which caused problems with unallocated memory