GH-13: Split main.py into several modules to prepare for unit-tests.