[2.0] Backport all changes since r2798 (included) from trunk