cleaning up code a bit

starting to map-out the flowchart and create named files appropriately.
Also introducing macros.