Fix a leak with DtlsFactory; a new instance is being created for every single DtlsClient/Server creation, but the factory was never being destroyed.

Also some various cleanup--remove unnecessary setSocket call (was already being done through setDtlsSocket), make some code a bit more readable, etc.