Speed improvement. memory leaks fixed. outputing correct data.

Improved all error catching. Implemented outputs for creating
distributions. Fixed memory leaks. Increased process speed. Ready for
release build use (hopefully).