[PATCH 1/2] Refactor and cleanup exception handling pieces