added binary semaphores, previous was VERY buggy