Speedup for non-windows, fixes.

See commit comments for details.