merge 4.0 support into master