changes to support compiling with a C89 C compiler

(must place variable declarations at the beginning of basic code blocks)