Add common header.
Use assert instead of error return value.

It is a programmer's responsibility to ensure that API is used as
intended.
Improve readability in a couple of places.
Assert.h is included in private.h header.
Remove now unneeded cast.
Minor MPI tweaks.