Code Optimization and tuning