Optimization and code trimming