Added licence headers and a few comments.