Cleanup and rearranging the functions in the files