Move some routines earlier in the file, preparing for upcoming changes.