Added a bunch of utility functions and a C++ wrapper