numerical stability tweaks