Modify connection class and termination of server, fix some stuff