hacking away, this is all a bit of a message and needs a tidy-up.