various code cleanup to make things easier to read. Going to branch here and experiment a little