Revamp job handling.
Fix race condition in checking if a job is already running.
Fix problem where long running job would overwrite database
  changes by saving a stale model.