remove some warnings, refactored connection handling