Implemented semaphores to group molecules.