Rework DNS resolution

As announced I took on the task to rework the DNS resolution and to make it threaded in background.
Comments are welcome. As soon as  everybody is fine with it I'll rebase the commits before merging.
Ah thanks. Fixed in next commit.