Replaced some uncaught exceptions with errnos.