Work on bad accesses and then memory leaks.

Terminating the application seems a bit extreme in this case.