Also including changes from master's a99bfaaa92ca99e3f86446fd670d0a15fa5fd603