Clean up and correct nearest-neighbor algorithm.
Uniform neighbor selection.
Use a repeatable cross-platform PRNG.