This is the largest of the function files, and unlike the others is cleanly split into four types. Reorganize the file and function definitions around those types to make it easier to navigate, and do so separately before refactoring for API.