Forward port of #198