Thank you William for your contribution, I liked the changes you made which worked better than the original for me.
However, there is one issue I am facing with it. It automatically activates item flags "Primal" and "Requires Level 1" for all the items in loaded inventory/stash.
Normally...