Also including changes from master's 91c8762c246253f546f0a3f1b922ae295e3c610f