Update for 1.5.x-1.7.x patches from upstream