Fix connection failure on second attempt

Closes #81