Cleaned up C code to be more C89 compliant