@Hinidu @aktau is it OK to leave this for another PR? I'm creating a list of code patterns that can be refactored to be more memory-efficient.  That's a good thing for an `entry-level` issue.