Code revision and optimization