Fix bug with exceptions