reduces memory consumption by removing unnecessary threading, references and utilising a different loop structure. [skip ci]