Removed some duplicate code, made some functions accessible for the incoming mdns module.