Fixed race conditions when adding or updating jobs.