Reworked some exception handling.