Also including changes from master's b035dd498040667b6f39ebb009783dc0852fca86