Dzianis lahutsik/memory optimization