Core lifecycle and public C API implementation.