Added mutex for qi