Use std::function instead of C-style callbacks