Avoid some function pointer casts

This casts allow to pass function with wrong signatures, without the
compiler noticing it.