Nicely formatted, slightly neatened code.

Formatted main file.
Neatened code slightly.