Completely rewrote types system

And added sockets and connections clearing after SERVER did it's job.