Re-order the directives, creating sections with comments

Group the directives by function, and add some comments.