Adding an optional hook that's called when changing layouts on the page ...

...form. Small cleanup as well.