Check SAPI

* Check the SAPI in case we're in cli for debugging
* Some error fixes. How do I member variable?