tidy up load and transformation blocks

moved all of the functions up into the megacode block. started
pseudocode for the peak section.