attempt to integrate changes from #440