fix missed and doubled up bits of patch from afformentioned link