Re-order so that functions are defined before use.