Fixed some fatal errors in load and write of ScriptPackage