Moved all parsing out of main