refactor to use object locks; add missing queueTask and taskComplete calls