Reorder functions to get rid of unnecessary prototypes, and move a global into GLOBALS.