Merge pull request #155 from TheOneRing/improve_connect