Get rid of uses of the deprecated 'msg.connection'

Closes #404 and #413
OK.