Fix space complexity.