Improve ambient gain calculations