renamed CondVar to Semaphore
proper fix for stack initialization and threadvar emulation