added error checking to the distribution primitives

Added error checking to the distribution primitives, updated
documentation and the makefile.