Added connection handling. No real connections yet though.