fixed bugs in tbs server connection handling