Split out main functions into their own files.