Code analysis and improvements