Switch from ns_min/max to std, update to bug 822289, 786533