Fixed some logic error when hadling the full and empty semaphores. Also fixed... See merge request !4