Also including changes from master's f0cbf8eef7ff163b31f46ad08d2d138fa3160f62