Drawing a bounding box does not cause JS console error

Drawing a bounding box when there is more than one layer does not cause
JS console errors to be thrown, however I believe there is now a small
memory leak, I did not feel comfortable committing this but received the
all clear from other parties. Fix for issue #943