Fixing document already in use bug.