Fix compiler warnings.

Declare functions before calling them.  Declare all return types.