Copy sanity.jam improvements from Moses