Preserving sanity while using a C API