Handling errors in all our C code. Closes #13.