Fixed exception catching problems.