updated exception handling and added debug flag to settings file