Apply changes from #927 directly