Some cleanup of exception handling