Merge our forked changes with upstream 4.0 changes