Added a method to handle some of the basic errors and cleaned up some of the MainFunction.py code