Move fns into more logical order