Added proper support for multiple connections.