Also including changes from master's e14ea0a65898c582ab1d9790d96b26af69bb7bdf