Preliminary Refactor of Main Script

Trello card: https://trello.com/c/4bbdyxqQ/18-prepare-refactor-of-main-script