Fix base index for panes as well.

Move the base index logic outside of the template to each of the models
instead. Also pass parent objects to child objects so they can be aware
of window indicies.