Refactoring to separate generation logic, slightly improved performance.
Command line arguments parsing.