Yes, I think this whole bit needs to be refactored. It was quite difficult just getting it all in one place so I was reluctant to change it too much at the same time.