Rewrote memory loops to use lower values