Catch, wrap, and rethrow decode errors.
Minor refactoring/cleanup.