Repaired do/while stmt in analyzing loop. Added calculation of goodness
and partially one optimization step.