fixed some exception handling issues