Changed some exception handling