Sync with Karsten's update in 3.0 branch. See changelog.