Fixes heap overflow issue.

I could not do the cool lazy averaging I wanted to do. I will revisit that