Add upstream bugfixes from 4.1 branch