As developer I need to check my progress (how mesh looks in orbiter in many iterations), so I use scenario editor a lot for vessel spawning.
D3d9 debug window is first so it slows me down as I need to precisely point scn editor instead of clicking whatever appears in custom functions.
I know it's minor problem but I'm used to having only scenario editor in custom functions.
The easiest way to overcome this problem is by deselecting all the modules. Afterwards, switch them back on but switch Scenario editor first followed by Directx9 and so on.