Implemented basic connection handling