Added a few guards around connection related bits; Seemed to fix #19.