Fix issue #1, redesign exception handling