Tidy up, add licence comment and attribution