General tidying up and silencing warnings

Attempting to make code readable.  Possibly runable.