Minor fixes on exception handling