optimise callbacks for ffi