Precision calculation of threshold π−d scattering, πN scattering lengths, and the GMO sum rule