Fix a leak with DtlsFactory; a new instance is being created for every s...

...ingle 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, pre-increment iterators, etc.