Improve connection parsing

Fixes #189