Some cleanup and re-factoring.
Some cleanup and re-factoring.