Add: a couple of C APIs to improve the support for customized exceptioin types;
Add: a minor refactoring of code.