Clean error handling.

Using all exit commands was a bad idea. We need to keep the return
commands but add an if statement at the end.