Use (declare) and reorder functions.

This is a clean up commit. This commit declares the functions
implemented in pull request #7 and reorders them so that they
flow in a more readable top down manner.