Also including changes from master's 40b82c903c1c71ce54a96dfa22935f73fa858f0c