Trivial fixes

Here are some trivial fixes and/or documentation to the code. There is a lot more to be done.

For instance, do you insist in functions only having one exit point? If not, then some functions could be made much more readable (with fewer nestings) if we didn't have to check `if (foo == bla)` all the time.

If we also allow early exits, we may also simplify the error treatment of functions in the same fashion that the Linux kernel does: by using `goto`s to a "trailing" section of the functions where we clean up things and avoid repeting code.

See chapter 7 of https://www.kernel.org/doc/Documentation/CodingStyle

Please, consider merging.