More tidying of the code - output HTML is a little cleaner now.