Jh/bugfix

Fixes Issue #22  by adjusting the index when there is a background layer.