[MONDRIAN-1785] Backport of commits 00e3d2bc6c376311ff6b2e5b6628564a45ce233f a3012a4d5e8beb7e7335312f7585cafa72ca4729 75bc4975ffbddb56fbeaab0f36923dd34c76ca1d form master.