I have to admit, my initial work on this was fairly rushed and cargo-cultish, so its quite possible that some of the stuff I copied is not relevant. This is a good example.