Rewrote distribution & PSD plotting code to be much cleaner.