copying bugfix from priv repo