Small bug fixes around connection