Code cleanup.Working solution.