FIX: call through wrong function pointer type + minor stuff

Two patches that improve the C code quality. The first is important, as it fixes a few calls through function pointers of the wrong type (which cause undefined behavior). The second just shuts up the build by introducing a few casts and removing some unused variables.