void Awake()
        {
            instance = this;

            #region Game Event Hooks
            GameEvents.onDominantBodyChange.Add(onDominantBodyChange);
            GameEvents.onLevelWasLoaded.Add(onLevelWasLoaded);
            GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
            GameEvents.OnVesselRecoveryRequested.Add(OnVesselRecoveryRequested);
            GameEvents.OnFundsChanged.Add(OnDoshChanged);
            GameEvents.onVesselRecovered.Add(OnVesselRecovered);
            GameEvents.onVesselRecoveryProcessing.Add(OnProcessRecovery);
            GameEvents.onGameStateSave.Add(SaveState);
            GameEvents.onGameStateLoad.Add(LoadState);
            GameEvents.OnKSCFacilityUpgraded.Add(OnKSCFacilityUpgraded);
            GameEvents.OnKSCFacilityUpgrading.Add(OnKSCFacilityUpgrading);
            GameEvents.OnUpgradeableObjLevelChange.Add(OnUpgradeableObjLevelChange);
            GameEvents.OnVesselRollout.Add(OnVesselLaunched);
            #endregion

            #region Other Mods Hooks
            if (StageRecoveryWrapper.StageRecoveryAvailable)
            {
                StageRecoveryWrapper.AddRecoveryProcessingStartListener(OnVesselRecoveryRequested);
                StageRecoveryWrapper.AddRecoveryProcessingFinishListener(SRProcessingFinished);
            }
            #endregion

            #region Model API
            KKAPI.addModelSetting("mesh", new ConfigFile());
            ConfigGenericString authorConfig = new ConfigGenericString();
            authorConfig.setDefaultValue("Unknown");
            KKAPI.addModelSetting("author", authorConfig);
            KKAPI.addModelSetting("DefaultLaunchPadTransform", new ConfigGenericString());
            KKAPI.addModelSetting("title", new ConfigGenericString());
            KKAPI.addModelSetting("category", new ConfigGenericString());
            KKAPI.addModelSetting("cost", new ConfigFloat());
            KKAPI.addModelSetting("manufacturer", new ConfigGenericString());
            KKAPI.addModelSetting("description", new ConfigGenericString());
            KKAPI.addModelSetting("DefaultLaunchSiteLength", new ConfigFloat());
            KKAPI.addModelSetting("DefaultLaunchSiteWidth", new ConfigFloat());
            KKAPI.addModelSetting("pointername", new ConfigGenericString());
            KKAPI.addModelSetting("name", new ConfigGenericString());
            KKAPI.addModelSetting("concaveColliders", new ConfigGenericString());
            #endregion

            #region Instance API
            // Position
            KKAPI.addInstanceSetting("CelestialBody", new ConfigCelestialBody());
            KKAPI.addInstanceSetting("RadialPosition", new ConfigVector3());
            KKAPI.addInstanceSetting("Orientation", new ConfigVector3());
            KKAPI.addInstanceSetting("RadiusOffset", new ConfigFloat());
            KKAPI.addInstanceSetting("RotationAngle", new ConfigFloat());

            // Calculated References - do not set, it will not work
            KKAPI.addInstanceSetting("RefLatitude", new ConfigFloat());
            KKAPI.addInstanceSetting("RefLongitude", new ConfigFloat());

            // Visibility and Grouping
            ConfigFloat visibilityConfig = new ConfigFloat();
            visibilityConfig.setDefaultValue(25000f);
            KKAPI.addInstanceSetting("VisibilityRange", visibilityConfig);
            ConfigGenericString groupConfig = new ConfigGenericString();
            groupConfig.setDefaultValue("Ungrouped");
            KKAPI.addInstanceSetting("Group", groupConfig);

            // Launchsite
            KKAPI.addInstanceSetting("LaunchSiteName", new ConfigGenericString());
            KKAPI.addInstanceSetting("LaunchPadTransform", new ConfigGenericString());
            KKAPI.addInstanceSetting("LaunchSiteAuthor", new ConfigGenericString());
            ConfigGenericString descriptionConfig = new ConfigGenericString();
            descriptionConfig.setDefaultValue("No description available.");
            KKAPI.addInstanceSetting("LaunchSiteDescription", descriptionConfig);
            KKAPI.addInstanceSetting("LaunchSiteLogo", new ConfigGenericString());
            KKAPI.addInstanceSetting("LaunchSiteIcon", new ConfigGenericString());
            KKAPI.addInstanceSetting("LaunchSiteType", new ConfigSiteType());
            ConfigGenericString category = new ConfigGenericString();
            category.setDefaultValue("Other");
            KKAPI.addInstanceSetting("Category", category);
            KKAPI.addInstanceSetting("LaunchSiteLength", new ConfigFloat());
            KKAPI.addInstanceSetting("LaunchSiteWidth", new ConfigFloat());

            // Career Mode Strategy Instances
            ConfigFloat openCost = new ConfigFloat();
            openCost.setDefaultValue(0f);
            KKAPI.addInstanceSetting("OpenCost", openCost);
            ConfigFloat closeValue = new ConfigFloat();
            closeValue.setDefaultValue(0f);
            KKAPI.addInstanceSetting("CloseValue", closeValue);
            ConfigGenericString opencloseState = new ConfigGenericString();
            opencloseState.setDefaultValue("Closed");
            KKAPI.addInstanceSetting("OpenCloseState", opencloseState);
            ConfigGenericString favouriteSite = new ConfigGenericString();
            favouriteSite.setDefaultValue("No");
            KKAPI.addInstanceSetting("FavouriteSite", favouriteSite);

            // Facility Types
            ConfigGenericString facilityrole = new ConfigGenericString();
            facilityrole.setDefaultValue("None");
            KKAPI.addModelSetting("DefaultFacilityType", facilityrole);
            ConfigGenericString instfacilityrole = new ConfigGenericString();
            instfacilityrole.setDefaultValue("None");
            KKAPI.addInstanceSetting("FacilityType", instfacilityrole);
            KKAPI.addModelSetting("DefaultFacilityLength", new ConfigFloat());
            KKAPI.addModelSetting("DefaultFacilityWidth", new ConfigFloat());
            KKAPI.addModelSetting("DefaultFacilityHeight", new ConfigFloat());
            KKAPI.addModelSetting("DefaultFacilityMassCapacity", new ConfigFloat());
            KKAPI.addModelSetting("DefaultFacilityCraftCapacity", new ConfigFloat());
            KKAPI.addInstanceSetting("FacilityLengthUsed", new ConfigFloat());
            KKAPI.addInstanceSetting("FacilityWidthUsed", new ConfigFloat());
            KKAPI.addInstanceSetting("FacilityHeightUsed", new ConfigFloat());
            KKAPI.addInstanceSetting("FacilityMassUsed", new ConfigFloat());
            KKAPI.addInstanceSetting("InStorage", new ConfigGenericString());

            // Local to a specific save - constructed in a specific save-game
            // WIP for founding
            ConfigGenericString LocalToSave = new ConfigGenericString();
            LocalToSave.setDefaultValue("False");
            KKAPI.addInstanceSetting("LocalToSave", LocalToSave);

            // Custom instances - added or modified by player with the editor
            ConfigGenericString CustomInstance = new ConfigGenericString();
            CustomInstance.setDefaultValue("False");
            KKAPI.addInstanceSetting("CustomInstance", CustomInstance);

            // Facility Ratings

            // Tracking station max short range in m
            KKAPI.addInstanceSetting("TrackingShort", new ConfigFloat());
            // Max tracking angle
            KKAPI.addInstanceSetting("TrackingAngle", new ConfigFloat());

            // Target Type and ID
            KKAPI.addInstanceSetting("TargetType", new ConfigGenericString());
            KKAPI.addInstanceSetting("TargetID", new ConfigGenericString());

            //XP
            KKAPI.addInstanceSetting("FacilityXP", new ConfigFloat());

            // Staff
            KKAPI.addModelSetting("DefaultStaffMax", new ConfigFloat());
            KKAPI.addInstanceSetting("StaffMax", new ConfigFloat());
            KKAPI.addInstanceSetting("StaffCurrent", new ConfigFloat());

            // Fueling
            KKAPI.addModelSetting("LqFMax", new ConfigFloat());
            KKAPI.addInstanceSetting("LqFCurrent", new ConfigFloat());
            KKAPI.addModelSetting("OxFMax", new ConfigFloat());
            KKAPI.addInstanceSetting("OxFCurrent", new ConfigFloat());
            KKAPI.addModelSetting("MoFMax", new ConfigFloat());
            KKAPI.addInstanceSetting("MoFCurrent", new ConfigFloat());

            KKAPI.addModelSetting("ECMax", new ConfigFloat());
            KKAPI.addModelSetting("ECRechargeRate", new ConfigFloat());
            KKAPI.addInstanceSetting("ECCurrent", new ConfigFloat());

            // Industry
            KKAPI.addModelSetting("DefaultProductionRateMax", new ConfigFloat());
            KKAPI.addInstanceSetting("ProductionRateMax", new ConfigFloat());
            KKAPI.addInstanceSetting("ProductionRateCurrent", new ConfigFloat());
            KKAPI.addInstanceSetting("Producing", new ConfigGenericString());

            KKAPI.addModelSetting("OreMax", new ConfigFloat());
            KKAPI.addInstanceSetting("OreCurrent", new ConfigFloat());
            KKAPI.addModelSetting("PrOreMax", new ConfigFloat());
            KKAPI.addInstanceSetting("PrOreCurrent", new ConfigFloat());

            // Science Rep Funds generation
            KKAPI.addModelSetting("DefaultScienceOMax", new ConfigFloat());
            KKAPI.addInstanceSetting("ScienceOMax", new ConfigFloat());
            KKAPI.addInstanceSetting("ScienceOCurrent", new ConfigFloat());
            KKAPI.addModelSetting("DefaultRepOMax", new ConfigFloat());
            KKAPI.addInstanceSetting("RepOMax", new ConfigFloat());
            KKAPI.addInstanceSetting("RepOCurrent", new ConfigFloat());
            KKAPI.addModelSetting("DefaultFundsOMax", new ConfigFloat());
            KKAPI.addInstanceSetting("FundsOMax", new ConfigFloat());
            KKAPI.addInstanceSetting("FundsOCurrent", new ConfigFloat());

            // Launch and Recovery
            ConfigFloat flaunchrefund = new ConfigFloat();
            flaunchrefund.setDefaultValue(0f);
            KKAPI.addInstanceSetting("LaunchRefund", flaunchrefund);
            ConfigFloat frecoveryfactor = new ConfigFloat();
            frecoveryfactor.setDefaultValue((float)defaultRecoveryFactor);
            KKAPI.addInstanceSetting("RecoveryFactor", frecoveryfactor);
            ConfigFloat frecoveryrange = new ConfigFloat();
            frecoveryrange.setDefaultValue((float)defaultEffectiveRange);
            KKAPI.addInstanceSetting("RecoveryRange", frecoveryrange);

            // Activity logging
            KKAPI.addInstanceSetting("LastCheck", new ConfigFloat());

            #endregion

            SpaceCenterManager.setKSC();

            loadConfig();
            saveConfig();

            DontDestroyOnLoad(this);
            loadObjects();
            importCustomInstances();
        }
		/* [KSPField]
		public Double staffHireCost = 1000;
		[KSPField]
		public Double staffRepRequirementMultiplier = 50; */	
		/* [KSPField]
		public Double ResourceCostLqF = 0.4;
		[KSPField]
		public Double ResourceCostOxF = 0.9;
		[KSPField]
		public Double ResourceCostMoF = 0.6; */
		#endregion

		void Awake()
		{
			instance = this;
			// Debug.Log("KK: Awake");

			#region Game Event Additions
			// Game Event Additions
			GameEvents.onDominantBodyChange.Add(onDominantBodyChange);
			GameEvents.onLevelWasLoaded.Add(onLevelWasLoaded);
			GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
			GameEvents.OnVesselRecoveryRequested.Add(OnVesselRecoveryRequested);
			GameEvents.OnFundsChanged.Add(OnDoshChanged);
			GameEvents.onVesselRecovered.Add(OnVesselRecovered);
			GameEvents.onGameStateSave.Add(SaveState);
			GameEvents.onGameStateLoad.Add(LoadState);
			GameEvents.OnKSCFacilityUpgraded.Add(OnKSCFacilityUpgraded);
			GameEvents.OnKSCFacilityUpgrading.Add(OnKSCFacilityUpgrading);
			GameEvents.OnUpgradeableObjLevelChange.Add(OnUpgradeableObjLevelChange);
			#endregion

			#region Model API
			// Model API
			KKAPI.addModelSetting("mesh", new ConfigFile());
			ConfigGenericString authorConfig = new ConfigGenericString();
			authorConfig.setDefaultValue("Unknown");
			KKAPI.addModelSetting("author", authorConfig);
			KKAPI.addModelSetting("DefaultLaunchPadTransform", new ConfigGenericString());
			KKAPI.addModelSetting("title", new ConfigGenericString());
			KKAPI.addModelSetting("category", new ConfigGenericString());
			KKAPI.addModelSetting("cost", new ConfigFloat());
			KKAPI.addModelSetting("mass", new ConfigFloat());
			KKAPI.addModelSetting("manufacturer", new ConfigGenericString());
			KKAPI.addModelSetting("description", new ConfigGenericString());
			KKAPI.addModelSetting("thumb", new ConfigGenericString());
			#endregion

			// START Instance API ******			
				// Position
				KKAPI.addInstanceSetting("CelestialBody", new ConfigCelestialBody());
				KKAPI.addInstanceSetting("RadialPosition", new ConfigVector3());
				KKAPI.addInstanceSetting("Orientation", new ConfigVector3());
				KKAPI.addInstanceSetting("RadiusOffset", new ConfigFloat());
				KKAPI.addInstanceSetting("RotationAngle", new ConfigFloat());

				// Visibility and Grouping
				ConfigFloat visibilityConfig = new ConfigFloat();
				visibilityConfig.setDefaultValue(25000f);
				KKAPI.addInstanceSetting("VisibilityRange", visibilityConfig);
				ConfigGenericString groupConfig = new ConfigGenericString();
				groupConfig.setDefaultValue("Ungrouped");
				KKAPI.addInstanceSetting("Group", groupConfig);

				// Launchsite
				KKAPI.addInstanceSetting("LaunchSiteName", new ConfigGenericString());
				KKAPI.addInstanceSetting("LaunchPadTransform", new ConfigGenericString());
				KKAPI.addInstanceSetting("LaunchSiteAuthor", new ConfigGenericString());
				ConfigGenericString descriptionConfig = new ConfigGenericString();
				descriptionConfig.setDefaultValue("No description available");
				KKAPI.addInstanceSetting("LaunchSiteDescription", descriptionConfig);
				KKAPI.addInstanceSetting("LaunchSiteLogo", new ConfigGenericString());
				KKAPI.addInstanceSetting("LaunchSiteIcon", new ConfigGenericString());
				KKAPI.addInstanceSetting("LaunchSiteType", new ConfigSiteType());
				ConfigGenericString category = new ConfigGenericString();
				category.setDefaultValue("Other");
				KKAPI.addInstanceSetting("Category", category);

				// Career Mode Strategy Instances
				ConfigFloat openCost = new ConfigFloat();
				openCost.setDefaultValue(0f);
				KKAPI.addInstanceSetting("OpenCost", openCost);
				ConfigFloat closeValue = new ConfigFloat();
				closeValue.setDefaultValue(0f);
				KKAPI.addInstanceSetting("CloseValue", closeValue);
				ConfigGenericString opencloseState = new ConfigGenericString();
				opencloseState.setDefaultValue("Closed");
				KKAPI.addInstanceSetting("OpenCloseState", opencloseState);

				// Career Mode Strategy Models
				ConfigGenericString facilityrole = new ConfigGenericString();
				facilityrole.setDefaultValue("None");
				KKAPI.addModelSetting("FacilityRole", facilityrole);
				ConfigGenericString LocalToSave = new ConfigGenericString();
				LocalToSave.setDefaultValue("False");
				KKAPI.addModelSetting("LocalToSave", LocalToSave);

				// Facility Ratings
				KKAPI.addModelSetting("StaffMax", new ConfigFloat());
				KKAPI.addInstanceSetting("StaffCurrent", new ConfigFloat());
				KKAPI.addModelSetting("LqFMax", new ConfigFloat());
				KKAPI.addInstanceSetting("LqFCurrent", new ConfigFloat());
				KKAPI.addModelSetting("OxFMax", new ConfigFloat());
				KKAPI.addInstanceSetting("OxFCurrent", new ConfigFloat());
				KKAPI.addModelSetting("MoFMax", new ConfigFloat());
				KKAPI.addInstanceSetting("MoFCurrent", new ConfigFloat());
				KKAPI.addModelSetting("ScienceOMax", new ConfigFloat());
				KKAPI.addInstanceSetting("ScienceOCurrent", new ConfigFloat());
				KKAPI.addModelSetting("RepOMax", new ConfigFloat());
				KKAPI.addInstanceSetting("RepOCurrent", new ConfigFloat());
				KKAPI.addModelSetting("FundsOMax", new ConfigFloat());
				KKAPI.addInstanceSetting("FundsOCurrent", new ConfigFloat());
				KKAPI.addModelSetting("RecoveryBMax", new ConfigFloat());
				KKAPI.addInstanceSetting("RecoveryBCurrent", new ConfigFloat());
				KKAPI.addModelSetting("LaunchBMax", new ConfigFloat());
				KKAPI.addInstanceSetting("LaunchBCurrent", new ConfigFloat());
				KKAPI.addModelSetting("TonsStMax", new ConfigFloat());
				KKAPI.addInstanceSetting("TonsStCurrent", new ConfigFloat());
				KKAPI.addInstanceSetting("LastCheck", new ConfigFloat());

			// END Instance API ******

			SpaceCenterManager.setKSC();

			loadConfig();
			saveConfig();
			
			DontDestroyOnLoad(this);
			loadObjects();
		}