Fixed a crash when BuildTreeStructure and Python script commands were run without a loaded DB