Made sure that the connections close and the debug info is always append...

...ed