backport improvements from background/master branch