Make sure automatic re-balancing of semaphores only happens for pipelines that have specifically asked for it.
simplified the apparent control flow of synchronization subroutines, removed the returned value that is no longer used
balance_semaphores() returns the number of unsemaphored jobs, and the second sync() is only done if a nonzero number of semaphored jobs were unsemaphored
only run balance_semaphores() automatically when it is absolutely necessary (no running or otherwise runnable jobs)