Moved some generic functionality to helpers.py. Minor refactoring in main.py