Exception trapping

Resolves #2