Optimize code and structure