Optimise memory usage