Fix exception bugs