Reorder functions.
Add code documentation.