add function headers below globals

- ensure that function header definitions are at the top, below the
globals, to prevent gcc compilation errors