Make set return value to allow chaining, also added comments/tidy.