Prepare for some robustness work.

We are not checking for errors in the execution of functions or
external programs that can fail, but we should improve robustness
of the program.

Passes our unittests, some manual testing and real-world uses too.