Move some functions up the file so we can use them.