improved some code for readability
more readability
dictionary instead of switch
Fix spelling, prune some old commented out lines.