sorry about all the commits

i just keep having all these ideas. Fixed averaging because it was being
done wrong. Won't continue now because the scale factor is 'nan', and so
the scaled arrays are all full of 'nan's.