Added g_debugLog cvar & a lot of checks in API functions