Finished the basic connection initialization and connection handling. (UNTESTED)