Unity keeps references to old scene when loading a scene

So i have made a nice editor for making tilemaps but today i noticed a bug in my editor. When i load a scene it keeps the references to the old scene which leads to alot of errors. This happens even when loading the same scene.

But when i just start unity up and that scene gets loaded it works fine. The serialization part also seems to work fine when i go into playmode and back.

What is the proper way to fix this?

Same issue here. I have a “main_menu” scene. I worked on that scene. And everything its ok if I run the scene directly. But, if I hit Play in another scene, and run SceneManager.LoadScene(“main_menu”);, Unity load an old version of my “main_menu” scene. Weird. I checked that main_menu is my only scene on the project.