Fix for #147
further work towards fixing #147, with input from @ljharb