Optimize background layer insertion

Background layers are now merged into one layer, which is copied to each layer separately.