add report-exception; some refactoring.