Reorder some functions

Some of the functions were still in the order they were initially created. Now
they are sorted alphabetically in every section of the script, to make it a bit
easier to find them.