Sanitize check_mx

This series of patch makes check_mx more efficient in more cases.