Changed some of the exception handling