added some more links; tidied up the code