Based on Dory 3.10 googlesource