Add config file and handle errrors more gracefully.