FIX FLEX-33878 avoid unnecessary matrix allocations