Whacking it into shape

Moving stuff around.
Not as much like spaghetti code, more (monty) Pythonic now...