removed semaphore, added DEBUG option