Make exceptions use codes Fixes #53