Fixed API errors when a NULL value may be passed, CMake improvements.