Port a few useful changes from the connectionpool branch