Fix for job queue problems

There seems to be a problem, if a job / project has queued items waiting. Sometimes it will cause two resources to be locked, even if one resource is requested. This pull request contains a fix to the problem.

I fixed the previous pull request with this fix, there was some confusion with rebasing.