Fixed more compile errors, switched to C99