Replacement for #3940
Fixed typos
Merge and fix conflicts.