Revert "Revert "Multiple backgrounds algorithm""

This reverts commit 1c2bdface84cf80a46dafef29e25bfa755eaeae6.