large code re-oganisation and encapsualtion effort

variables better defined
global vs. local use cleaned up
naming standardised
easier to read.
typography function created, but not finished.