Move the global mutex/condition vars in the stubs into a per-interface variable
rename stub variables for greater consistency
Cleanup debug and check for malloc/sscanf errors