Move config file logic into its own class with better error handling

Also combine flags into a single config object