fix warnings and errors found with -Wall -Wextra

- configured with CPPFLAGS="-Wall -Wextra", built, and fixed all warnings
- fixed code paths that resulted in use of uninitialized variables
- fixed unchecked comparisons between signed and unsigned vars
- marked unused params
- moved static functions out of header files
- removed useless "const" modifier on integral return values