Added parameter to specify number of units per block.
Added code to save plots.
Improved efficiency of block selection.