modifications for upstream version