Switched to typeclass-based exception handling