Manually applying PR #347