Last update since the problem is solved for good. I had to make a small change to the code because of my own stupidity. I’ve attached it if it can help someone.