Fix [partically] cherry picked from e4f4d6d5