Definitely update Avisynth+ like StainlessS said.
As to the lack of RAM, if you're using x86, you might wanna take a look at this:
https://forum.doom9.org/showthread.php?t=163281
I successfully made Avisynth x86 use more than 7 GB of RAM on my 32 GB system by splitting each filter into a separate process so that each process can allocate 2 GB of RAM and Avisynth as a whole can allocate as much RAM as possible.
As to the modifications in red, I'll take a look at it later as I'm really in a hurry right now.