Code Optimization: Effective Memory Usage