Created, fixed and cleaned up 'Main' function