Fixing some bugs in connection manager