Reorder functions to avoid needing forward declarations.