Code cleanup.
The pattern-matching depth of the main function is now handled correctly.