Improved MX lookup code