Better code style

Don't need semicolons or parens any more. Pulled bits out into functions
to start clarifying things.