Main patch from 2.1.7 to 2.2.0-pre