Fix all global function declarations

Group together from all over the file and:
* Rearrange by category
* Sort alphabetically