Quantcast

Minor code cleanup

Taracque [06-02-11 - 15:06]
Minor code cleanup
Filename
Change_log.txt
Ele_GUI.lua
Elementarist.lua
Elementarist.toc
License.txt
Localization_enUS.lua
diff --git a/Change_log.txt b/Change_log.txt
index d90dfcd..990779e 100755
--- a/Change_log.txt
+++ b/Change_log.txt
@@ -1,7 +1,10 @@
+**v2.0.2**
+* Bugfix: Flame Shock tracker are now more accurate, if there is no FS tick on an enemy in last 4sec, it is automatically removed from tracker
+
 **v2.0.1**
-* Mind Quickening and Boomkin Aura is now detected by ID
-* UE conditions fixed
-* Earthquake can now disabled from rotation
+* Bugfix: Mind Quickening and Boomkin Aura is now detected by ID
+* Bugfix: UE conditions fixed
+* Added: Earthquake can now disabled from rotation

 **v2.0.0**
 * Change: Earth Shock advice modified
diff --git a/Ele_GUI.lua b/Ele_GUI.lua
index a1e306c..2397542 100755
--- a/Ele_GUI.lua
+++ b/Ele_GUI.lua
@@ -1,651 +1,652 @@
--------------------------------------------------------------------------------
--- Elementarist Gui functions
---
--- GUI functions and structures for Elementarist
--------------------------------------------------------------------------------
-
-local L = Elementarist.Locals
-
-function Elementarist:CreateCheckButton(name, parent, table, field, radio)
-	local button
-	if radio then
-		button = CreateFrame('CheckButton', parent:GetName() .. name, parent, 'SendMailRadioButtonTemplate')
-	else
-		button = CreateFrame('CheckButton', parent:GetName() .. name, parent, 'OptionsCheckButtonTemplate')
-	end
-	local frame = _G[button:GetName() .. 'Text']
-	frame:SetText(name)
-	frame:SetTextColor(1, 1, 1, 1)
-	frame:SetFontObject(GameFontNormal)
-	button:SetScript("OnShow",
-		function (self)
-			self:SetChecked(table[field])
-			self.origValue = table[field] or self.origValue
-		end
-	)
-	if radio then
-		button:SetScript("OnClick",
-			function (self, button, down)
-				this:SetChecked(1)
-				table[field] = not table[field]
-			end
-		)
-	else
-		button:SetScript("OnClick",
-			function (self, button, down)
-				table[field] = not table[field]
-			end
-		)
-	end
-
-	function button:Restore()
-		table[field] = self.origValue
-	end
-	return button
-end
-
-function Elementarist:CreateSlider(text, parent, low, high, step)
-	local name = parent:GetName() .. text
-	local slider = CreateFrame('Slider', name, parent, 'OptionsSliderTemplate')
-	slider:SetScript('OnMouseWheel', Slider_OnMouseWheel)
-	slider:SetMinMaxValues(low, high)
-	slider:SetValueStep(step)
-	slider:EnableMouseWheel(true)
-	_G[name .. 'Text']:SetText(text)
-	_G[name .. 'Low']:SetText('')
-	_G[name .. 'High']:SetText('')
-	local text = slider:CreateFontString(nil, 'BACKGROUND')
-	text:SetFontObject('GameFontHighlightSmall')
-	text:SetPoint('LEFT', slider, 'RIGHT', 7, 0)
-	slider.valText = text
-	return slider
-end
-
-function Elementarist:CreateButton(text, parent)
-	local name = parent:GetName() .. text
-	local button = CreateFrame('Button', name, parent, 'UIPanelButtonTemplate')
-	_G[name .. 'Text']:SetText(text)
-	local text = button:CreateFontString(nil, 'BACKGROUND')
-	text:SetFontObject('GameFontHighlightSmall')
-	text:SetPoint('LEFT', button, 'RIGHT', 7, 0)
-	button.valText = text
-	return button
-end
-
-function Elementarist:CreateDropDownMenu(text, parent, dbTree, varName, itemList, width)
-	local name = parent:GetName() .. text
-    local menu = CreateFrame("Frame", name, parent, "UIDropDownMenuTemplate");
-    menu.displayMode = "MENU"
-
-	local frame = _G[menu:GetName() .. 'Text']
-	frame:SetText(text)
-	frame:SetTextColor(1, 1, 1, 1)
-	frame:SetFontObject(GameFontNormal)
-
-    menu:EnableMouse(true);
-    if(width) then
-        _G.UIDropDownMenu_SetWidth(menu, width);
-    end
-    menu.itemList = itemList or {};
-    menu.init = function()
-            for i=1, #menu.itemList do
-                if(not menu.itemList[i].hooked) then
-                    local func = menu.itemList[i].func or function(self) end;
-                    menu.itemList[i].func = function(self, arg1, arg2)
-                        self = self or _G.this; -- wotlk/tbc hack
-                        dbTree[varName] = self.value;
-                        _G.UIDropDownMenu_SetSelectedValue(menu, self.value);
-                        func(self, arg1, arg2);
-                    end
-                    menu.itemList[i].hooked = true;
-                end
-                local info = _G.UIDropDownMenu_CreateInfo();
-                for k,v in pairs(menu.itemList[i]) do
-                    info[k] = v;
-                end
-                _G.UIDropDownMenu_AddButton(info, _G.UIDROPDOWNMENU_MENU_LEVEL);
-            end
-        end
-    menu:SetScript("OnShow", function(self)
-            _G.UIDropDownMenu_Initialize(self, self.init);
-            _G.UIDropDownMenu_SetSelectedValue(self, dbTree[varName]);
-        end);
-    menu.SetValue = function(self, value)
-            _G.UIDropDownMenu_SetSelectedValue(self, value);
-        end;
-    menu:Hide(); menu:Show();
-    return menu;
-end
-
-function Elementarist:ApplySettings()
-	Elementarist:InitSettings()
-	if (not ElementaristDB.locked) then
-		Elementarist:UnLockFrames()
-	else
-		if (Elementarist.displayFrame) then
-			Elementarist.displayFrame:EnableMouse(false)
-			Elementarist.displayFrame:SetMovable(false)
-			Elementarist.displayFrame:SetBackdropColor(0, 0, 0, .0)
-			Elementarist.debuffTracker:EnableMouse(false)
-			Elementarist.debuffTracker:SetMovable(false)
-			Elementarist.debuffTracker:SetBackdropColor(0, 0, 0, .0)
-			Elementarist.shieldTracker:EnableMouse(false)
-			Elementarist.shieldTracker:SetMovable(false)
-			Elementarist.shieldTracker:SetBackdropColor(0, 0, 0, .0)
-		end
-	end
-	if (not Elementarist:isEnabled()) then
-		if (Elementarist.displayFrame) then
-			Elementarist.displayFrame:Hide()
-			Elementarist.debuffTracker:Hide()
-			Elementarist.shieldTracker:Hide()
-		end
-	else
-		if (Elementarist.displayFrame) then
-			Elementarist.displayFrame:Show()
-			if (ElementaristDB.debuffdisabled) then
-				Elementarist.debuffTracker:Hide()
-			else
-				Elementarist.debuffTracker:Show()
-			end
-			if (ElementaristDB.shielddisabled) then
-				Elementarist.shieldTracker:Hide()
-			else
-				Elementarist.shieldTracker:Show()
-			end
-		end
-	end
-	if (Elementarist.displayFrame) then
-		Elementarist.displayFrame:SetAlpha(ElementaristDB.alpha)
-		Elementarist.displayFrame:SetScale(ElementaristDB.scale)
-		Elementarist.debuffTracker:SetAlpha(ElementaristDB.debuffalpha)
-		Elementarist.debuffTracker:SetScale(ElementaristDB.debuffscale)
-		Elementarist.shieldTracker:SetAlpha(ElementaristDB.shieldalpha)
-		Elementarist.shieldTracker:SetScale(ElementaristDB.shieldscale)
-	end
-end
-
-function Elementarist:StoreUIValues()
-    for i,v in pairs(ElementaristDB) do
-		Elementarist.prevDB[i]=v
-    end
-end
-
-function Elementarist:ReStoreUIValues()
-    for i,v in pairs(Elementarist.prevDB) do
-		ElementaristDB[i]=v
-    end
-end
-
-function Elementarist:CreateConfig()
-	Elementarist.configPanel = CreateFrame( "Frame", "ElementaristConfigPanel", UIParent );
-	-- Register in the Interface Addon Options GUI
-	-- Set the name for the Category for the Options Panel
-	Elementarist.configPanel.name = "Elementarist";
-
-	local EnableBtn = Elementarist:CreateCheckButton(L.CONFIG_ENABLED, Elementarist.configPanel, ElementaristDB, "enabled", false)
-	EnableBtn:SetPoint('TOPLEFT', 10, -8)
-
-	local EnableBtn = Elementarist:CreateCheckButton(L.CONFIG_ONLY_ON_ELE, Elementarist.configPanel, ElementaristDB, "disableIfNotEle", false)
-	EnableBtn:SetPoint('TOPLEFT', 40, -28)
-
-	local LockBtn = Elementarist:CreateCheckButton(L.CONFIG_LOCK_FRAMES, Elementarist.configPanel, ElementaristDB, "locked", false)
-	LockBtn:SetPoint('TOPLEFT', 10, -58)
-
-	local Scale = Elementarist:CreateSlider(L.CONFIG_SPELL_ADV_SCALE, Elementarist.configPanel, .25, 3, .1)
-	Scale:SetScript('OnShow', function(self)
-		self.onShow = true
-		Elementarist:StoreUIValues()
-		self:SetValue(ElementaristDB.scale)
-		self.onShow = nil
-	end)
-	Scale:SetScript('OnValueChanged', function(self, value)
-		self.valText:SetText(format('%.1f', value))
-		if not self.onShow then
-			ElementaristDB.scale=value
-			Elementarist.displayFrame:SetScale(value)
-
-		end
-	end)
-	Scale:SetPoint("TOPLEFT",10,-98)
-	Scale:Show()
-
-	local Alpha = Elementarist:CreateSlider(L.CONFIG_SPELL_ADV_ALPHA, Elementarist.configPanel, .0, 1, .1)
-	Alpha:SetScript('OnShow', function(self)
-		self.onShow = true
-		self:SetValue(ElementaristDB.alpha)
-		self.onShow = nil
-	end)
-	Alpha:SetScript('OnValueChanged', function(self, value)
-		self.valText:SetText(format('%.1f', value))
-		if not self.onShow then
-			ElementaristDB.alpha=value
-			Elementarist.displayFrame:SetAlpha(value)
-		end
-	end)
-	Alpha:SetPoint("TOPLEFT",200,-98)
-	Alpha:Show()
-
-	local DebuffDisableBtn = Elementarist:CreateCheckButton(L.CONFIG_DISABLE_DEBUFF_TRACKER, Elementarist.configPanel, ElementaristDB, "debuffdisabled", false)
-	DebuffDisableBtn:SetPoint('TOPLEFT', 10, -158)
-
-	local DebuffScale = Elementarist:CreateSlider(L.CONFIG_DEBUFF_TRACKER_SCALE, Elementarist.configPanel, .25, 3, .1)
-	DebuffScale:SetScript('OnShow', function(self)
-		self.onShow = true
-		self:SetValue(ElementaristDB.debuffscale)
-		self.onShow = nil
-	end)
-	DebuffScale:SetScript('OnValueChanged', function(self, value)
-		self.valText:SetText(format('%.1f', value))
-		if not self.onShow then
-			ElementaristDB.debuffscale=value
-			Elementarist.debuffTracker:SetScale(value)
-		end
-	end)
-	DebuffScale:SetPoint("TOPLEFT",10,-138)
-	DebuffScale:Show()
-
-	local DebuffAlpha = Elementarist:CreateSlider(L.CONFIG_DEBUFF_TRACKER_ALPHA, Elementarist.configPanel, .0, 1, .1)
-	DebuffAlpha:SetScript('OnShow', function(self)
-		self.onShow = true
-		self:SetValue(ElementaristDB.debuffalpha)
-		self.onShow = nil
-	end)
-	DebuffAlpha:SetScript('OnValueChanged', function(self, value)
-		self.valText:SetText(format('%.1f', value))
-		if not self.onShow then
-			ElementaristDB.debuffalpha=value
-			Elementarist.debuffTracker:SetAlpha(value)
-		end
-	end)
-	DebuffAlpha:SetPoint("TOPLEFT",200,-138)
-	DebuffAlpha:Show()
-
-	local ShieldDisableBtn = Elementarist:CreateCheckButton(L.CONFIG_DISABLE_SHIELD_TRACKER, Elementarist.configPanel, ElementaristDB, "shielddisabled", false)
-	ShieldDisableBtn:SetPoint('TOPLEFT', 10, -218)
-
-	local ShieldScale = Elementarist:CreateSlider(L.CONFIG_SHIELD_TRACKER_SCALE, Elementarist.configPanel, .25, 3, .1)
-	ShieldScale:SetScript('OnShow', function(self)
-		self.onShow = true
-		self:SetValue(ElementaristDB.shieldscale)
-		self.onShow = nil
-	end)
-	ShieldScale:SetScript('OnValueChanged', function(self, value)
-		self.valText:SetText(format('%.1f', value))
-		if not self.onShow then
-			ElementaristDB.shieldscale=value
-			Elementarist.shieldTracker:SetScale(value)
-		end
-	end)
-	ShieldScale:SetPoint("TOPLEFT",10,-198)
-	ShieldScale:Show()
-
-	local ShieldAlpha = Elementarist:CreateSlider(L.CONFIG_SHIELD_TRACKER_ALPHA, Elementarist.configPanel, .0, 1, .1)
-	ShieldAlpha:SetScript('OnShow', function(self)
-		self.onShow = true
-		self:SetValue(ElementaristDB.shieldalpha)
-		self.onShow = nil
-	end)
-	ShieldAlpha:SetScript('OnValueChanged', function(self, value)
-		self.valText:SetText(format('%.1f', value))
-		if not self.onShow then
-			ElementaristDB.shieldalpha=value
-			Elementarist.shieldTracker:SetAlpha(value)
-		end
-	end)
-	ShieldAlpha:SetPoint("TOPLEFT",200,-198)
-	ShieldAlpha:Show()
-
-	local FireNovaBtn = Elementarist:CreateCheckButton(L.CONFIG_ENABLE_NOVA, Elementarist.configPanel, ElementaristDB, "FireNova", false)
-	FireNovaBtn:SetPoint('TOPLEFT', 10, -248)
-
-	local FSBehaviourMenu = Elementarist:CreateDropDownMenu(L.CONFIG_BEHAVIOUR, Elementarist.configPanel, ElementaristDB, "Behaviour", {{text = Elementarist.Behaviours["1"]}, {text = Elementarist.Behaviours["2"]}},200)
-	FSBehaviourMenu:SetPoint('TOPLEFT', 10, -278)
-
-	-- local CLBehaviourMenu = Elementarist:CreateDropDownMenu(L.CONFIG_CLSTBEHAVIOUR, Elementarist.configPanel, ElementaristDB, "CLBehaviour", {{text = Elementarist.CLBehaviours["0"]}, {text = Elementarist.CLBehaviours["1"]}, {text = Elementarist.CLBehaviours["2"]}},200)
-	-- CLBehaviourMenu:SetPoint('TOPLEFT', 10, -308)
-	local UEEnableBtn = Elementarist:CreateCheckButton(L.CONFIG_ENABLE_UE_SPELL, Elementarist.configPanel, ElementaristDB, "EnableUE", false)
-	UEEnableBtn:SetPoint('TOPLEFT', 10, -308)
-
-	local EQEnableBtn = Elementarist:CreateCheckButton(L.CONFIG_ENABLE_EQ_SPELL, Elementarist.configPanel, ElementaristDB, "EnableEQ", false)
-	EQEnableBtn:SetPoint('TOPLEFT', 10, -338)
-
-	local ThreatWarnBtn = Elementarist:CreateCheckButton(L.CONFIG_THREAT_WARNING, Elementarist.configPanel, ElementaristDB, "ThreatWarning", false)
-	ThreatWarnBtn:SetPoint('TOPLEFT', 10, -368)
-
-	local ResetBtn = Elementarist:CreateButton(L.CONFIG_RESET_POSITIONS, Elementarist.configPanel)
-	ResetBtn:SetWidth(160)
-	ResetBtn:SetHeight(22)
-	ResetBtn:SetScript('OnClick', function()
-		Elementarist:ResetPosition()
-	end)
-	ResetBtn:SetPoint("TOPLEFT",10,-398)
-	ResetBtn:Show()
-
-	Elementarist.configPanel.okay = function()
-		Elementarist:ApplySettings()
-	end
-	Elementarist.configPanel.cancel = function()
-		-- cancel button pressed, revert changes
-		Elementarist:ReStoreUIValues()
-		Elementarist:ApplySettings()
-	end
-	Elementarist.configPanel.default = function()
-		-- default button pressed, reset setting
-		ElementaristDB.scale = 1
-		ElementaristDB.debuffscale = 1
-		ElementaristDB.shieldscale = 1
-		ElementaristDB.locked = false
-		ElementaristDB.enabled = true
-		ElementaristDB.disableIfNotEle = true
-		ElementaristDB.debuffdisabled = false
-		ElementaristDB.shielddisabled = false
-		ElementaristDB.alpha = 0.8
-		ElementaristDB.debuffalpha = 1
-		ElementaristDB.shieldalpha = 1
-		ElementaristDB.FireNova = true
-		ElementaristDB.Behaviour = Elementarist.Behaviours["1"]
-		ElementaristDB.EnableUE = false
-		ElementaristDB.EnableEQ = false
-		ElementaristDB.ThreatWarning = true
-		Elementarist:ResetPosition()
-	end
-
-	-- always show frame if config panel is open
-	Elementarist.configPanel:SetScript('OnShow', function(self)
-		self.onShow = true
-		Elementarist:DecideSpells()
-		self.onShow = nil
-	end)
-	Elementarist.configPanel:SetScript('OnHide', function(self)
-		self.onHide = true
-		Elementarist:DecideSpells()
-		self.onHide = nil
-	end)
-	-- Add the panel to the Interface Options
-	InterfaceOptions_AddCategory(Elementarist.configPanel)
-end
-
-function Elementarist.Options(msg)
-	if msg=='debug' then
-		if (Elementarist.DebugMode) then
-			Elementarist:Debug("Debug ended", GetTime())
-		end
-		Elementarist.DebugMode = not ( Elementarist.DebugMode )
-		local debugStatus = "disabled"
-		if (Elementarist.DebugMode) then
-			debugStatus = "enabled. Using frame: " .. Elementarist.DebugChat:GetID()
-			Elementarist:Debug("Debug started", GetTime())
-		end
-		DEFAULT_CHAT_FRAME:AddMessage("Elementarist Debug " .. debugStatus)
-	else
-		InterfaceOptionsFrame_OpenToCategory(getglobal("ElementaristConfigPanel"))
-	end
-end
-
-function Elementarist:ResetPosition()
-	ElementaristDB.x = 0
-	ElementaristDB.y = -100
-	ElementaristDB.relativePoint = "CENTER"
-	ElementaristDB.debuffx = -100
-	ElementaristDB.debuffy = 0
-	ElementaristDB.debuffrelativePoint = "CENTER"
-	ElementaristDB.shieldx = 100
-	ElementaristDB.shieldy = 0
-	ElementaristDB.shieldrelativePoint = "CENTER"
-	Elementarist.displayFrame:ClearAllPoints()
-	Elementarist.displayFrame:SetPoint(ElementaristDB.relativePoint,ElementaristDB.x,ElementaristDB.y)
-	Elementarist.debuffTracker:ClearAllPoints()
-	Elementarist.debuffTracker:SetPoint(ElementaristDB.debuffrelativePoint,ElementaristDB.debuffx,ElementaristDB.debuffy)
-	Elementarist.shieldTracker:ClearAllPoints()
-	Elementarist.shieldTracker:SetPoint(ElementaristDB.shieldrelativePoint,ElementaristDB.shieldx,ElementaristDB.shieldy)
-
-end
-
-function Elementarist:MakeDraggable(frame,x_name,y_name,rp_name)
-	frame:SetBackdropColor(0, 0, 0, .3)
-	frame:EnableMouse(true)
-	frame:SetMovable(true)
-	frame:SetClampedToScreen(true)
-	frame:SetScript("OnMouseDown", function(self) self:StartMoving(); self:SetBackdropColor(0, 0, 0, .6); end)
-	frame:SetScript("OnMouseUp", function(self)
-		self:StopMovingOrSizing()
-		if (Elementarist.locked) then
-			self:SetBackdropColor(0, 0, 0, 0)
-		else
-			self:SetBackdropColor(0, 0, 0, .3)
-		end
-		local _,_,rp,x,y = self:GetPoint()
-		ElementaristDB[x_name] = x
-		ElementaristDB[y_name] = y
-		ElementaristDB[rp_name] = rp
-	end)
-	frame:SetScript("OnDragStop", function(self)
-		self:StopMovingOrSizing();
-		if (Elementarist.locked) then
-			self:SetBackdropColor(0, 0, 0, 0)
-		else
-			self:SetBackdropColor(0, 0, 0, .3)
-		end
-		local _,_,rp,x,y = self:GetPoint()
-		ElementaristDB[x_name] = x
-		ElementaristDB[y_name] = y
-		ElementaristDB[rp_name] = rp
-	end)
-end
-
-function Elementarist:UnLockFrames()
-	Elementarist:MakeDraggable(Elementarist.displayFrame,"x","y","relativePoint")
-	Elementarist:MakeDraggable(Elementarist.debuffTracker,"debuffx","debuffy","debuffrelativePoint")
-	Elementarist:MakeDraggable(Elementarist.shieldTracker,"shieldx","shieldy","shieldrelativePoint")
-end
-
-function Elementarist:CreateGUI()
-	local t
-	local displayFrame = CreateFrame("Frame","ElementaristDisplayFrame",UIParent)
-	displayFrame:SetFrameStrata("BACKGROUND")
-	displayFrame:SetWidth(150)
-	displayFrame:SetHeight(120)
-	displayFrame:SetBackdrop({
-          bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 32,
-	})
-	displayFrame:SetBackdropColor(0, 0, 0, .0)
-	displayFrame:SetPoint(ElementaristDB.relativePoint,ElementaristDB.x,ElementaristDB.y)
-
-	local displayFrame_next = CreateFrame("Frame","$parent_next", ElementaristDisplayFrame)
-	local displayFrame_next1 = CreateFrame("Frame","$parent_next1", ElementaristDisplayFrame)
-	local displayFrame_next2 = CreateFrame("Frame","$parent_next2", ElementaristDisplayFrame)
-	local displayFrame_misc = CreateFrame("Frame","$parent_misc", ElementaristDisplayFrame)
-	local displayFrame_int = CreateFrame("Frame","$parent_int", ElementaristDisplayFrame)
-	local displayFrame_dps = CreateFrame("Frame","$parent_dps", ElementaristDisplayFrame)
-
-	displayFrame_next:SetWidth(60)
-	displayFrame_next1:SetWidth(40)
-	displayFrame_next2:SetWidth(20)
-	displayFrame_misc:SetWidth(40)
-	displayFrame_int:SetWidth(40)
-	displayFrame_dps:SetWidth(60)
-
-	displayFrame_next:SetFrameLevel(10)
-	displayFrame_next1:SetFrameLevel(5)
-	displayFrame_next2:SetFrameLevel(0)
-
-	displayFrame_next:SetHeight(60)
-	displayFrame_next1:SetHeight(40)
-	displayFrame_next2:SetHeight(20)
-	displayFrame_misc:SetHeight(40)
-	displayFrame_int:SetHeight(40)
-	displayFrame_dps:SetHeight(30)
-
-
-	displayFrame_next:SetPoint("TOPLEFT", 45, -30)
-	displayFrame_next1:SetPoint("TOPLEFT", 55, -10)
-	displayFrame_next2:SetPoint("TOPLEFT", 65, 0)
-
-	displayFrame_misc:SetPoint("TOPLEFT", 0, -80)
-	displayFrame_int:SetPoint("TOPLEFT", 110, -80)
-	displayFrame_dps:SetPoint("TOPLEFT", 45, -90)
-
-	t = displayFrame_next:CreateTexture(nil,"BACKGROUND")
-	t:SetTexture(nil)
-	t:SetAllPoints(displayFrame_next)
-	t:SetAlpha(1)
-	displayFrame_next.texture = t
-	Elementarist.textureList["next"] = t
-
-	t = displayFrame_next1:CreateTexture(nil,"BACKGROUND")
-	t:SetTexture(nil)
-	t:SetAllPoints(displayFrame_next1)
-	t:SetAlpha(0.7)
-	displayFrame_next1.texture = t
-	Elementarist.textureList["next1"] = t
-
-	t = displayFrame_next2:CreateTexture(nil,"BACKGROUND")
-	t:SetTexture(nil)
-	t:SetAllPoints(displayFrame_next2)
-	t:SetAlpha(0.5)
-	displayFrame_next2.texture = t
-	Elementarist.textureList["next2"] = t
-
-	t = displayFrame_misc:CreateTexture(nil,"BACKGROUND")
-	t:SetTexture(nil)
-	t:SetAllPoints(displayFrame_misc)
-	t:SetAlpha(1)
-	displayFrame_misc.texture = t
-	Elementarist.textureList["misc"] = t
-
-	t = displayFrame_int:CreateTexture(nil,"BACKGROUND")
-	t:SetTexture(nil)
-	t:SetAllPoints(displayFrame_int)
-	t:SetAlpha(1)
-	displayFrame_int.texture = t
-	Elementarist.textureList["int"] = t
-
-	t = displayFrame_dps:CreateFontString("$parent_DPSText","ARTWORK","GameFontNormal");
-	t:SetAllPoints(displayFrame_dps)
-	t:SetAlpha(1)
-	t:SetText("")
-	Elementarist.textList["dps"] = t
-
-	displayFrame:SetScript("OnUpdate", function(this, elapsed)
-		Elementarist:OnUpdate(elapsed)
-	end)
-
-	local cooldownFrame = CreateFrame("Cooldown","$parent_cooldown", ElementaristDisplayFrame_current, "CooldownFrameTemplate")
-	cooldownFrame:SetHeight(60)
-	cooldownFrame:SetWidth(60)
-	cooldownFrame:ClearAllPoints()
-	cooldownFrame:SetPoint("CENTER", displayFrame_next, "CENTER", 0, 0)
-
-	displayFrame:SetAlpha(ElementaristDB.alpha)
-
-	Elementarist.displayFrame = displayFrame
-	Elementarist.displayFrame_next = displayFrame_next
-	Elementarist.displayFrame_next1 = displayFrame_next1
-	Elementarist.displayFrame_next2 = displayFrame_next2
-	Elementarist.displayFrame_misc =  displayFrame_misc
-	Elementarist.displayFrame_int =  displayFrame_int
-	Elementarist.displayFrame_dps =  displayFrame_dps
-	Elementarist.cooldownFrame = cooldownFrame
-
-	local debuffTracker = CreateFrame("Frame","ElementaristDebuffTrackerFrame",UIParent)
-	debuffTracker:SetFrameStrata("BACKGROUND")
-	debuffTracker:SetWidth(100)
-	debuffTracker:SetHeight(50)
-	debuffTracker:SetBackdrop({
-          bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 32,
-	})
-	debuffTracker:SetBackdropColor(0, 0, 0, .0)
-	debuffTracker:SetPoint(ElementaristDB.debuffrelativePoint,ElementaristDB.debuffx,ElementaristDB.debuffy)
-	debuffTracker:SetAlpha(ElementaristDB.debuffalpha)
-	Elementarist.debuffTracker = debuffTracker
-
-	local debuffTracker_cd = CreateFrame("Frame","$parent_debuff", ElementaristDebuffTrackerFrame)
-	debuffTracker_cd:SetWidth(50)
-	debuffTracker_cd:SetHeight(50)
-	debuffTracker_cd:SetPoint("TOPLEFT", 0, 0)
-	t = debuffTracker_cd:CreateTexture(nil,"BACKGROUND")
-	t:SetTexture(nil)
-	t:SetAllPoints(debuffTracker_cd)
-	t:SetAlpha(1)
-	debuffTracker_cd.texture = t
-	Elementarist.textureList["debuff"] = t
-
-	t = debuffTracker_cd:CreateFontString("$parent_DebuffText","OVERLAY","GameFontNormalLarge")
-	t:SetAllPoints(debuffTracker)
-	t:SetAlpha(1)
-	t:SetText("")
-	Elementarist.textList["debuff"] = t
-
-	local debuffCooldownFrame = CreateFrame("Cooldown","$parent_debuffcooldown", ElementaristDebuffTrackerFrame, "CooldownFrameTemplate")
-	debuffCooldownFrame:SetHeight(50)
-	debuffCooldownFrame:SetWidth(50)
-	debuffCooldownFrame:ClearAllPoints()
-	debuffCooldownFrame:SetPoint("TOPLEFT", Elementarist.debuffTracker, "TOPLEFT", 0, 0)
-	Elementarist.debuffCooldownFrame["main"] = debuffCooldownFrame
-
-	for i=1,4,1 do
-		local debuffTracker_cd = CreateFrame("Frame","$parent_debuff_" .. tostring(i), ElementaristDebuffTrackerFrame)
-		debuffTracker_cd:SetWidth(25)
-		debuffTracker_cd:SetHeight(25)
-		debuffTracker_cd:SetPoint("TOPLEFT", 50 + (25 * ( (i - 1) % 2) ), - ( 25 * ( math.floor( (i - 1) / 2) ) ) )
-		t = debuffTracker_cd:CreateTexture(nil,"BACKGROUND")
-		t:SetTexture(nil)
-		t:SetAllPoints(debuffTracker_cd)
-		t:SetAlpha(1)
-		debuffTracker_cd.texture = t
-		Elementarist.textureList["debuff_" .. tostring(i)] = t
-
-		local debuffCooldownFrame = CreateFrame("Cooldown" ,"$parent_debuffcooldown_" .. tostring(i), ElementaristDebuffTrackerFrame, "CooldownFrameTemplate")
-		debuffCooldownFrame:SetHeight(25)
-		debuffCooldownFrame:SetWidth(25)
-		debuffCooldownFrame:ClearAllPoints()
-		debuffCooldownFrame:SetPoint("TOPLEFT", 50 + (25 * ( (i - 1) % 2) ), - ( 25 * ( math.floor( (i - 1) / 2) ) ) )
-		Elementarist.debuffCooldownFrame["mini_" .. tostring(i)] = debuffCooldownFrame
-	end
-
-	local shieldTracker = CreateFrame("Frame","ElementaristShieldTrackerFrame",UIParent)
-	shieldTracker:SetFrameStrata("BACKGROUND")
-	shieldTracker:SetWidth(50)
-	shieldTracker:SetHeight(50)
-	shieldTracker:SetBackdrop({
-          bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 32,
-	})
-	shieldTracker:SetBackdropColor(0, 0, 0, .0)
-	shieldTracker:SetPoint(ElementaristDB.shieldrelativePoint,ElementaristDB.shieldx,ElementaristDB.shieldy)
-
-	local shieldTracker_cd = CreateFrame("Frame","$parent_shield", ElementaristShieldTrackerFrame)
-	shieldTracker_cd:SetWidth(50)
-	shieldTracker_cd:SetHeight(50)
-	shieldTracker_cd:SetPoint("CENTER", 0, 0)
-	t = shieldTracker_cd:CreateTexture(nil,"BACKGROUND")
-	t:SetTexture(nil)
-	t:SetAllPoints(shieldTracker_cd)
-	t:SetAlpha(1)
-	shieldTracker_cd.texture = t
-	Elementarist.textureList["shield"] = t
-
-	t = shieldTracker_cd:CreateFontString("$parent_ShieldText","OVERLAY","GameFontHighlightLarge");
-	t:SetPoint("BOTTOMRIGHT",shieldTracker,"BOTTOMRIGHT",-5,5)
---	t:SetAllPoints(shieldTracker)
-	t:SetAlpha(1)
-	t:SetText("")
-	Elementarist.textList["shield"] = t
-
-	local shieldCooldownFrame = CreateFrame("Cooldown","$parent_shieldcooldown", ElementaristShieldTrackerFrame, "CooldownFrameTemplate")
-	shieldCooldownFrame:SetHeight(50)
-	shieldCooldownFrame:SetWidth(50)
-	shieldCooldownFrame:ClearAllPoints()
-	shieldCooldownFrame:SetPoint("CENTER", shieldTracker, "CENTER", 0, 0)
-
-	shieldTracker:SetAlpha(ElementaristDB.shieldalpha)
-
-	Elementarist.shieldTracker = shieldTracker
-	Elementarist.shieldCooldownFrame = shieldCooldownFrame
-
-	if (not ElementaristDB.locked) then
-		Elementarist:UnLockFrames()
-	end
-
-	DEFAULT_CHAT_FRAME:AddMessage("Elementarist " .. Elementarist.versionNumber .. " loaded")
-end
+-------------------------------------------------------------------------------
+-- Elementarist Gui functions
+--
+-- GUI functions and structures for Elementarist
+-------------------------------------------------------------------------------
+
+local L = Elementarist.Locals
+
+function Elementarist:CreateCheckButton(name, parent, table, field, radio)
+	local button
+	if radio then
+		button = CreateFrame('CheckButton', parent:GetName() .. name, parent, 'SendMailRadioButtonTemplate')
+	else
+		button = CreateFrame('CheckButton', parent:GetName() .. name, parent, 'OptionsCheckButtonTemplate')
+	end
+	local frame = _G[button:GetName() .. 'Text']
+	frame:SetText(name)
+	frame:SetTextColor(1, 1, 1, 1)
+	frame:SetFontObject(GameFontNormal)
+	button:SetScript("OnShow",
+		function (self)
+			self:SetChecked(table[field])
+			self.origValue = table[field] or self.origValue
+		end
+	)
+	if radio then
+		button:SetScript("OnClick",
+			function (self, button, down)
+				this:SetChecked(1)
+				table[field] = not table[field]
+			end
+		)
+	else
+		button:SetScript("OnClick",
+			function (self, button, down)
+				table[field] = not table[field]
+			end
+		)
+	end
+
+	function button:Restore()
+		table[field] = self.origValue
+	end
+	return button
+end
+
+function Elementarist:CreateSlider(text, parent, low, high, step)
+	local name = parent:GetName() .. text
+	local slider = CreateFrame('Slider', name, parent, 'OptionsSliderTemplate')
+	slider:SetScript('OnMouseWheel', Slider_OnMouseWheel)
+	slider:SetMinMaxValues(low, high)
+	slider:SetValueStep(step)
+	slider:EnableMouseWheel(true)
+	_G[name .. 'Text']:SetText(text)
+	_G[name .. 'Low']:SetText('')
+	_G[name .. 'High']:SetText('')
+	local text = slider:CreateFontString(nil, 'BACKGROUND')
+	text:SetFontObject('GameFontHighlightSmall')
+	text:SetPoint('LEFT', slider, 'RIGHT', 7, 0)
+	slider.valText = text
+	return slider
+end
+
+function Elementarist:CreateButton(text, parent)
+	local name = parent:GetName() .. text
+	local button = CreateFrame('Button', name, parent, 'UIPanelButtonTemplate')
+	_G[name .. 'Text']:SetText(text)
+	local text = button:CreateFontString(nil, 'BACKGROUND')
+	text:SetFontObject('GameFontHighlightSmall')
+	text:SetPoint('LEFT', button, 'RIGHT', 7, 0)
+	button.valText = text
+	return button
+end
+
+function Elementarist:CreateDropDownMenu(text, parent, dbTree, varName, itemList, width)
+	local name = parent:GetName() .. text
+    local menu = CreateFrame("Frame", name, parent, "UIDropDownMenuTemplate");
+    menu.displayMode = "MENU"
+
+	local frame = _G[menu:GetName() .. 'Text']
+	frame:SetText(text)
+	frame:SetTextColor(1, 1, 1, 1)
+	frame:SetFontObject(GameFontNormal)
+
+    menu:EnableMouse(true);
+    if(width) then
+        _G.UIDropDownMenu_SetWidth(menu, width);
+    end
+    menu.itemList = itemList or {};
+    menu.init = function()
+            for i=1, #menu.itemList do
+                if(not menu.itemList[i].hooked) then
+                    local func = menu.itemList[i].func or function(self) end;
+                    menu.itemList[i].func = function(self, arg1, arg2)
+                        self = self or _G.this; -- wotlk/tbc hack
+                        dbTree[varName] = self.value;
+                        _G.UIDropDownMenu_SetSelectedValue(menu, self.value);
+                        func(self, arg1, arg2);
+                    end
+                    menu.itemList[i].hooked = true;
+                end
+                local info = _G.UIDropDownMenu_CreateInfo();
+                for k,v in pairs(menu.itemList[i]) do
+                    info[k] = v;
+                end
+                _G.UIDropDownMenu_AddButton(info, _G.UIDROPDOWNMENU_MENU_LEVEL);
+            end
+        end
+    menu:SetScript("OnShow", function(self)
+            _G.UIDropDownMenu_Initialize(self, self.init);
+            _G.UIDropDownMenu_SetSelectedValue(self, dbTree[varName]);
+        end);
+    menu.SetValue = function(self, value)
+            _G.UIDropDownMenu_SetSelectedValue(self, value);
+        end;
+    menu:Hide(); menu:Show();
+    return menu;
+end
+
+function Elementarist:ApplySettings()
+	Elementarist:InitSettings()
+	if (not ElementaristDB.locked) then
+		Elementarist:UnLockFrames()
+	else
+		if (Elementarist.displayFrame) then
+			Elementarist.displayFrame:EnableMouse(false)
+			Elementarist.displayFrame:SetMovable(false)
+			Elementarist.displayFrame:SetBackdropColor(0, 0, 0, .0)
+			Elementarist.debuffTracker:EnableMouse(false)
+			Elementarist.debuffTracker:SetMovable(false)
+			Elementarist.debuffTracker:SetBackdropColor(0, 0, 0, .0)
+			Elementarist.shieldTracker:EnableMouse(false)
+			Elementarist.shieldTracker:SetMovable(false)
+			Elementarist.shieldTracker:SetBackdropColor(0, 0, 0, .0)
+		end
+	end
+	if (not Elementarist:isEnabled()) then
+		if (Elementarist.displayFrame) then
+			Elementarist.displayFrame:Hide()
+			Elementarist.debuffTracker:Hide()
+			Elementarist.shieldTracker:Hide()
+		end
+	else
+		if (Elementarist.displayFrame) then
+			Elementarist.displayFrame:Show()
+			if (ElementaristDB.debuffdisabled) then
+				Elementarist.debuffTracker:Hide()
+			else
+				Elementarist.debuffTracker:Show()
+			end
+			if (ElementaristDB.shielddisabled) then
+				Elementarist.shieldTracker:Hide()
+			else
+				Elementarist.shieldTracker:Show()
+			end
+		end
+	end
+	if (Elementarist.displayFrame) then
+		Elementarist.displayFrame:SetAlpha(ElementaristDB.alpha)
+		Elementarist.displayFrame:SetScale(ElementaristDB.scale)
+		Elementarist.debuffTracker:SetAlpha(ElementaristDB.debuffalpha)
+		Elementarist.debuffTracker:SetScale(ElementaristDB.debuffscale)
+		Elementarist.shieldTracker:SetAlpha(ElementaristDB.shieldalpha)
+		Elementarist.shieldTracker:SetScale(ElementaristDB.shieldscale)
+	end
+end
+
+function Elementarist:StoreUIValues()
+    for i,v in pairs(ElementaristDB) do
+		Elementarist.prevDB[i]=v
+    end
+end
+
+function Elementarist:ReStoreUIValues()
+    for i,v in pairs(Elementarist.prevDB) do
+		ElementaristDB[i]=v
+    end
+end
+
+function Elementarist:CreateConfig()
+	Elementarist.configPanel = CreateFrame( "Frame", "ElementaristConfigPanel", UIParent );
+	-- Register in the Interface Addon Options GUI
+	-- Set the name for the Category for the Options Panel
+	Elementarist.configPanel.name = "Elementarist";
+
+	local EnableBtn = Elementarist:CreateCheckButton(L.CONFIG_ENABLED, Elementarist.configPanel, ElementaristDB, "enabled", false)
+	EnableBtn:SetPoint('TOPLEFT', 10, -8)
+
+	local EnableBtn = Elementarist:CreateCheckButton(L.CONFIG_ONLY_ON_ELE, Elementarist.configPanel, ElementaristDB, "disableIfNotEle", false)
+	EnableBtn:SetPoint('TOPLEFT', 40, -28)
+
+	local LockBtn = Elementarist:CreateCheckButton(L.CONFIG_LOCK_FRAMES, Elementarist.configPanel, ElementaristDB, "locked", false)
+	LockBtn:SetPoint('TOPLEFT', 10, -58)
+
+	local Scale = Elementarist:CreateSlider(L.CONFIG_SPELL_ADV_SCALE, Elementarist.configPanel, .25, 3, .1)
+	Scale:SetScript('OnShow', function(self)
+		self.onShow = true
+		Elementarist:StoreUIValues()
+		self:SetValue(ElementaristDB.scale)
+		self.onShow = nil
+	end)
+	Scale:SetScript('OnValueChanged', function(self, value)
+		self.valText:SetText(format('%.1f', value))
+		if not self.onShow then
+			ElementaristDB.scale=value
+			Elementarist.displayFrame:SetScale(value)
+
+		end
+	end)
+	Scale:SetPoint("TOPLEFT",10,-98)
+	Scale:Show()
+
+	local Alpha = Elementarist:CreateSlider(L.CONFIG_SPELL_ADV_ALPHA, Elementarist.configPanel, .0, 1, .1)
+	Alpha:SetScript('OnShow', function(self)
+		self.onShow = true
+		self:SetValue(ElementaristDB.alpha)
+		self.onShow = nil
+	end)
+	Alpha:SetScript('OnValueChanged', function(self, value)
+		self.valText:SetText(format('%.1f', value))
+		if not self.onShow then
+			ElementaristDB.alpha=value
+			Elementarist.displayFrame:SetAlpha(value)
+		end
+	end)
+	Alpha:SetPoint("TOPLEFT",200,-98)
+	Alpha:Show()
+
+	local DebuffDisableBtn = Elementarist:CreateCheckButton(L.CONFIG_DISABLE_DEBUFF_TRACKER, Elementarist.configPanel, ElementaristDB, "debuffdisabled", false)
+	DebuffDisableBtn:SetPoint('TOPLEFT', 10, -158)
+
+	local DebuffScale = Elementarist:CreateSlider(L.CONFIG_DEBUFF_TRACKER_SCALE, Elementarist.configPanel, .25, 3, .1)
+	DebuffScale:SetScript('OnShow', function(self)
+		self.onShow = true
+		self:SetValue(ElementaristDB.debuffscale)
+		self.onShow = nil
+	end)
+	DebuffScale:SetScript('OnValueChanged', function(self, value)
+		self.valText:SetText(format('%.1f', value))
+		if not self.onShow then
+			ElementaristDB.debuffscale=value
+			Elementarist.debuffTracker:SetScale(value)
+		end
+	end)
+	DebuffScale:SetPoint("TOPLEFT",10,-138)
+	DebuffScale:Show()
+
+	local DebuffAlpha = Elementarist:CreateSlider(L.CONFIG_DEBUFF_TRACKER_ALPHA, Elementarist.configPanel, .0, 1, .1)
+	DebuffAlpha:SetScript('OnShow', function(self)
+		self.onShow = true
+		self:SetValue(ElementaristDB.debuffalpha)
+		self.onShow = nil
+	end)
+	DebuffAlpha:SetScript('OnValueChanged', function(self, value)
+		self.valText:SetText(format('%.1f', value))
+		if not self.onShow then
+			ElementaristDB.debuffalpha=value
+			Elementarist.debuffTracker:SetAlpha(value)
+		end
+	end)
+	DebuffAlpha:SetPoint("TOPLEFT",200,-138)
+	DebuffAlpha:Show()
+
+	local ShieldDisableBtn = Elementarist:CreateCheckButton(L.CONFIG_DISABLE_SHIELD_TRACKER, Elementarist.configPanel, ElementaristDB, "shielddisabled", false)
+	ShieldDisableBtn:SetPoint('TOPLEFT', 10, -218)
+
+	local ShieldScale = Elementarist:CreateSlider(L.CONFIG_SHIELD_TRACKER_SCALE, Elementarist.configPanel, .25, 3, .1)
+	ShieldScale:SetScript('OnShow', function(self)
+		self.onShow = true
+		self:SetValue(ElementaristDB.shieldscale)
+		self.onShow = nil
+	end)
+	ShieldScale:SetScript('OnValueChanged', function(self, value)
+		self.valText:SetText(format('%.1f', value))
+		if not self.onShow then
+			ElementaristDB.shieldscale=value
+			Elementarist.shieldTracker:SetScale(value)
+		end
+	end)
+	ShieldScale:SetPoint("TOPLEFT",10,-198)
+	ShieldScale:Show()
+
+	local ShieldAlpha = Elementarist:CreateSlider(L.CONFIG_SHIELD_TRACKER_ALPHA, Elementarist.configPanel, .0, 1, .1)
+	ShieldAlpha:SetScript('OnShow', function(self)
+		self.onShow = true
+		self:SetValue(ElementaristDB.shieldalpha)
+		self.onShow = nil
+	end)
+	ShieldAlpha:SetScript('OnValueChanged', function(self, value)
+		self.valText:SetText(format('%.1f', value))
+		if not self.onShow then
+			ElementaristDB.shieldalpha=value
+			Elementarist.shieldTracker:SetAlpha(value)
+		end
+	end)
+	ShieldAlpha:SetPoint("TOPLEFT",200,-198)
+	ShieldAlpha:Show()
+
+	local FireNovaBtn = Elementarist:CreateCheckButton(L.CONFIG_ENABLE_NOVA, Elementarist.configPanel, ElementaristDB, "FireNova", false)
+	FireNovaBtn:SetPoint('TOPLEFT', 10, -248)
+
+	local FSBehaviourMenu = Elementarist:CreateDropDownMenu(L.CONFIG_BEHAVIOUR, Elementarist.configPanel, ElementaristDB, "Behaviour", {{text = Elementarist.Behaviours["1"]}, {text = Elementarist.Behaviours["2"]}},200)
+	FSBehaviourMenu:SetPoint('TOPLEFT', 10, -278)
+
+	-- local CLBehaviourMenu = Elementarist:CreateDropDownMenu(L.CONFIG_CLSTBEHAVIOUR, Elementarist.configPanel, ElementaristDB, "CLBehaviour", {{text = Elementarist.CLBehaviours["0"]}, {text = Elementarist.CLBehaviours["1"]}, {text = Elementarist.CLBehaviours["2"]}},200)
+	-- CLBehaviourMenu:SetPoint('TOPLEFT', 10, -308)
+	local UEEnableBtn = Elementarist:CreateCheckButton(L.CONFIG_ENABLE_UE_SPELL, Elementarist.configPanel, ElementaristDB, "EnableUE", false)
+	UEEnableBtn:SetPoint('TOPLEFT', 10, -308)
+
+	local EQEnableBtn = Elementarist:CreateCheckButton(L.CONFIG_ENABLE_EQ_SPELL, Elementarist.configPanel, ElementaristDB, "EnableEQ", false)
+	EQEnableBtn:SetPoint('TOPLEFT', 10, -338)
+
+	local ThreatWarnBtn = Elementarist:CreateCheckButton(L.CONFIG_THREAT_WARNING, Elementarist.configPanel, ElementaristDB, "ThreatWarning", false)
+	ThreatWarnBtn:SetPoint('TOPLEFT', 10, -368)
+
+	local ResetBtn = Elementarist:CreateButton(L.CONFIG_RESET_POSITIONS, Elementarist.configPanel)
+	ResetBtn:SetWidth(160)
+	ResetBtn:SetHeight(22)
+	ResetBtn:SetScript('OnClick', function()
+		Elementarist:ResetPosition()
+	end)
+	ResetBtn:SetPoint("TOPLEFT",10,-398)
+	ResetBtn:Show()
+
+	Elementarist.configPanel.okay = function()
+		Elementarist:ApplySettings()
+	end
+	Elementarist.configPanel.cancel = function()
+		-- cancel button pressed, revert changes
+		Elementarist:ReStoreUIValues()
+		Elementarist:ApplySettings()
+	end
+	Elementarist.configPanel.default = function()
+		-- default button pressed, reset setting
+		ElementaristDB.scale = 1
+		ElementaristDB.debuffscale = 1
+		ElementaristDB.shieldscale = 1
+		ElementaristDB.locked = false
+		ElementaristDB.enabled = true
+		ElementaristDB.disableIfNotEle = true
+		ElementaristDB.debuffdisabled = false
+		ElementaristDB.shielddisabled = false
+		ElementaristDB.alpha = 0.8
+		ElementaristDB.debuffalpha = 1
+		ElementaristDB.shieldalpha = 1
+		ElementaristDB.FireNova = true
+		ElementaristDB.Behaviour = Elementarist.Behaviours["1"]
+		ElementaristDB.EnableUE = false
+		ElementaristDB.EnableEQ = false
+		ElementaristDB.ThreatWarning = true
+		Elementarist:ResetPosition()
+	end
+
+	-- always show frame if config panel is open
+	Elementarist.configPanel:SetScript('OnShow', function(self)
+		self.onShow = true
+		Elementarist:DecideSpells()
+		self.onShow = nil
+	end)
+	Elementarist.configPanel:SetScript('OnHide', function(self)
+		self.onHide = true
+		Elementarist:DecideSpells()
+		self.onHide = nil
+	end)
+	-- Add the panel to the Interface Options
+	InterfaceOptions_AddCategory(Elementarist.configPanel)
+end
+
+function Elementarist.Options(msg)
+	if (msg=='debug') then
+		if (Elementarist.DebugMode) then
+			Elementarist:Debug("Debug ended", GetTime())
+		end
+		Elementarist.DebugMode = not ( Elementarist.DebugMode )
+		local debugStatus = "disabled"
+		if (Elementarist.DebugMode) then
+			Elementarist.DebugChat = Elementarist:GetDebugFrame()
+			debugStatus = "enabled. Using frame: " .. Elementarist.DebugChat:GetID()
+			Elementarist:Debug("Debug started", GetTime())
+		end
+		DEFAULT_CHAT_FRAME:AddMessage("Elementarist Debug " .. debugStatus)
+	else
+		InterfaceOptionsFrame_OpenToCategory(getglobal("ElementaristConfigPanel"))
+	end
+end
+
+function Elementarist:ResetPosition()
+	ElementaristDB.x = 0
+	ElementaristDB.y = -100
+	ElementaristDB.relativePoint = "CENTER"
+	ElementaristDB.debuffx = -100
+	ElementaristDB.debuffy = 0
+	ElementaristDB.debuffrelativePoint = "CENTER"
+	ElementaristDB.shieldx = 100
+	ElementaristDB.shieldy = 0
+	ElementaristDB.shieldrelativePoint = "CENTER"
+	Elementarist.displayFrame:ClearAllPoints()
+	Elementarist.displayFrame:SetPoint(ElementaristDB.relativePoint,ElementaristDB.x,ElementaristDB.y)
+	Elementarist.debuffTracker:ClearAllPoints()
+	Elementarist.debuffTracker:SetPoint(ElementaristDB.debuffrelativePoint,ElementaristDB.debuffx,ElementaristDB.debuffy)
+	Elementarist.shieldTracker:ClearAllPoints()
+	Elementarist.shieldTracker:SetPoint(ElementaristDB.shieldrelativePoint,ElementaristDB.shieldx,ElementaristDB.shieldy)
+
+end
+
+function Elementarist:MakeDraggable(frame,x_name,y_name,rp_name)
+	frame:SetBackdropColor(0, 0, 0, .3)
+	frame:EnableMouse(true)
+	frame:SetMovable(true)
+	frame:SetClampedToScreen(true)
+	frame:SetScript("OnMouseDown", function(self) self:StartMoving(); self:SetBackdropColor(0, 0, 0, .6); end)
+	frame:SetScript("OnMouseUp", function(self)
+		self:StopMovingOrSizing()
+		if (Elementarist.locked) then
+			self:SetBackdropColor(0, 0, 0, 0)
+		else
+			self:SetBackdropColor(0, 0, 0, .3)
+		end
+		local _,_,rp,x,y = self:GetPoint()
+		ElementaristDB[x_name] = x
+		ElementaristDB[y_name] = y
+		ElementaristDB[rp_name] = rp
+	end)
+	frame:SetScript("OnDragStop", function(self)
+		self:StopMovingOrSizing();
+		if (Elementarist.locked) then
+			self:SetBackdropColor(0, 0, 0, 0)
+		else
+			self:SetBackdropColor(0, 0, 0, .3)
+		end
+		local _,_,rp,x,y = self:GetPoint()
+		ElementaristDB[x_name] = x
+		ElementaristDB[y_name] = y
+		ElementaristDB[rp_name] = rp
+	end)
+end
+
+function Elementarist:UnLockFrames()
+	Elementarist:MakeDraggable(Elementarist.displayFrame,"x","y","relativePoint")
+	Elementarist:MakeDraggable(Elementarist.debuffTracker,"debuffx","debuffy","debuffrelativePoint")
+	Elementarist:MakeDraggable(Elementarist.shieldTracker,"shieldx","shieldy","shieldrelativePoint")
+end
+
+function Elementarist:CreateGUI()
+	local t
+	local displayFrame = CreateFrame("Frame","ElementaristDisplayFrame",UIParent)
+	displayFrame:SetFrameStrata("BACKGROUND")
+	displayFrame:SetWidth(150)
+	displayFrame:SetHeight(120)
+	displayFrame:SetBackdrop({
+          bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 32,
+	})
+	displayFrame:SetBackdropColor(0, 0, 0, .0)
+	displayFrame:SetPoint(ElementaristDB.relativePoint,ElementaristDB.x,ElementaristDB.y)
+
+	local displayFrame_next = CreateFrame("Frame","$parent_next", ElementaristDisplayFrame)
+	local displayFrame_next1 = CreateFrame("Frame","$parent_next1", ElementaristDisplayFrame)
+	local displayFrame_next2 = CreateFrame("Frame","$parent_next2", ElementaristDisplayFrame)
+	local displayFrame_misc = CreateFrame("Frame","$parent_misc", ElementaristDisplayFrame)
+	local displayFrame_int = CreateFrame("Frame","$parent_int", ElementaristDisplayFrame)
+	local displayFrame_dps = CreateFrame("Frame","$parent_dps", ElementaristDisplayFrame)
+
+	displayFrame_next:SetWidth(60)
+	displayFrame_next1:SetWidth(40)
+	displayFrame_next2:SetWidth(20)
+	displayFrame_misc:SetWidth(40)
+	displayFrame_int:SetWidth(40)
+	displayFrame_dps:SetWidth(60)
+
+	displayFrame_next:SetFrameLevel(10)
+	displayFrame_next1:SetFrameLevel(5)
+	displayFrame_next2:SetFrameLevel(0)
+
+	displayFrame_next:SetHeight(60)
+	displayFrame_next1:SetHeight(40)
+	displayFrame_next2:SetHeight(20)
+	displayFrame_misc:SetHeight(40)
+	displayFrame_int:SetHeight(40)
+	displayFrame_dps:SetHeight(30)
+
+
+	displayFrame_next:SetPoint("TOPLEFT", 45, -30)
+	displayFrame_next1:SetPoint("TOPLEFT", 55, -10)
+	displayFrame_next2:SetPoint("TOPLEFT", 65, 0)
+
+	displayFrame_misc:SetPoint("TOPLEFT", 0, -80)
+	displayFrame_int:SetPoint("TOPLEFT", 110, -80)
+	displayFrame_dps:SetPoint("TOPLEFT", 45, -90)
+
+	t = displayFrame_next:CreateTexture(nil,"BACKGROUND")
+	t:SetTexture(nil)
+	t:SetAllPoints(displayFrame_next)
+	t:SetAlpha(1)
+	displayFrame_next.texture = t
+	Elementarist.textureList["next"] = t
+
+	t = displayFrame_next1:CreateTexture(nil,"BACKGROUND")
+	t:SetTexture(nil)
+	t:SetAllPoints(displayFrame_next1)
+	t:SetAlpha(0.7)
+	displayFrame_next1.texture = t
+	Elementarist.textureList["next1"] = t
+
+	t = displayFrame_next2:CreateTexture(nil,"BACKGROUND")
+	t:SetTexture(nil)
+	t:SetAllPoints(displayFrame_next2)
+	t:SetAlpha(0.5)
+	displayFrame_next2.texture = t
+	Elementarist.textureList["next2"] = t
+
+	t = displayFrame_misc:CreateTexture(nil,"BACKGROUND")
+	t:SetTexture(nil)
+	t:SetAllPoints(displayFrame_misc)
+	t:SetAlpha(1)
+	displayFrame_misc.texture = t
+	Elementarist.textureList["misc"] = t
+
+	t = displayFrame_int:CreateTexture(nil,"BACKGROUND")
+	t:SetTexture(nil)
+	t:SetAllPoints(displayFrame_int)
+	t:SetAlpha(1)
+	displayFrame_int.texture = t
+	Elementarist.textureList["int"] = t
+
+	t = displayFrame_dps:CreateFontString("$parent_DPSText","ARTWORK","GameFontNormal");
+	t:SetAllPoints(displayFrame_dps)
+	t:SetAlpha(1)
+	t:SetText("")
+	Elementarist.textList["dps"] = t
+
+	displayFrame:SetScript("OnUpdate", function(this, elapsed)
+		Elementarist:OnUpdate(elapsed)
+	end)
+
+	local cooldownFrame = CreateFrame("Cooldown","$parent_cooldown", ElementaristDisplayFrame_current, "CooldownFrameTemplate")
+	cooldownFrame:SetHeight(60)
+	cooldownFrame:SetWidth(60)
+	cooldownFrame:ClearAllPoints()
+	cooldownFrame:SetPoint("CENTER", displayFrame_next, "CENTER", 0, 0)
+
+	displayFrame:SetAlpha(ElementaristDB.alpha)
+
+	Elementarist.displayFrame = displayFrame
+	Elementarist.displayFrame_next = displayFrame_next
+	Elementarist.displayFrame_next1 = displayFrame_next1
+	Elementarist.displayFrame_next2 = displayFrame_next2
+	Elementarist.displayFrame_misc =  displayFrame_misc
+	Elementarist.displayFrame_int =  displayFrame_int
+	Elementarist.displayFrame_dps =  displayFrame_dps
+	Elementarist.cooldownFrame = cooldownFrame
+
+	local debuffTracker = CreateFrame("Frame","ElementaristDebuffTrackerFrame",UIParent)
+	debuffTracker:SetFrameStrata("BACKGROUND")
+	debuffTracker:SetWidth(100)
+	debuffTracker:SetHeight(50)
+	debuffTracker:SetBackdrop({
+          bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 32,
+	})
+	debuffTracker:SetBackdropColor(0, 0, 0, .0)
+	debuffTracker:SetPoint(ElementaristDB.debuffrelativePoint,ElementaristDB.debuffx,ElementaristDB.debuffy)
+	debuffTracker:SetAlpha(ElementaristDB.debuffalpha)
+	Elementarist.debuffTracker = debuffTracker
+
+	local debuffTracker_cd = CreateFrame("Frame","$parent_debuff", ElementaristDebuffTrackerFrame)
+	debuffTracker_cd:SetWidth(50)
+	debuffTracker_cd:SetHeight(50)
+	debuffTracker_cd:SetPoint("TOPLEFT", 0, 0)
+	t = debuffTracker_cd:CreateTexture(nil,"BACKGROUND")
+	t:SetTexture(nil)
+	t:SetAllPoints(debuffTracker_cd)
+	t:SetAlpha(1)
+	debuffTracker_cd.texture = t
+	Elementarist.textureList["debuff"] = t
+
+	t = debuffTracker_cd:CreateFontString("$parent_DebuffText","OVERLAY","GameFontNormalLarge")
+	t:SetAllPoints(debuffTracker)
+	t:SetAlpha(1)
+	t:SetText("")
+	Elementarist.textList["debuff"] = t
+
+	local debuffCooldownFrame = CreateFrame("Cooldown","$parent_debuffcooldown", ElementaristDebuffTrackerFrame, "CooldownFrameTemplate")
+	debuffCooldownFrame:SetHeight(50)
+	debuffCooldownFrame:SetWidth(50)
+	debuffCooldownFrame:ClearAllPoints()
+	debuffCooldownFrame:SetPoint("TOPLEFT", Elementarist.debuffTracker, "TOPLEFT", 0, 0)
+	Elementarist.debuffCooldownFrame["main"] = debuffCooldownFrame
+
+	for i=1,4,1 do
+		local debuffTracker_cd = CreateFrame("Frame","$parent_debuff_" .. tostring(i), ElementaristDebuffTrackerFrame)
+		debuffTracker_cd:SetWidth(25)
+		debuffTracker_cd:SetHeight(25)
+		debuffTracker_cd:SetPoint("TOPLEFT", 50 + (25 * ( (i - 1) % 2) ), - ( 25 * ( math.floor( (i - 1) / 2) ) ) )
+		t = debuffTracker_cd:CreateTexture(nil,"BACKGROUND")
+		t:SetTexture(nil)
+		t:SetAllPoints(debuffTracker_cd)
+		t:SetAlpha(1)
+		debuffTracker_cd.texture = t
+		Elementarist.textureList["debuff_" .. tostring(i)] = t
+
+		local debuffCooldownFrame = CreateFrame("Cooldown" ,"$parent_debuffcooldown_" .. tostring(i), ElementaristDebuffTrackerFrame, "CooldownFrameTemplate")
+		debuffCooldownFrame:SetHeight(25)
+		debuffCooldownFrame:SetWidth(25)
+		debuffCooldownFrame:ClearAllPoints()
+		debuffCooldownFrame:SetPoint("TOPLEFT", 50 + (25 * ( (i - 1) % 2) ), - ( 25 * ( math.floor( (i - 1) / 2) ) ) )
+		Elementarist.debuffCooldownFrame["mini_" .. tostring(i)] = debuffCooldownFrame
+	end
+
+	local shieldTracker = CreateFrame("Frame","ElementaristShieldTrackerFrame",UIParent)
+	shieldTracker:SetFrameStrata("BACKGROUND")
+	shieldTracker:SetWidth(50)
+	shieldTracker:SetHeight(50)
+	shieldTracker:SetBackdrop({
+          bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 32,
+	})
+	shieldTracker:SetBackdropColor(0, 0, 0, .0)
+	shieldTracker:SetPoint(ElementaristDB.shieldrelativePoint,ElementaristDB.shieldx,ElementaristDB.shieldy)
+
+	local shieldTracker_cd = CreateFrame("Frame","$parent_shield", ElementaristShieldTrackerFrame)
+	shieldTracker_cd:SetWidth(50)
+	shieldTracker_cd:SetHeight(50)
+	shieldTracker_cd:SetPoint("CENTER", 0, 0)
+	t = shieldTracker_cd:CreateTexture(nil,"BACKGROUND")
+	t:SetTexture(nil)
+	t:SetAllPoints(shieldTracker_cd)
+	t:SetAlpha(1)
+	shieldTracker_cd.texture = t
+	Elementarist.textureList["shield"] = t
+
+	t = shieldTracker_cd:CreateFontString("$parent_ShieldText","OVERLAY","GameFontHighlightLarge");
+	t:SetPoint("BOTTOMRIGHT",shieldTracker,"BOTTOMRIGHT",-5,5)
+--	t:SetAllPoints(shieldTracker)
+	t:SetAlpha(1)
+	t:SetText("")
+	Elementarist.textList["shield"] = t
+
+	local shieldCooldownFrame = CreateFrame("Cooldown","$parent_shieldcooldown", ElementaristShieldTrackerFrame, "CooldownFrameTemplate")
+	shieldCooldownFrame:SetHeight(50)
+	shieldCooldownFrame:SetWidth(50)
+	shieldCooldownFrame:ClearAllPoints()
+	shieldCooldownFrame:SetPoint("CENTER", shieldTracker, "CENTER", 0, 0)
+
+	shieldTracker:SetAlpha(ElementaristDB.shieldalpha)
+
+	Elementarist.shieldTracker = shieldTracker
+	Elementarist.shieldCooldownFrame = shieldCooldownFrame
+
+	if (not ElementaristDB.locked) then
+		Elementarist:UnLockFrames()
+	end
+
+	DEFAULT_CHAT_FRAME:AddMessage("Elementarist " .. Elementarist.versionNumber .. " loaded")
+end
diff --git a/Elementarist.lua b/Elementarist.lua
index 6244b73..631718d 100755
--- a/Elementarist.lua
+++ b/Elementarist.lua
@@ -1,1137 +1,1140 @@
--------------------------------------------------------------------------------
--- Elementarist 2.0.2
---
--- Shows the advised spell for an elemental shaman for optimal DPS output.
--------------------------------------------------------------------------------
-
-Elementarist = {Locals = {}}
-
-local L = Elementarist.Locals
-
-Elementarist.versionNumber = '2.0.2'
-Elementarist.playerName = UnitName("player")
-Elementarist.playerGUID = UnitGUID("player")
-Elementarist.targetGUID = nil
-Elementarist.spellHaste = GetCombatRatingBonus(20)
-Elementarist.timeSinceLastUpdate = 0
-Elementarist.debuffTrackerUpdate = 0
-Elementarist.shieldTrackerUpdate = 0
-Elementarist.spellPower = GetSpellBonusDamage(4);	-- nature spell bonus
-Elementarist.lastBaseGCD = 1.5
-Elementarist.lastShockCD = 5
-Elementarist.person = {
-	["foeCount"]	= 0,
-	["friendCount"]	= 0,
-	["friend"]  = {},
-	["foe"]		= {}
-}
-Elementarist.debuffCooldowns = {
-}
-Elementarist.lastPersonTablePurged = 0.0;
-Elementarist.configPanel = nil
-Elementarist.prevDB = {}
-Elementarist.DPSTable = {}
-Elementarist.DebugMode = false
-Elementarist.DebugChat = DEFAULT_CHAT_FRAME
-Elementarist.inParty = 0
-Elementarist.OmniCC = _G['OmniCC']
-Elementarist.SpellFlash = _G['SpellFlashAddon']
-Elementarist.SFHistory = {
-	["spell"] = nil,
-	["misc"] = nil,
-	["int"] = nil
-}
-Elementarist.isEle = false
-Elementarist.talentUnsure = true
-Elementarist.lastSpell = nil
-Elementarist.CustomIDs = {
-	["Flask of Enhancement Item"] = 58149,
-	["Flask of Enhancement Spell"] = 79640,
-	["Moonkin Aura"] = 24907,
-	["Mind Quickening"] = 49868
-}
-Elementarist.SpellList = {
-	["Flame Shock"] = GetSpellInfo(8050),
-	["Lightning Bolt"] = GetSpellInfo(403),
-	["Lava Burst"] = GetSpellInfo(51505),
-	["Chain Lightning"] = GetSpellInfo(421),
-	["Thunderstorm"] = GetSpellInfo(59159),
-	["Purge"]	= GetSpellInfo(8012),
-	["Wind Shear"] = GetSpellInfo(57994),
-	["Water Shield"] = GetSpellInfo(52127),
-	["Flametongue Weapon"] = GetSpellInfo(8024),
-	["Wrath of Air Totem"] = GetSpellInfo(3738),
-	["Mana Spring Totem"] = GetSpellInfo(567),
-	["Elemental Mastery"] = GetSpellInfo(16166),
-	["Fire Nova"] = GetSpellInfo(1535),
-	["Earth Shock"] = GetSpellInfo(8042),
-	["Searing Totem"] = GetSpellInfo(3599),
-	["Lightning Shield"] = GetSpellInfo(324),
-	["Unleash Elements"] = GetSpellInfo(73680),
-	["Earthquake"] = GetSpellInfo(61882),
-
-	-- racials
-	["Berserking"] = GetSpellInfo(26297),	-- Troll racial
-	["Blood Fury"] = GetSpellInfo(33697),	-- Orc racial
-
-	-- debuffs
-	["Totem of Wrath Debuff"] = GetSpellInfo(30708),
-	["Heart of the Crusader"] = GetSpellInfo(54499),
-
-	-- other buffs
-	["Demonic Pact"] = GetSpellInfo(48090),
-	["Flask of Enhancement"] = GetSpellInfo(Elementarist.CustomIDs["Flask of Enhancement Spell"]),
-	["Flask of the Draconic Mind"] = GetSpellInfo(79470),
-	["Lifeblood"] = GetSpellInfo(55503)
-}
-Elementarist.debuffCooldownFrame = {
-	["main"] = nil,
-	["mini_1"] = nil,
-	["mini_2"] = nil,
-	["mini_3"] = nil,
-	["mini_4"] = nil
-}
-Elementarist.textureList = {
-	["next"] = nil,
-	["next1"] = nil,
-	["next2"] = nil,
-	["misc"] = nil,
-	["int"] = nil,
-	["debuff"] = nil,
-	["debuff_1"] = nil,
-	["debuff_2"] = nil,
-	["debuff_3"] = nil,
-	["debuff_4"] = nil,
-	["shield"] = nil
-}
-
-Elementarist.textList = {
-	["dps"] = nil,
-	["debuff"] = nil,
-	["shield"] = nil
-}
-Elementarist.Behaviours = {
-}
-Elementarist.CLBehaviours = {
-}
-Elementarist.HostileFilter = {
-  ["_DAMAGE"] = true,
-  ["_LEECH"] = true,
-  ["_DRAIN"] = true,
-  ["_STOLEN"] = true,
-  ["_INSTAKILL"] = true,
-  ["_INTERRUPT"] = true,
-  ["_MISSED"] = true
-}
-
--- Our sneaky frame to watch for events ... checks Elementarist.events[] for the function.  Passes all args.
-Elementarist.eventFrame = CreateFrame("Frame")
-Elementarist.eventFrame:SetScript("OnEvent", function(this, event, ...)
-  Elementarist.events[event](...)
-end)
-
-Elementarist.eventFrame:RegisterEvent("ADDON_LOADED")
-Elementarist.eventFrame:RegisterEvent("PLAYER_LOGIN")
-Elementarist.eventFrame:RegisterEvent("PLAYER_ALIVE")
-
--- Define our Event Handlers here
-Elementarist.events = {}
-
-function Elementarist:Debug(statictxt,msg)
-	if (Elementarist.DebugMode) and (Elementarist.DebugChat) then
-		if (msg) then
-			Elementarist.DebugChat:AddMessage( statictxt  .. " : " .. msg)
-		else
-			Elementarist.DebugChat:AddMessage( statictxt  .. " : " .. "<nil>")
-		end
-	end
-end
-
-function Elementarist:GetDebugFrame()
-	for i=1,NUM_CHAT_WINDOWS do
-		local windowName = GetChatWindowInfo(i);
-		if windowName == "EleDBG" then
-			return getglobal("ChatFrame" .. i)
-		end
-	end
-end
-
-function Elementarist.events.PLAYER_TALENT_UPDATE()
-	Elementarist:detectTalent()
-
-	Elementarist:ApplySettings()
-end
-
-function Elementarist.events.PARTY_MEMBERS_CHANGED()
-	Elementarist.inParty = Elementarist:PlayerInParty()
-end
-
-function Elementarist.events.PLAYER_ALIVE()
-	-- check anything
-	Elementarist:detectTalent()
-	Elementarist:ApplySettings()
-
-	-- Elementarist.eventFrame:UnregisterEvent("PLAYER_ALIVE")
-end
-
-function Elementarist.events.PLAYER_ENTERING_WORLD()
-	Elementarist:detectTalent()
-end
-
-function Elementarist.events.PLAYER_LOGIN()
-	Elementarist.playerName = UnitName("player");
-
-	Elementarist.spellHaste = GetCombatRatingBonus(20)
-	Elementarist.spellPower = GetSpellBonusDamage(4);
-end
-
-function Elementarist.events.ADDON_LOADED(addon)
-	if addon == "OmniCC" then
-		Elementarist.OmniCC = _G['OmniCC']
-	end
-	if addon == "SpellFlash" then
-		Elementarist.SpellFlash = _G['SpellFlashAddon']
-	end
-	if addon ~= "Elementarist" then return end
-	local _,playerClass = UnitClass("player")
-	if playerClass ~= "SHAMAN" then
-		Elementarist.eventFrame:UnregisterEvent("PLAYER_ALIVE")
-		return
-	end
-
-	-- load defaults, if first start
-	Elementarist:InitSettings()
-
-	-- add slash command
-	SlashCmdList["Elementarist"] = Elementarist.Options
-	SLASH_Elementarist1 = "/Elementarist"
-	SLASH_Elementarist2 = "/ele"
-
-	-- check if talent is elemental
-	Elementarist:detectTalent()
-
-	Elementarist.playerLevel = UnitLevel("player")
-
-	-- Setup behaviours
-	Elementarist.Behaviours["1"] = L.BEHAVIOUR_KEEP_FS_UP
-	Elementarist.Behaviours["2"] = L.BEHAVIOUR_FS_BEFORE_LVB
-	Elementarist.CLBehaviours["0"] = L.CLSTBEHAVIOUR_NONE
-	Elementarist.CLBehaviours["1"] = L.CLSTBEHAVIOUR_CL_AFTER_LVB
-	Elementarist.CLBehaviours["2"] = L.CLSTBEHAVIOUR_CL_ON_CD
-
-	-- Create GUI
-	Elementarist:CreateGUI()
-	Elementarist.displayFrame:SetScale(ElementaristDB.scale)
-	Elementarist.OmniCC = _G['OmniCC']
-	Elementarist.SpellFlash = _G['SpellFlashAddon']
-
-	-- Create config page
-	Elementarist:CreateConfig()
-
-	-- Register for Function Events
-	Elementarist.eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
-	Elementarist.eventFrame:RegisterEvent("COMBAT_RATING_UPDATE") -- Monitor the all-mighty haste
-	Elementarist.eventFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
-	Elementarist.eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED") -- Left combat, clean up all enemy GUIDs
-	Elementarist.eventFrame:RegisterEvent("PLAYER_TALENT_UPDATE")
-	Elementarist.eventFrame:RegisterEvent("PARTY_MEMBERS_CHANGED")
-
-	-- get debug frame
-	Elementarist.DebugChat = Elementarist:GetDebugFrame()
-end
-
-function Elementarist:InitSettings()
-	if not ElementaristDB then
-		ElementaristDB = {} -- fresh start
-	end
-	if not ElementaristDB.scale then ElementaristDB.scale = 1 end
-	if not ElementaristDB.debuffscale then ElementaristDB.debuffscale = 1 end
-	if not ElementaristDB.shieldscale then ElementaristDB.shieldscale = 1 end
-	if ElementaristDB.locked == nil then ElementaristDB.locked = false end
-	if ElementaristDB.enabled == nil then ElementaristDB.enabled = true end
-	if ElementaristDB.disableIfNotEle == nil then ElementaristDB.disableIfNotEle = true end
-	if ElementaristDB.debuffdisabled == nil then ElementaristDB.debuffdisabled = false end
-	if ElementaristDB.shielddisabled == nil then ElementaristDB.shielddisabled = false end
-	if ElementaristDB.alpha == nil then ElementaristDB.alpha = 0.8 end
-	if ElementaristDB.debuffalpha == nil then ElementaristDB.debuffalpha = 1 end
-	if ElementaristDB.shieldalpha == nil then ElementaristDB.shieldalpha = 1 end
-	if ElementaristDB.FireNova == nil then ElementaristDB.FireNova = true end
-	if ElementaristDB.Behaviour == nil then ElementaristDB.Behaviour = Elementarist.Behaviours["1"] end
-	if ElementaristDB.CLBehaviour == nil then ElementaristDB.CLBehaviour = Elementarist.CLBehaviours["0"] end
-	if ElementaristDB.EnableUE == nil then ElementaristDB.EnableUE = false end
-	if ElementaristDB.ThreatWarning == nil then ElementaristDB.ThreatWarning = true end
-	if ElementaristDB.EnableEQ == nil then ElementaristDB.EnableEQ = false end
-	if not ElementaristDB.x then ElementaristDB.x = -200 end
-	if not ElementaristDB.y then ElementaristDB.y = -200 end
-	if not ElementaristDB.relativePoint then ElementaristDB.relativePoint = "CENTER" end
-	if not ElementaristDB.debuffx then ElementaristDB.debuffx = -200 end
-	if not ElementaristDB.debuffy then ElementaristDB.debuffy = -100 end
-	if not ElementaristDB.debuffrelativePoint then ElementaristDB.debuffrelativePoint = "CENTER" end
-	if not ElementaristDB.shieldrelativePoint then ElementaristDB.shieldrelativePoint = "CENTER" end
-end
-
-function Elementarist:detectTalent()
-	local _,_,_,_,rest,_ = GetTalentTabInfo(3)
-	local _,_,_,_,enha,_ = GetTalentTabInfo(2)
-	local _,_,_,_,elem,_ = GetTalentTabInfo(1)
-
-	if (elem+rest+enha>0) then
-		Elementarist.isEle = ((elem>=enha) and (elem>=rest))
-	end
-	if (elem + enha + rest == 0) then
-		Elementarist.talentUnsure = true
-	else
-		Elementarist.talentUnsure = false
-	end
-end
-
-function Elementarist:PlayerInParty()
-	if (GetNumRaidMembers()>0) then
-		return 2
-	elseif (GetNumPartyMembers()>0) then
-		return 1
-	else
-		return 0
-	end
-end
-
-function Elementarist:RemoveFromTables(guid)
-	if (Elementarist.person["friend"][guid]) and (Elementarist.person["friend"][guid] ~= 0) then
-		Elementarist.person["friend"][guid] = 0
-		Elementarist.person["friendCount"] = Elementarist.person["friendCount"] - 1
-	end
-	if (Elementarist.person["foe"][guid]) and (Elementarist.person["foe"][guid] ~= 0) then
-		Elementarist.person["foe"][guid] = 0
-		Elementarist.person["foeCount"] = Elementarist.person["foeCount"] - 1
-		Elementarist:Debug('Enemy died:', Elementarist.person["foeCount"] .. " " .. guid)
-	end
-	if (Elementarist.debuffCooldowns[guid]) then
-		table.remove(Elementarist.debuffCooldowns, guid)
-		Elementarist:UpdateDebuffTracker()
-	end
-end
-
-function Elementarist:PurgeDebuffTable()
-	Elementarist.debuffCooldowns = {}
-	Elementarist:UpdateDebuffTracker()
-end
-
-function Elementarist:PurgePersonTable()
-	for i,v in pairs(Elementarist.person["foe"]) do
-		if ( ( GetTime() - Elementarist.person["foe"][i] ) > 3) then
-			-- no activity from that unit in last 2 seconds, remove it
-			if ( Elementarist.person["foe"][i] ~= 0) then
-				Elementarist.person["foe"][i] = 0	-- mark as inactive
-				Elementarist.person["foeCount"] = Elementarist.person["foeCount"] - 1
-				Elementarist:Debug('Enemy removed:', Elementarist.person["foeCount"])
-			end
-		end
-	end
-	for i,v in pairs(Elementarist.person["friend"]) do
-		if ( ( GetTime() - Elementarist.person["friend"][i] ) > 3) then
-			-- no activity from that unit in last 2 seconds, remove it
-			if ( Elementarist.person["friend"][i] ~= 0 ) then
-				Elementarist.person["friend"][i] = 0	-- mark as inactive
-				Elementarist.person["friendCount"] = Elementarist.person["friendCount"] - 1
-				Elementarist:Debug('Friend removed:', Elementarist.person["friendCount"])
-			end
-		end
-	end
-	Elementarist.lastPersonTablePurged = GetTime()
-end
-
-function Elementarist:CountPerson(time, event, sguid, sname, sflags, dguid, dname, dflags)
-	local suffix = event:match(".+(_.-)$")
-	local stype = (tonumber(sguid:sub(5,5), 16)) % 8
-	local dtype = (tonumber(dguid:sub(5,5), 16)) % 8
-	if Elementarist.HostileFilter[suffix] then
-		if (bit.band(dflags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE) and (bit.band(dflags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) and ((dtype==0) or (dtype==3)) then
-			if ((not Elementarist.person["foe"][dguid]) or (Elementarist.person["foe"][dguid]==0)) then
-				Elementarist.person["foeCount"] = Elementarist.person["foeCount"] + 1
-				Elementarist:Debug('Enemy added', Elementarist.person["foeCount"] .. " " .. dguid .. " " .. dflags)
-			end
-			Elementarist.person["foe"][dguid] = GetTime()
-    	elseif (bit.band(sflags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE) and (bit.band(sflags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) and ((stype==0) or (stype==3)) then
-			if ((not Elementarist.person["foe"][sguid]) or (Elementarist.person["foe"][sguid]==0)) then
-				Elementarist.person["foeCount"] = Elementarist.person["foeCount"] + 1
-				Elementarist:Debug('Enemy added', Elementarist.person["foeCount"] .. " " .. sguid)
-			end
-			Elementarist.person["foe"][sguid] = GetTime()
-		end
-		if (bit.band(dflags, COMBATLOG_OBJECT_REACTION_FRIENDLY) == COMBATLOG_OBJECT_REACTION_FRIENDLY) and ((dtype==0) or (dtype==3)) then
-			if ((not Elementarist.person["friend"][dguid]) or (Elementarist.person["friend"][dguid]==0)) then
-				Elementarist.person["friendCount"] = Elementarist.person["friendCount"] + 1
-			end
-			Elementarist.person["friend"][dguid] = GetTime()
-    	elseif (bit.band(sflags, COMBATLOG_OBJECT_REACTION_FRIENDLY) == COMBATLOG_OBJECT_REACTION_FRIENDLY) and ((stype==0) or (stype==3)) then
-			if ((not Elementarist.person["friend"][sguid]) or (Elementarist.person["friend"][sguid]==0)) then
-				Elementarist.person["friendCount"] = Elementarist.person["friendCount"] + 1
-			end
-			Elementarist.person["friend"][sguid] = GetTime()
-		end
-	end
-	if (Elementarist.lastPersonTablePurged < (GetTime() - 3)) and (Elementarist.person["foeCount"]>0) then
-		Elementarist:PurgePersonTable()
-	end
-	--
-	-- Elementarist:Debug('Enemy count:', Elementarist.person["foeCount"])
-	-- Elementarist:Debug('Friend count:', Elementarist.person["friendCount"])
-end
-
-function Elementarist.HighDMGFormat(dmg_amount)
-	if (dmg_amount >= 10000) then
-		return(format('%.1f',dmg_amount/1000) .. "K")
-	else
-		return(format('%.f',dmg_amount))
-	end
-end
-
--- for 4.2:
--- function Elementarist.events.COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, srcGUID, srcName, srcFlags, srcRaidFlags, dstGUID, dstName, dstFlags, dstRaidFlags, spellId, spellName, spellSchool, damage, ...)
-function Elementarist.events.COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellId, spellName, spellSchool, damage, ...)
-	if Elementarist.isEnabled() then
-		if srcName == Elementarist.playerName then
-			if (event=="SPELL_PERIODIC_DAMAGE") and (spellName==Elementarist.SpellList["Flame Shock"]) and (Elementarist.debuffCooldowns[dstGUID]) then
-				Elementarist.debuffCooldowns[dstGUID]["action"] = GetTime()
-			end
-			if (event=="SPELL_CAST_START") then
-				Elementarist.SFHistory.spell = nil
-				Elementarist.SFHistory.misc = nil
-				Elementarist.SFHistory.int = nil
-			end
-			Elementarist:DecideSpells()
-			-- calculate DPS
-			if (event=="SPELL_CAST_SUCCESS") then
-				Elementarist.lastSpell = spellName
-			end
-			if ((event=="SPELL_DAMAGE") or (event=="SPELL_PERIODIC_DAMAGE")) then
-				if (not Elementarist.DPSTable[dstGUID]) then
-					Elementarist.DPSTable[dstGUID] = {
-						["time"] = GetTime(),
-						["amount"] = 0,
-					}
-				end
-
-				Elementarist.DPSTable[dstGUID]["amount"] = Elementarist.DPSTable[dstGUID]["amount"] + damage
-				local dps_txt = ""
-				if (dstGUID == Elementarist.targetGUID) and (Elementarist.DPSTable[Elementarist.targetGUID]) then
-					local dps_sec = GetTime() - Elementarist.DPSTable[dstGUID]["time"]
-					if (dps_sec > 5) then
-						dps_txt = format('%.f',(Elementarist.DPSTable[dstGUID]["amount"] / dps_sec))
-					end
-					local threat_txt = ""
-					local _, status, threatpct, _, _ = UnitDetailedThreatSituation("player", "target")
-					if (status) then
-						if (threatpct<80) then
-							threat_txt = format("%.f",threatpct) .. " %"
-							Elementarist.cooldownFrame:SetReverse(false)
-							if (ElementaristDB.ThreatWarning) and (Elementarist.inParty>0) and (threatpct>70) then
-								RaidNotice_AddMessage(RaidBossEmoteFrame, L.THREAT_WARNING_PREFIX .. format("%.f",threatpct) .. L.THREAT_WARNING_SUFFIX, ChatTypeInfo["RAID_WARNING"])
-							end
-						else
-							threat_txt = "|cffff0000" .. format("%.f",threatpct) .. " %|r"
-							if (ElementaristDB.ThreatWarning) and (Elementarist.inParty>0) then
-								RaidNotice_AddMessage(RaidBossEmoteFrame, "|cffff0000" .. L.THREAT_WARNING_PREFIX .. format("%.f",threatpct) ..  L.THREAT_WARNING_SUFFIX .. "|r", ChatTypeInfo["RAID_WARNING"])
-							end
-							Elementarist.cooldownFrame:SetReverse((Elementarist.person["friendCount"]>1) and (Elementarist.inParty>0))
-						end
-					end
-					dps_txt = dps_txt .. "|n" .. threat_txt
-					Elementarist.textList["dps"]:SetText(dps_txt)
-				end
-			end
-		else
-			-- if unit died, remove if from friend and foe tables
-			if (event=="UNIT_DIED") or (event=="UNIT_DESTROYED") then
-				Elementarist:RemoveFromTables(dstGUID);
-			end
-			-- count enemies if player in combat
-			if (UnitAffectingCombat("player")) then
-				-- enemy count for CL advise and multiple player in combat (for aggro warning)
-				Elementarist:CountPerson(timestamp, event, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags)
-			end
-		end
-	end
-end
-
-function Elementarist.events.COMBAT_RATING_UPDATE(unit)
-	if unit == "player" then
-    	Elementarist.spellHaste = GetCombatRatingBonus(20) -- update spell haste
-		Elementarist.spellPower = GetSpellBonusDamage(4);
-	end
-end
-
-function Elementarist.events.PLAYER_TARGET_CHANGED(...)
-	Elementarist.targetGUID = UnitGUID("target")
-	Elementarist.inParty = Elementarist:PlayerInParty()
-
-	if (ElementaristDB.disableIfNotEle) and (not Elementarist:isEnabled()) then
-		Elementarist:detectTalent()
-		if Elementarist:isEnabled() then
-			Elementarist:ApplySettings()
-		end
-	end
-	if (not Elementarist.targetGUID) then
-		local threat_txt = ""
-		local _, status, threatpct, _, _ = UnitDetailedThreatSituation("player", "target")
-		if (status) then
-			if (threatpct<80) then
-				threat_txt = format("%.f",threatpct) .. " %"
-				Elementarist.cooldownFrame:SetReverse(false)
-			else
-				threat_txt = "|cffff0000" .. format("%.f",threatpct) .. " %|r"
-				Elementarist.cooldownFrame:SetReverse((Elementarist.person["friendCount"]>1) and (Elementarist.inParty>0))
-			end
-		end
-		Elementarist.textList["dps"]:SetText(threat_txt)
-	end
-	Elementarist:DecideSpells()
-end
-
-function Elementarist.events.PLAYER_REGEN_ENABLED(...)
-	-- left combat
-	Elementarist.person["friend"] = {}
-	Elementarist.person["friendCount"] = 0
-	Elementarist.person["foe"] = {}
-	Elementarist.person["foeCount"] = 0
-	Elementarist.DPSTable = {}
-	Elementarist.textList["dps"]:SetText("")
-	Elementarist.textList["debuff"]:SetText("")
-	Elementarist.cooldownFrame:SetReverse(false)
-	Elementarist:PurgePersonTable()
-	Elementarist:PurgeDebuffTable()
-end
-
-function Elementarist:isEnabled()
-	if (Elementarist.talentUnsure) then
-		Elementarist:detectTalent()
-	end
-	return (
-		ElementaristDB.enabled and (
-			(not ElementaristDB.disableIfNotEle) or (Elementarist.isEle)
-		)
-	)
-end
-
-function Elementarist:UpdateShieldTracker()
-	local name, _, icon, count, _, d, e = Elementarist:hasBuff("player",Elementarist.SpellList["Lightning Shield"])
-
-	Elementarist.shieldTrackerUpdate = GetTime()
-	if (name) then
-		Elementarist.textureList["shield"]:SetTexture(icon)
-		Elementarist.textList["shield"]:SetText(format('%.0f', count))
-		Elementarist.shieldCooldownFrame:SetCooldown( e-d, d)
-	else
-		Elementarist.textureList["shield"]:SetTexture("")
-		Elementarist.textList["shield"]:SetText("")
-		Elementarist.shieldCooldownFrame:SetCooldown(0, 0)
-	end
-end
-
-function Elementarist:UpdateDebuffTracker()
-	local name, _, icon, _, _, d, e = Elementarist:hasDeBuff("target",Elementarist.SpellList["Flame Shock"],"player")
-	local tguid = UnitGUID("target")
-
-	Elementarist.debuffTrackerUpdate = GetTime()
-	if (name) then
-		if (tguid) and (not Elementarist.debuffCooldowns[tguid]) then
-			Elementarist.debuffCooldowns[tguid] = {}
-		end
-		Elementarist.debuffCooldowns[tguid]["start"] = e-d
-		Elementarist.debuffCooldowns[tguid]["duration"] = d
-		Elementarist.debuffCooldowns[tguid]["action"] = GetTime()
-	else
-		_, _, icon = GetSpellInfo(Elementarist.SpellList["Flame Shock"])
-	end
-
-	-- update mini frames
-	local m = 1
-	for i,v in pairs(Elementarist.debuffCooldowns) do
-		if ( (v["start"] + v["duration"]) > GetTime() ) and (i ~= tguid) and (m <= 4) and (v["action"]>GetTime() - 4) then
-			Elementarist.textureList["debuff_" .. tostring(m)]:SetTexture(icon)
-			Elementarist.debuffCooldownFrame["mini_" .. tostring(m)]:SetCooldown( v["start"], v["duration"])
-			m = m + 1
-		end
-	end
-	for i=m,4,1 do
-		Elementarist.textureList["debuff_" .. tostring(m)]:SetTexture("")
-		Elementarist.debuffCooldownFrame["mini_" .. tostring(m)]:SetCooldown( 0, 0)
-	end
-
-	-- update main frame
-	if (name) then
-		Elementarist.textureList["debuff"]:SetTexture(icon)
-		if (not Elementarist.OmniCC) then
-			Elementarist.textList["debuff"]:SetText(format('%.1f', (e - GetTime())))
-		end
-		Elementarist.debuffCooldownFrame["main"]:SetCooldown( e-d, d)
-	else
-		Elementarist.textureList["debuff"]:SetTexture("")
-		Elementarist.textList["debuff"]:SetText("")
-		Elementarist.debuffCooldownFrame["main"]:SetCooldown(0, 0)
-	end
-end
-
-function Elementarist:GetSpellCooldownRemaining(spell)
-	local s, d, _ = GetSpellCooldown(spell)
-	if (d) and (d>0) then
-		d = s - GetTime() + d
-	end
-
-	return d
-end
-
-function Elementarist:hasDeBuff(unit, spellName, casterUnit)
-	local i = 1;
-	while true do
-		local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitDebuff(unit, i);
-		if not name then
-			break;
-		end
-		if (name) and (spellName) then
-			if string.match(name, spellName) and ((unitCaster == casterUnit) or (casterUnit == nil)) then
-				return name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable;
-			end
-		end
-		i = i + 1;
-	end
-end
-
-function Elementarist:hasBuff(unit, spellName, stealableOnly, getByID)
-	local i = 1;
-	while true do
-		local name, rank, icon, count, buffType, duration, expirationTime, source, isStealable, _, spellId = UnitBuff(unit, i);
-		if not name then
-			break;
-		end
-		if (not getByID) and (name) and (spellName) then
-			if string.match(name, spellName) then
-				if (not stealableOnly) or (isStealable) then
-					return name, rank, icon, count, buffType, duration, expirationTime, unitCaster, isStealable;
-				end
-			end
-		else
-			if (getByID == spellId) then
-				return name, rank, icon, count, buffType, duration, expirationTime, unitCaster, isStealable;
-			end
-		end
-		i = i + 1;
-	end
-end
-
-function Elementarist:hasTotem(unit, spellName)
-	local i = 1;
-	while true do
-		local name, rank, icon, count, buffType, duration, expirationTime, source, isStealable = UnitBuff(unit, i);
-		if not name then
-			break;
-		end
-		if (string.match(name, spellName) or (string.match(icon, spellName))) and (expirationTime==0) then
-	   		return name, rank, icon, count, buffType, duration, expirationTime, unitCaster, isStealable;
-		end
-		i = i + 1;
-	end
-end
-
-function Elementarist:SpellAvailable(spell)
-	if (not spell) then
-		return false
-	end
-	if (IsUsableSpell(spell)) then
-		return true
-	else
-		return false
-	end
-end
-
-function Elementarist:NextSpell(timeshift,exspell1,exspell2)
-	local guid = UnitGUID("target")
-	local currentTime = GetTime()
-	local s,d,e
-	local name, fsExpiration, unitCaster
-	local lastSpell
-
-	if (exspell1) then
-		if (exspell2) then
-			lastSpell = exspell2
-		else
-			lastSpell = exspell1
-		end
-	else
-		lastSpell = Elementarist.lastSpell
-	end
-
-	Elementarist.lastBaseGCD = 1.5 - (1.5 * Elementarist.spellHaste * .01)
-
-	local flameshockavail = false
-	local LvBct = 2 - (2 * Elementarist.spellHaste * .01)
-
-	-- check Shock CD
-	local s, d = GetSpellCooldown(Elementarist.SpellList["Flame Shock"])
-	if (d) and (d>0) then
-		Elementarist.lastShockCD = d
-	end
-	local s, d = GetSpellCooldown(Elementarist.SpellList["Earth Shock"])
-	if (d) and (d>0) then
-		Elementarist.lastShockCD = d
-	end
-
-	-- if target is dead, return ""
-	if (UnitHealth("target")<=0) then
-		return ""
-	end
-
-	if (not timeshift) then
-		timeshift = 0
-	end
-
-	-- check current spell
-	local spellInCast, _, _, _, sICstartTime, sICendTime = UnitCastingInfo("player")
-	if (sepllInCast) then
-		if ( (sICendTime - sICstartTime) / 1000 ) < Elementarist.lastBaseGCD then
-			sICendTime = sICstartTime + (Elementarist.lastBaseGCD * 1000)
-		end
-		timeshift = timeshift + (sICendTime / 1000) - GetTime()
-	else
-		-- no spell in cast, check global cd via Flametongue Weapon
-		if (Elementarist.SpellList["Flametongue Weapon"]) then
-			local ftcd = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Flametongue Weapon"])
-			if (ftcd) then
-				timeshift = timeshift + Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Flametongue Weapon"])
-			else
-				timeshift = timeshift + Elementarist.lastBaseGCD
-			end
-		else
-			timeshift = timeshift + Elementarist.lastBaseGCD
-		end
-	end
-
-	-- check if Flame shock applied on target first
-	name, _, _, _, _, _, fsExpiration, unitCaster = Elementarist:hasDeBuff("target", Elementarist.SpellList["Flame Shock"], "player");
-	if (exspell1 ~= Elementarist.SpellList["Flame Shock"]) and (exspell2 ~= Elementarist.SpellList["Flame Shock"]) then
-		if IsSpellInRange(Elementarist.SpellList["Flame Shock"], "target") == 1 then
-			if (not fsExpiration) then
-				fsExpiration = 0
-			end
-			d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Flame Shock"])
-			if ((d - timeshift) <= 0) then
-				flameshockavail = true
-				local doFS = false
-				if (unitCaster ~= "player") then	-- fs debuff is not casted by the player
-					name = false
-					fsExpiration = 0
-				end
-				if (not name) then 	-- no fs debuff on target
-					fsExpiration = 0
-				end
-				if (ElementaristDB.Behaviour == Elementarist.Behaviours["1"]) then
-					doFS = true
-				else	-- if fs before lvb, check lvb cd
-					d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Lava Burst"])
-					if (d <= (timeshift + Elementarist.lastBaseGCD)) then
-						doFS = true
-					end
-				end
-				if (doFS) and ((fsExpiration - GetTime() - timeshift) < 0) then
-					return Elementarist.SpellList["Flame Shock"]
-				end
-			end
-		end
-	end
-
-	-- Unleash Elements if LvB will be available after it, and target has FS debuff, and it will not expire before UE, and no LvB cast before UE
-	-- Weapon enchant has to be Flamtounge Weapon, and Unleash Elements are not on CD
-	if (ElementaristDB.EnableUE) then
-		if (exspell1 ~= Elementarist.SpellList["Unleash Elements"]) and (exspell2 ~= Elementarist.SpellList["Unleash Elements"]) then
-			if (
-				(IsSpellInRange(Elementarist.SpellList["Unleash Elements"], "target") == 1) and
-				(
-					( (Elementarist.SpellList["Lava Burst"]) ~= spellInCast) and
-					( (Elementarist.SpellList["Lava Burst"]) ~= exspell1) and
-					( (Elementarist.SpellList["Lava Burst"]) ~= exspell2)
-				) and
-				(
-					(exspell1 == Elementarist.SpellList["Flame Shock"] ) or
-					(exspell2 == Elementarist.SpellList["Flame Shock"] ) or
-					(fsExpiration > timeshift + (2 * Elementarist.lastBaseGCD ) )
-				)
-			) then
-				local hasMainHandEnchant, _, _, _, _, _ = GetWeaponEnchantInfo()
-				if (hasMainHandEnchant) then
-					d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Lava Burst"])
-					e = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Unleash Elements"])
-					if (d <= (timeshift + Elementarist.lastBaseGCD)) and ((e-timeshift) <= 0) then
-						return Elementarist.SpellList["Unleash Elements"]
-					end
-				end
-			end
-		end
-	end
-
-	if (not fsExpiration) then
-		fsExpiration = 0
-	end
-	if (exspell1 ~= Elementarist.SpellList["Lava Burst"]) and (exspell2 ~= Elementarist.SpellList["Lava Burst"]) then
-		if (IsSpellInRange(Elementarist.SpellList["Lava Burst"], "target") == 1) and
-		(
-			((fsExpiration~=0) and ((fsExpiration-GetTime()-timeshift) > LvBct)) or
-			(exspell1 == Elementarist.SpellList["Flame Shock"]) or
-			(exspell2 == Elementarist.SpellList["Flame Shock"])
-		) then
-			if ((Elementarist.SpellList["Lava Burst"]) ~= spellInCast) then
-				d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Lava Burst"])
-				if ((d-timeshift) <= 0) then
-					return Elementarist.SpellList["Lava Burst"]
-				end
-			end
-		end
-	end
-
-	-- if >=4 foes are available, and Earthquake not on cd
-	if (ElementaristDB.EnableEQ) then
-		if (exspell1 ~= Elementarist.SpellList["Earthquake"]) and (exspell2 ~= Elementarist.SpellList["Earthquake"]) then
-			if (Elementarist.person["foeCount"]>=4) then
-				d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Earthquake"])
-				if ((d-timeshift) <= 0) then
-					return Elementarist.SpellList["Earthquake"]
-				end
-			end
-		end
-	end
-
-	-- if >=4 foes are available, and Fire Nova enabled in settings, and not in cd (and has Flame Shock applied on target)
-	if (exspell1 ~= Elementarist.SpellList["Fire Nova"]) and (exspell2 ~= Elementarist.SpellList["Fire Nova"]) then
-		if (ElementaristDB.FireNova) and (Elementarist.person["foeCount"]>=4) then
-			-- is Flame Shock on target
-			local f = Elementarist:hasDeBuff("target",Elementarist.SpellList["Flame Shock"],"player")
-			if f then
-	            d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Fire Nova"])
-				if ((d-timeshift) <= 0) then
-					return Elementarist.SpellList["Fire Nova"]
-				end
-			end
-		end
-	end
-
-	-- Earth shock if Lightning Shield count >=9 and not on cd or FS debuff remaining between FS and FS cd + 2sec and LS count>=7
-	if ( (exspell1 ~= Elementarist.SpellList["Earth Shock"]) and (exspell2 ~= Elementarist.SpellList["Earth Shock"]) ) then
-		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Earth Shock"])
-		local _, _, _, lscount = Elementarist:hasBuff("player",Elementarist.SpellList["Lightning Shield"])
-		if (
-				( (d) and ((d-timeshift) <= 0) and (lscount) ) and (
-					(lscount>=9) or
-					( (lscount>=7) and
-						( (fsExpiration - GetTime() - timeshift) > Elementarist.lastShockCD ) and
-						( (fsExpiration - GetTime() - timeshift) < Elementarist.lastShockCD + 2 )
-					)
-				)
-			) then
-			return Elementarist.SpellList["Earth Shock"]
-		end
-	end
-
-	-- CL if there are multiple targets, (count in a dirty way from combat log, not to accurate!!!)
-	if (exspell1 ~= Elementarist.SpellList["Chain Lightning"]) and (exspell2 ~= Elementarist.SpellList["Chain Lightning"]) then
-		if (Elementarist.person["foeCount"]>2) then
-			if IsSpellInRange(Elementarist.SpellList["Chain Lightning"], "target") == 1 then
-				if ((Elementarist.SpellList["Chain Lightning"]) ~= spellInCast) then
-					d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Chain Lightning"])
-					if ((d-timeshift) <= 0) then
-						return Elementarist.SpellList["Chain Lightning"]
-					end
-				end
-			end
-		end
-	end
-
-	-- otherwise lightning bolt
-	if IsSpellInRange(Elementarist.SpellList["Lightning Bolt"], "target") == 1 then
-		return Elementarist.SpellList["Lightning Bolt"]
-	end
-
-	-- if nothing works, try flameshock again
-	if flameshockavail then
-		return Elementarist.SpellList["Flame Shock"]
-	end
-
-	return ""
-end
-
-function Elementarist:MiscSpell()
-	-- Miscelaneous spell order:
-	-- Flametongoue weapon
-	-- Lightning Shield
-	-- Searing Totem
-	-- Totem of Wrath
-	-- Wrath of Air totem
-	-- Elemental Mastery
-	-- Berserking troll racial (if available)
-	-- Blood Fury orc racial
-	-- Lifeblood Herbalism spell
-
-	local d, e
-	local name, expirationTime
-
-	-- Alchemy Flask of Enhancement
-	if GetItemCount(Elementarist.CustomIDs["Flask of Enhancement Item"]) ~= 0 then
-		name = Elementarist:hasBuff("player", Elementarist.SpellList["Flask of the Draconic Mind"]);
-		if (name == nil) then
-			name, _, _, _, _, _, expirationTime = Elementarist:hasBuff("player", Elementarist.SpellList["Flask of Enhancement"], false, Elementarist.CustomIDs["Flask of Enhancement Spell"]);
-			if (name == nil) or (expirationTime < 2) then
-				if (icon == nil) then
-					icon = GetItemIcon(Elementarist.CustomIDs["Flask of Enhancement Item"])
-				end
-				return nil,icon
-			end
-		end
-	end
-
-	-- Flametongue weapon
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Flametongue Weapon"]) then
-		local hasMainHandEnchant, mainHandExpiration, _, _, _, _ = GetWeaponEnchantInfo()
-		if (hasMainHandEnchant == nil) or ((mainHandExpiration / 60000) < 1) then
-			return Elementarist.SpellList["Flametongue Weapon"]
-		end
-	end
-
-	-- Lightning Shield
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Lightning Shield"]) then
-		name, _, _, _, _, _, expirationTime = Elementarist:hasBuff("player", Elementarist.SpellList["Lightning Shield"]);
-		if (name == nil) or (expirationTime < 1) then
-			return Elementarist.SpellList["Lightning Shield"]
-		end
-	end
-
-	-- Searing Totem
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Searing Totem"]) then
-		local haveFireTotem,fireTotemName,_,_ = GetTotemInfo(1)
-		if (fireTotemName == "") then
-			-- no fire totem
-			return Elementarist.SpellList["Searing Totem"]
-		end
-	end
-
-	-- Wrath of Air totem
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Wrath of Air Totem"]) then
-		if (
-			(Elementarist:hasTotem("player", Elementarist.SpellList["Wrath of Air Totem"]) == nil) and
-			(Elementarist:hasBuff("player", GetSpellInfo(Elementarist.CustomIDs["Moonkin Aura"]), false, Elementarist.CustomIDs["Moonkin Aura"]) == nil) and
-			(Elementarist:hasBuff("player", GetSpellInfo(Elementarist.CustomIDs["Mind Quickening"]), false, Elementarist.CustomIDs["Mind Quickening"]) == nil)
-		) then
-			return Elementarist.SpellList["Wrath of Air Totem"]
-		end
-	end
-
-	-- Elemental Mastery
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Elemental Mastery"]) then
-		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Elemental Mastery"])
-		if d <= 0.5 then
-			return Elementarist.SpellList["Elemental Mastery"]
-		end
-	end
-
-	-- Berserking
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Berserking"]) then
-		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Berserking"])
-		if d <= 0.5 then
-			return Elementarist.SpellList["Berserking"]
-		end
-	end
-
-	-- Blood Fury
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Blood Fury"]) then
-		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Blood Fury"])
-		if d <= 0.5 then
-			return Elementarist.SpellList["Blood Fury"]
-		end
-	end
-
-	-- Lifeblood
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Lifeblood"]) then
-		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Lifeblood"])
-		if d <= 0.5 then
-			return Elementarist.SpellList["Lifeblood"]
-		end
-	end
-
-	return ""
-
-end
-
-function Elementarist:IntSpell()
-	-- interruptions, mana recharge wia thunderstorm, and purge on target
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Wind Shear"]) then
-		if IsSpellInRange(Elementarist.SpellList["Wind Shear"], "target") == 1 then
-			local _, status, threatpct, _, _ = UnitDetailedThreatSituation("player", "target")
-			if ((UnitCastingInfo("target")) or (UnitChannelInfo("target"))) or ((status) and (threatpct>80) and (Elementarist.person["friendCount"]>1) and (Elementarist.inParty>0)) then
-				local d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Wind Shear"])
-				if (d) and (d<0.5) and (IsSpellInRange(Elementarist.SpellList["Wind Shear"], "target") ) then
-					return Elementarist.SpellList["Wind Shear"]
-				end
-			end
-
-			if (UnitChannelInfo("target")) then
-				local d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Wind Shear"])
-				if (d<0.5) and (interruptable) and (IsSpellInRange(Elementarist.SpellList["Wind Shear"], "target") ) then
-					return Elementarist.SpellList["Wind Shear"]
-				end
-			end
-		end
-	end
-
-	-- check if mana is below 70% and Thunderstorm available
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Thunderstorm"]) then
-		local d = GetSpellCooldown(Elementarist.SpellList["Thunderstorm"])
-		if (d) and ((UnitPower("player",0) / UnitPowerMax("player",0)) < 0.7) and (d < 0.5) then
-			return Elementarist.SpellList["Thunderstorm"]
-		end
-	end
-
-	-- check if purgeable buff is on target (not sure if this is ok)
-	if Elementarist:SpellAvailable(Elementarist.SpellList["Purge"]) then
-		if IsSpellInRange(Elementarist.SpellList["Purge"], "target") == 1 then
-			if (Elementarist:hasBuff("target", ".", 1)) then
-				local d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Purge"])
-				if (d<0.5) then
-					return Elementarist.SpellList["Purge"]
-				end
-			end
-		end
-	end
-
-	return ""
-end
-
-function Elementarist:FlashSpell(spell,spelltype)
-	local color = "White"
-	if (Elementarist.SpellFlash) and (Elementarist.SFHistory[spelltype] ~= spell) and (Elementarist.SpellFlash.Flashable(spell)) then
-		if (spelltype == "int") then
-			color = "Aqua"
-		end
-		if (spelltype == "misc") then
-			color = "Green"
-		end
-		Elementarist.SpellFlash.Flash(spell,color)
-		Elementarist.SFHistory.spell=spell
-	end
-end
-
-function Elementarist:DecideSpells()
-
-	Elementarist.timeSinceLastUpdate = 0;
-	local currentTime = GetTime()
-
-	local guid = UnitGUID("target")
-	local guid = UnitGUID("target")
-	if  UnitName("target") == nil or UnitIsFriend("player","target") ~= nil or UnitHealth("target") == 0 then
-		guid = nil
-	end
-
-	if UnitInVehicle("player") then
-		-- player is in a "vehicle" don't suggest spell
-		Elementarist.textureList["next"]:SetTexture("")
-		Elementarist.textureList["next1"]:SetTexture("")
-		Elementarist.textureList["next2"]:SetTexture("")
-		Elementarist.textureList["misc"]:SetTexture("")
-		Elementarist.textureList["int"]:SetTexture("")
-
-		return
-	end
-
-	if guid == nil then
-		Elementarist.textureList["next"]:SetTexture("")
-		Elementarist.textureList["next1"]:SetTexture("")
-		Elementarist.textureList["next2"]:SetTexture("")
-		Elementarist.textureList["misc"]:SetTexture("")
-		Elementarist.textureList["int"]:SetTexture("")
-
-		return
-	end
-  	if (UnitHealth("target") == 0) then
-		Elementarist.textureList["next"]:SetTexture("")
-		Elementarist.textureList["next1"]:SetTexture("")
-		Elementarist.textureList["next2"]:SetTexture("")
-
-		return
-  	end
-
-	local spell = ""
-	spell = Elementarist:NextSpell()
-	Elementarist:FlashSpell(spell,"spell")
-	local d = Elementarist:GetSpellCooldownRemaining(spell)
-	if (d) and (d>0) then
-		local cdStart = currentTime - Elementarist.lastBaseGCD + d  -- should be less then the base gcd if we are suggesting it
-		if (cdStart) and (Elementarist.lastBaseGCD) then
-			Elementarist.cooldownFrame:SetCooldown(cdStart, Elementarist.lastBaseGCD)
-		end
-	end
-	Elementarist.textureList["next"]:SetTexture(GetSpellTexture(spell))
-
-	local _,_,_,_,_,_,ct1=GetSpellInfo(spell)
-	if (not ct1) then
-		ct1 = 0
-	else
-		ct1 = (ct1 / 1000)
-	end
-	local spell1 = Elementarist:NextSpell(ct1,spell)
-	Elementarist.textureList["next1"]:SetTexture(GetSpellTexture(spell1))
-
-	local _,_,_,_,_,_,ct2=GetSpellInfo(spell1)
-	if (not ct2) then
-		ct2 = 0
-	else
-		ct2 = (ct2 / 1000)
-	end
-	if (not ct2) or (ct2 < Elementarist.lastBaseGCD) then
-		ct2 = Elementarist.lastBaseGCD
-	end
-	local spell2 = Elementarist:NextSpell(ct1+ct2,spell,spell1)
-	Elementarist.textureList["next2"]:SetTexture(GetSpellTexture(spell2))
-
-	local icon
-
-	spell,icon = Elementarist:MiscSpell()
-	Elementarist:FlashSpell(spell,"misc")
-
-	if (icon) then
-		Elementarist.textureList["misc"]:SetTexture(icon)
-	else
-		if (spell) then
-			Elementarist.textureList["misc"]:SetTexture(GetSpellTexture(spell))
-		end
-	end
-
-	spell = Elementarist:IntSpell()
-	Elementarist:FlashSpell(spell,"int")
-	Elementarist.textureList["int"]:SetTexture(GetSpellTexture(spell))
-
-
-end
-
-function Elementarist:OnUpdate(elapsed)
-	if (Elementarist:isEnabled()) then
-		Elementarist.timeSinceLastUpdate = Elementarist.timeSinceLastUpdate + elapsed
-
-		if (Elementarist.timeSinceLastUpdate > (1.5 - (1.5 * Elementarist.spellHaste * .01)) * 0.3) then
-			Elementarist:DecideSpells()
-		end
-		if (not ElementaristDB.debuffdisabled) then
-			Elementarist.debuffTrackerUpdate = Elementarist.debuffTrackerUpdate + elapsed
-			if (
-				((Elementarist.OmniCC) and (Elementarist.debuffTrackerUpdate >= 1)) or
-				((not Elementarist.OmniCC) and (Elementarist.debuffTrackerUpdate >= 1))
-			) then
-				Elementarist:UpdateDebuffTracker()
-			end
-		end
-		if (not ElementaristDB.shielddisabled) then
-			Elementarist.shieldTrackerUpdate = Elementarist.shieldTrackerUpdate + elapsed
-			if (
-				((Elementarist.OmniCC) and (Elementarist.shieldTrackerUpdate >= 1)) or
-				((not Elementarist.OmniCC) and (Elementarist.shieldTrackerUpdate >= 1))
-			) then
-				Elementarist:UpdateShieldTracker()
-			end
-		end
-	end
-end
+-------------------------------------------------------------------------------
+-- Elementarist 2.0.2
+--
+-- Shows the advised spell for an elemental shaman for optimal DPS output.
+-------------------------------------------------------------------------------
+
+Elementarist = {Locals = {}}
+
+local L = Elementarist.Locals
+
+Elementarist.versionNumber = '2.0.2'
+Elementarist.playerName = UnitName("player")
+Elementarist.playerGUID = UnitGUID("player")
+Elementarist.targetGUID = nil
+Elementarist.spellHaste = GetCombatRatingBonus(20)
+Elementarist.timeSinceLastUpdate = 0
+Elementarist.debuffTrackerUpdate = 0
+Elementarist.shieldTrackerUpdate = 0
+Elementarist.spellPower = GetSpellBonusDamage(4);	-- nature spell bonus
+Elementarist.lastBaseGCD = 1.5
+Elementarist.lastShockCD = 5
+Elementarist.person = {
+	["foeCount"]	= 0,
+	["friendCount"]	= 0,
+	["friend"]  = {},
+	["foe"]		= {}
+}
+Elementarist.debuffCooldowns = {
+}
+Elementarist.lastPersonTablePurged = 0.0;
+Elementarist.configPanel = nil
+Elementarist.prevDB = {}
+Elementarist.DPSTable = {}
+Elementarist.DebugMode = false
+Elementarist.DebugChat = DEFAULT_CHAT_FRAME
+Elementarist.inParty = 0
+Elementarist.OmniCC = _G['OmniCC']
+Elementarist.SpellFlash = _G['SpellFlashAddon']
+Elementarist.SFHistory = {
+	["spell"] = nil,
+	["misc"] = nil,
+	["int"] = nil
+}
+Elementarist.isEle = false
+Elementarist.talentUnsure = true
+Elementarist.lastSpell = nil
+Elementarist.CustomIDs = {
+	["Flask of Enhancement Item"] = 58149,
+	["Flask of Enhancement Spell"] = 79640,
+	["Moonkin Aura"] = 24907,
+	["Mind Quickening"] = 49868
+}
+Elementarist.SpellList = {
+	["Flame Shock"] = GetSpellInfo(8050),
+	["Lightning Bolt"] = GetSpellInfo(403),
+	["Lava Burst"] = GetSpellInfo(51505),
+	["Chain Lightning"] = GetSpellInfo(421),
+	["Thunderstorm"] = GetSpellInfo(59159),
+	["Purge"]	= GetSpellInfo(8012),
+	["Wind Shear"] = GetSpellInfo(57994),
+	["Water Shield"] = GetSpellInfo(52127),
+	["Flametongue Weapon"] = GetSpellInfo(8024),
+	["Wrath of Air Totem"] = GetSpellInfo(3738),
+	["Mana Spring Totem"] = GetSpellInfo(567),
+	["Elemental Mastery"] = GetSpellInfo(16166),
+	["Fire Nova"] = GetSpellInfo(1535),
+	["Earth Shock"] = GetSpellInfo(8042),
+	["Searing Totem"] = GetSpellInfo(3599),
+	["Lightning Shield"] = GetSpellInfo(324),
+	["Unleash Elements"] = GetSpellInfo(73680),
+	["Earthquake"] = GetSpellInfo(61882),
+
+	-- racials
+	["Berserking"] = GetSpellInfo(26297),	-- Troll racial
+	["Blood Fury"] = GetSpellInfo(33697),	-- Orc racial
+
+	-- debuffs
+	["Totem of Wrath Debuff"] = GetSpellInfo(30708),
+	["Heart of the Crusader"] = GetSpellInfo(54499),
+
+	-- other buffs
+	["Demonic Pact"] = GetSpellInfo(48090),
+	["Flask of Enhancement"] = GetSpellInfo(Elementarist.CustomIDs["Flask of Enhancement Spell"]),
+	["Flask of the Draconic Mind"] = GetSpellInfo(79470),
+	["Lifeblood"] = GetSpellInfo(55503)
+}
+Elementarist.debuffCooldownFrame = {
+	["main"] = nil,
+	["mini_1"] = nil,
+	["mini_2"] = nil,
+	["mini_3"] = nil,
+	["mini_4"] = nil
+}
+Elementarist.textureList = {
+	["next"] = nil,
+	["next1"] = nil,
+	["next2"] = nil,
+	["misc"] = nil,
+	["int"] = nil,
+	["debuff"] = nil,
+	["debuff_1"] = nil,
+	["debuff_2"] = nil,
+	["debuff_3"] = nil,
+	["debuff_4"] = nil,
+	["shield"] = nil
+}
+
+Elementarist.textList = {
+	["dps"] = nil,
+	["debuff"] = nil,
+	["shield"] = nil
+}
+Elementarist.Behaviours = {
+}
+Elementarist.CLBehaviours = {
+}
+Elementarist.HostileFilter = {
+  ["_DAMAGE"] = true,
+  ["_LEECH"] = true,
+  ["_DRAIN"] = true,
+  ["_STOLEN"] = true,
+  ["_INSTAKILL"] = true,
+  ["_INTERRUPT"] = true,
+  ["_MISSED"] = true
+}
+
+-- Our sneaky frame to watch for events ... checks Elementarist.events[] for the function.  Passes all args.
+Elementarist.eventFrame = CreateFrame("Frame")
+Elementarist.eventFrame:SetScript("OnEvent", function(this, event, ...)
+  Elementarist.events[event](...)
+end)
+
+Elementarist.eventFrame:RegisterEvent("ADDON_LOADED")
+Elementarist.eventFrame:RegisterEvent("PLAYER_LOGIN")
+Elementarist.eventFrame:RegisterEvent("PLAYER_ALIVE")
+
+-- Define our Event Handlers here
+Elementarist.events = {}
+
+function Elementarist:Debug(statictxt,msg)
+	if (Elementarist.DebugMode) and (Elementarist.DebugChat) then
+		if (msg) then
+			Elementarist.DebugChat:AddMessage( statictxt  .. " : " .. msg)
+		else
+			Elementarist.DebugChat:AddMessage( statictxt  .. " : " .. "<nil>")
+		end
+	end
+end
+
+function Elementarist:GetDebugFrame()
+	for i=1,NUM_CHAT_WINDOWS do
+		local windowName = GetChatWindowInfo(i);
+		if windowName == "EleDBG" then
+			return getglobal("ChatFrame" .. i)
+		end
+	end
+	return DEFAULT_CHAT_FRAME
+end
+
+function Elementarist.events.PLAYER_TALENT_UPDATE()
+	Elementarist:detectTalent()
+
+	Elementarist:ApplySettings()
+end
+
+function Elementarist.events.PARTY_MEMBERS_CHANGED()
+	Elementarist.inParty = Elementarist:PlayerInParty()
+end
+
+function Elementarist.events.PLAYER_ALIVE()
+	-- check anything
+	Elementarist:detectTalent()
+	Elementarist:ApplySettings()
+
+	-- Elementarist.eventFrame:UnregisterEvent("PLAYER_ALIVE")
+end
+
+function Elementarist.events.PLAYER_ENTERING_WORLD()
+	Elementarist:detectTalent()
+end
+
+function Elementarist.events.PLAYER_LOGIN()
+	Elementarist.playerName = UnitName("player");
+
+	Elementarist.spellHaste = GetCombatRatingBonus(20)
+	Elementarist.spellPower = GetSpellBonusDamage(4);
+end
+
+function Elementarist.events.ADDON_LOADED(addon)
+	if addon == "OmniCC" then
+		Elementarist.OmniCC = _G['OmniCC']
+	end
+	if addon == "SpellFlash" then
+		Elementarist.SpellFlash = _G['SpellFlashAddon']
+	end
+	if addon ~= "Elementarist" then return end
+	local _,playerClass = UnitClass("player")
+	if playerClass ~= "SHAMAN" then
+		Elementarist.eventFrame:UnregisterEvent("PLAYER_ALIVE")
+		return
+	end
+
+	-- load defaults, if first start
+	Elementarist:InitSettings()
+
+	-- add slash command
+	SlashCmdList["Elementarist"] = Elementarist.Options
+	SLASH_Elementarist1 = "/Elementarist"
+	SLASH_Elementarist2 = "/ele"
+
+	-- check if talent is elemental
+	Elementarist:detectTalent()
+
+	Elementarist.playerLevel = UnitLevel("player")
+
+	-- Setup behaviours
+	Elementarist.Behaviours["1"] = L.BEHAVIOUR_KEEP_FS_UP
+	Elementarist.Behaviours["2"] = L.BEHAVIOUR_FS_BEFORE_LVB
+	Elementarist.CLBehaviours["0"] = L.CLSTBEHAVIOUR_NONE
+	Elementarist.CLBehaviours["1"] = L.CLSTBEHAVIOUR_CL_AFTER_LVB
+	Elementarist.CLBehaviours["2"] = L.CLSTBEHAVIOUR_CL_ON_CD
+
+	-- Create GUI
+	Elementarist:CreateGUI()
+	Elementarist.displayFrame:SetScale(ElementaristDB.scale)
+	Elementarist.OmniCC = _G['OmniCC']
+	Elementarist.SpellFlash = _G['SpellFlashAddon']
+
+	-- Create config page
+	Elementarist:CreateConfig()
+
+	-- Register for Function Events
+	Elementarist.eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
+	Elementarist.eventFrame:RegisterEvent("COMBAT_RATING_UPDATE") -- Monitor the all-mighty haste
+	Elementarist.eventFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
+	Elementarist.eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED") -- Left combat, clean up all enemy GUIDs
+	Elementarist.eventFrame:RegisterEvent("PLAYER_TALENT_UPDATE")
+	Elementarist.eventFrame:RegisterEvent("PARTY_MEMBERS_CHANGED")
+
+	-- get debug frame
+	Elementarist.DebugChat = Elementarist:GetDebugFrame()
+end
+
+function Elementarist:InitSettings()
+	if not ElementaristDB then
+		ElementaristDB = {} -- fresh start
+	end
+	if not ElementaristDB.scale then ElementaristDB.scale = 1 end
+	if not ElementaristDB.debuffscale then ElementaristDB.debuffscale = 1 end
+	if not ElementaristDB.shieldscale then ElementaristDB.shieldscale = 1 end
+	if ElementaristDB.locked == nil then ElementaristDB.locked = false end
+	if ElementaristDB.enabled == nil then ElementaristDB.enabled = true end
+	if ElementaristDB.disableIfNotEle == nil then ElementaristDB.disableIfNotEle = true end
+	if ElementaristDB.debuffdisabled == nil then ElementaristDB.debuffdisabled = false end
+	if ElementaristDB.shielddisabled == nil then ElementaristDB.shielddisabled = false end
+	if ElementaristDB.alpha == nil then ElementaristDB.alpha = 0.8 end
+	if ElementaristDB.debuffalpha == nil then ElementaristDB.debuffalpha = 1 end
+	if ElementaristDB.shieldalpha == nil then ElementaristDB.shieldalpha = 1 end
+	if ElementaristDB.FireNova == nil then ElementaristDB.FireNova = true end
+	if ElementaristDB.Behaviour == nil then ElementaristDB.Behaviour = Elementarist.Behaviours["1"] end
+	if ElementaristDB.CLBehaviour == nil then ElementaristDB.CLBehaviour = Elementarist.CLBehaviours["0"] end
+	if ElementaristDB.EnableUE == nil then ElementaristDB.EnableUE = false end
+	if ElementaristDB.ThreatWarning == nil then ElementaristDB.ThreatWarning = true end
+	if ElementaristDB.EnableEQ == nil then ElementaristDB.EnableEQ = false end
+	if not ElementaristDB.x then ElementaristDB.x = -200 end
+	if not ElementaristDB.y then ElementaristDB.y = -200 end
+	if not ElementaristDB.relativePoint then ElementaristDB.relativePoint = "CENTER" end
+	if not ElementaristDB.debuffx then ElementaristDB.debuffx = -200 end
+	if not ElementaristDB.debuffy then ElementaristDB.debuffy = -100 end
+	if not ElementaristDB.debuffrelativePoint then ElementaristDB.debuffrelativePoint = "CENTER" end
+	if not ElementaristDB.shieldrelativePoint then ElementaristDB.shieldrelativePoint = "CENTER" end
+end
+
+function Elementarist:detectTalent()
+	local _,_,_,_,rest,_ = GetTalentTabInfo(3)
+	local _,_,_,_,enha,_ = GetTalentTabInfo(2)
+	local _,_,_,_,elem,_ = GetTalentTabInfo(1)
+
+	if (elem+rest+enha>0) then
+		Elementarist.isEle = ((elem>=enha) and (elem>=rest))
+	end
+	if (elem + enha + rest == 0) then
+		Elementarist.talentUnsure = true
+	else
+		Elementarist.talentUnsure = false
+	end
+end
+
+function Elementarist:PlayerInParty()
+	if (GetNumRaidMembers()>0) then
+		return 2
+	elseif (GetNumPartyMembers()>0) then
+		return 1
+	else
+		return 0
+	end
+end
+
+function Elementarist:RemoveFromTables(guid)
+	if (Elementarist.person["friend"][guid]) and (Elementarist.person["friend"][guid] ~= 0) then
+		Elementarist.person["friend"][guid] = 0
+		Elementarist.person["friendCount"] = Elementarist.person["friendCount"] - 1
+	end
+	if (Elementarist.person["foe"][guid]) and (Elementarist.person["foe"][guid] ~= 0) then
+		Elementarist.person["foe"][guid] = 0
+		Elementarist.person["foeCount"] = Elementarist.person["foeCount"] - 1
+		Elementarist:Debug('Enemy died:', Elementarist.person["foeCount"] .. " " .. guid)
+	end
+	if (Elementarist.debuffCooldowns[guid]) then
+		table.remove(Elementarist.debuffCooldowns, guid)
+		Elementarist:UpdateDebuffTracker()
+	end
+end
+
+function Elementarist:PurgeDebuffTable()
+	Elementarist.debuffCooldowns = {}
+	Elementarist:UpdateDebuffTracker()
+end
+
+function Elementarist:PurgePersonTable()
+	for i,v in pairs(Elementarist.person["foe"]) do
+		if ( ( GetTime() - Elementarist.person["foe"][i] ) > 3) then
+			-- no activity from that unit in last 2 seconds, remove it
+			if ( Elementarist.person["foe"][i] ~= 0) then
+				Elementarist.person["foe"][i] = 0	-- mark as inactive
+				Elementarist.person["foeCount"] = Elementarist.person["foeCount"] - 1
+				Elementarist:Debug('Enemy removed:', Elementarist.person["foeCount"])
+			end
+		end
+	end
+	for i,v in pairs(Elementarist.person["friend"]) do
+		if ( ( GetTime() - Elementarist.person["friend"][i] ) > 3) then
+			-- no activity from that unit in last 2 seconds, remove it
+			if ( Elementarist.person["friend"][i] ~= 0 ) then
+				Elementarist.person["friend"][i] = 0	-- mark as inactive
+				Elementarist.person["friendCount"] = Elementarist.person["friendCount"] - 1
+				Elementarist:Debug('Friend removed:', Elementarist.person["friendCount"])
+			end
+		end
+	end
+	Elementarist.lastPersonTablePurged = GetTime()
+end
+
+function Elementarist:CountPerson(time, event, sguid, sname, sflags, dguid, dname, dflags)
+	local suffix = event:match(".+(_.-)$")
+	local stype = (tonumber(sguid:sub(5,5), 16)) % 8
+	local dtype = (tonumber(dguid:sub(5,5), 16)) % 8
+	if Elementarist.HostileFilter[suffix] then
+		if (bit.band(dflags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE) and (bit.band(dflags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) and ((dtype==0) or (dtype==3)) then
+			if ((not Elementarist.person["foe"][dguid]) or (Elementarist.person["foe"][dguid]==0)) then
+				Elementarist.person["foeCount"] = Elementarist.person["foeCount"] + 1
+				Elementarist:Debug('Enemy added', Elementarist.person["foeCount"] .. " " .. dguid .. " " .. dflags)
+			end
+			Elementarist.person["foe"][dguid] = GetTime()
+    	elseif (bit.band(sflags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE) and (bit.band(sflags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) and ((stype==0) or (stype==3)) then
+			if ((not Elementarist.person["foe"][sguid]) or (Elementarist.person["foe"][sguid]==0)) then
+				Elementarist.person["foeCount"] = Elementarist.person["foeCount"] + 1
+				Elementarist:Debug('Enemy added', Elementarist.person["foeCount"] .. " " .. sguid)
+			end
+			Elementarist.person["foe"][sguid] = GetTime()
+		end
+		if (bit.band(dflags, COMBATLOG_OBJECT_REACTION_FRIENDLY) == COMBATLOG_OBJECT_REACTION_FRIENDLY) and ((dtype==0) or (dtype==3)) then
+			if ((not Elementarist.person["friend"][dguid]) or (Elementarist.person["friend"][dguid]==0)) then
+				Elementarist.person["friendCount"] = Elementarist.person["friendCount"] + 1
+				Elementarist:Debug('Friend added', Elementarist.person["friendCount"] .. " " .. dguid .. " " .. dflags)
+			end
+			Elementarist.person["friend"][dguid] = GetTime()
+    	elseif (bit.band(sflags, COMBATLOG_OBJECT_REACTION_FRIENDLY) == COMBATLOG_OBJECT_REACTION_FRIENDLY) and ((stype==0) or (stype==3)) then
+			if ((not Elementarist.person["friend"][sguid]) or (Elementarist.person["friend"][sguid]==0)) then
+				Elementarist.person["friendCount"] = Elementarist.person["friendCount"] + 1
+				Elementarist:Debug('Friend added', Elementarist.person["friendCount"] .. " " .. sguid .. " " .. sflags)
+			end
+			Elementarist.person["friend"][sguid] = GetTime()
+		end
+	end
+	if (Elementarist.lastPersonTablePurged < (GetTime() - 3)) and (Elementarist.person["foeCount"]>0) then
+		Elementarist:PurgePersonTable()
+	end
+	--
+	-- Elementarist:Debug('Enemy count:', Elementarist.person["foeCount"])
+	-- Elementarist:Debug('Friend count:', Elementarist.person["friendCount"])
+end
+
+function Elementarist.HighDMGFormat(dmg_amount)
+	if (dmg_amount >= 10000) then
+		return(format('%.1f',dmg_amount/1000) .. "K")
+	else
+		return(format('%.f',dmg_amount))
+	end
+end
+
+-- for 4.2:
+-- function Elementarist.events.COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, srcGUID, srcName, srcFlags, srcRaidFlags, dstGUID, dstName, dstFlags, dstRaidFlags, spellId, spellName, spellSchool, damage, ...)
+function Elementarist.events.COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellId, spellName, spellSchool, damage, ...)
+	if Elementarist.isEnabled() then
+		if srcName == Elementarist.playerName then
+			if (event=="SPELL_PERIODIC_DAMAGE") and (spellName==Elementarist.SpellList["Flame Shock"]) and (Elementarist.debuffCooldowns[dstGUID]) then
+				Elementarist.debuffCooldowns[dstGUID]["action"] = GetTime()
+			end
+			if (event=="SPELL_CAST_START") then
+				Elementarist.SFHistory.spell = nil
+				Elementarist.SFHistory.misc = nil
+				Elementarist.SFHistory.int = nil
+			end
+			Elementarist:DecideSpells()
+			-- calculate DPS
+			if (event=="SPELL_CAST_SUCCESS") then
+				Elementarist.lastSpell = spellName
+			end
+			if ((event=="SPELL_DAMAGE") or (event=="SPELL_PERIODIC_DAMAGE")) then
+				if (not Elementarist.DPSTable[dstGUID]) then
+					Elementarist.DPSTable[dstGUID] = {
+						["time"] = GetTime(),
+						["amount"] = 0,
+					}
+				end
+
+				Elementarist.DPSTable[dstGUID]["amount"] = Elementarist.DPSTable[dstGUID]["amount"] + damage
+				local dps_txt = ""
+				if (dstGUID == Elementarist.targetGUID) and (Elementarist.DPSTable[Elementarist.targetGUID]) then
+					local dps_sec = GetTime() - Elementarist.DPSTable[dstGUID]["time"]
+					if (dps_sec > 5) then
+						dps_txt = format('%.f',(Elementarist.DPSTable[dstGUID]["amount"] / dps_sec))
+					end
+					local threat_txt = ""
+					local _, status, threatpct, _, _ = UnitDetailedThreatSituation("player", "target")
+					if (status) then
+						if (threatpct<80) then
+							threat_txt = format("%.f",threatpct) .. " %"
+							Elementarist.cooldownFrame:SetReverse(false)
+							if (ElementaristDB.ThreatWarning) and (Elementarist.inParty>0) and (threatpct>70) then
+								RaidNotice_AddMessage(RaidBossEmoteFrame, L.THREAT_WARNING_PREFIX .. format("%.f",threatpct) .. L.THREAT_WARNING_SUFFIX, ChatTypeInfo["RAID_WARNING"])
+							end
+						else
+							threat_txt = "|cffff0000" .. format("%.f",threatpct) .. " %|r"
+							if (ElementaristDB.ThreatWarning) and (Elementarist.inParty>0) then
+								RaidNotice_AddMessage(RaidBossEmoteFrame, "|cffff0000" .. L.THREAT_WARNING_PREFIX .. format("%.f",threatpct) ..  L.THREAT_WARNING_SUFFIX .. "|r", ChatTypeInfo["RAID_WARNING"])
+							end
+							Elementarist.cooldownFrame:SetReverse((Elementarist.person["friendCount"]>1) and (Elementarist.inParty>0))
+						end
+					end
+					dps_txt = dps_txt .. "|n" .. threat_txt
+					Elementarist.textList["dps"]:SetText(dps_txt)
+				end
+			end
+		else
+			-- if unit died, remove if from friend and foe tables
+			if (event=="UNIT_DIED") or (event=="UNIT_DESTROYED") then
+				Elementarist:RemoveFromTables(dstGUID);
+			end
+			-- count enemies if player in combat
+			if (UnitAffectingCombat("player")) then
+				-- enemy count for CL advise and multiple player in combat (for aggro warning)
+				Elementarist:CountPerson(timestamp, event, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags)
+			end
+		end
+	end
+end
+
+function Elementarist.events.COMBAT_RATING_UPDATE(unit)
+	if unit == "player" then
+    	Elementarist.spellHaste = GetCombatRatingBonus(20) -- update spell haste
+		Elementarist.spellPower = GetSpellBonusDamage(4);
+	end
+end
+
+function Elementarist.events.PLAYER_TARGET_CHANGED(...)
+	Elementarist.targetGUID = UnitGUID("target")
+	Elementarist.inParty = Elementarist:PlayerInParty()
+
+	if (ElementaristDB.disableIfNotEle) and (not Elementarist:isEnabled()) then
+		Elementarist:detectTalent()
+		if Elementarist:isEnabled() then
+			Elementarist:ApplySettings()
+		end
+	end
+	if (not Elementarist.targetGUID) then
+		local threat_txt = ""
+		local _, status, threatpct, _, _ = UnitDetailedThreatSituation("player", "target")
+		if (status) then
+			if (threatpct<80) then
+				threat_txt = format("%.f",threatpct) .. " %"
+				Elementarist.cooldownFrame:SetReverse(false)
+			else
+				threat_txt = "|cffff0000" .. format("%.f",threatpct) .. " %|r"
+				Elementarist.cooldownFrame:SetReverse((Elementarist.person["friendCount"]>1) and (Elementarist.inParty>0))
+			end
+		end
+		Elementarist.textList["dps"]:SetText(threat_txt)
+	end
+	Elementarist:DecideSpells()
+end
+
+function Elementarist.events.PLAYER_REGEN_ENABLED(...)
+	-- left combat
+	Elementarist.person["friend"] = {}
+	Elementarist.person["friendCount"] = 0
+	Elementarist.person["foe"] = {}
+	Elementarist.person["foeCount"] = 0
+	Elementarist.DPSTable = {}
+	Elementarist.textList["dps"]:SetText("")
+	Elementarist.textList["debuff"]:SetText("")
+	Elementarist.cooldownFrame:SetReverse(false)
+	Elementarist:PurgePersonTable()
+	Elementarist:PurgeDebuffTable()
+end
+
+function Elementarist:isEnabled()
+	if (Elementarist.talentUnsure) then
+		Elementarist:detectTalent()
+	end
+	return (
+		ElementaristDB.enabled and (
+			(not ElementaristDB.disableIfNotEle) or (Elementarist.isEle)
+		)
+	)
+end
+
+function Elementarist:UpdateShieldTracker()
+	local name, _, icon, count, _, d, e = Elementarist:hasBuff("player",Elementarist.SpellList["Lightning Shield"])
+
+	Elementarist.shieldTrackerUpdate = GetTime()
+	if (name) then
+		Elementarist.textureList["shield"]:SetTexture(icon)
+		Elementarist.textList["shield"]:SetText(format('%.0f', count))
+		Elementarist.shieldCooldownFrame:SetCooldown( e-d, d)
+	else
+		Elementarist.textureList["shield"]:SetTexture("")
+		Elementarist.textList["shield"]:SetText("")
+		Elementarist.shieldCooldownFrame:SetCooldown(0, 0)
+	end
+end
+
+function Elementarist:UpdateDebuffTracker()
+	local name, _, icon, _, _, d, e = Elementarist:hasDeBuff("target",Elementarist.SpellList["Flame Shock"],"player")
+	local tguid = UnitGUID("target")
+
+	Elementarist.debuffTrackerUpdate = GetTime()
+	if (name) then
+		if (tguid) and (not Elementarist.debuffCooldowns[tguid]) then
+			Elementarist.debuffCooldowns[tguid] = {}
+		end
+		Elementarist.debuffCooldowns[tguid]["start"] = e-d
+		Elementarist.debuffCooldowns[tguid]["duration"] = d
+		Elementarist.debuffCooldowns[tguid]["action"] = GetTime()
+	else
+		_, _, icon = GetSpellInfo(Elementarist.SpellList["Flame Shock"])
+	end
+
+	-- update mini frames
+	local m = 1
+	for i,v in pairs(Elementarist.debuffCooldowns) do
+		if ( (v["start"] + v["duration"]) > GetTime() ) and (i ~= tguid) and (m <= 4) and (v["action"]>GetTime() - 4) then
+			Elementarist.textureList["debuff_" .. tostring(m)]:SetTexture(icon)
+			Elementarist.debuffCooldownFrame["mini_" .. tostring(m)]:SetCooldown( v["start"], v["duration"])
+			m = m + 1
+		end
+	end
+	for i=m,4,1 do
+		Elementarist.textureList["debuff_" .. tostring(m)]:SetTexture("")
+		Elementarist.debuffCooldownFrame["mini_" .. tostring(m)]:SetCooldown( 0, 0)
+	end
+
+	-- update main frame
+	if (name) then
+		Elementarist.textureList["debuff"]:SetTexture(icon)
+		if (not Elementarist.OmniCC) then
+			Elementarist.textList["debuff"]:SetText(format('%.1f', (e - GetTime())))
+		end
+		Elementarist.debuffCooldownFrame["main"]:SetCooldown( e-d, d)
+	else
+		Elementarist.textureList["debuff"]:SetTexture("")
+		Elementarist.textList["debuff"]:SetText("")
+		Elementarist.debuffCooldownFrame["main"]:SetCooldown(0, 0)
+	end
+end
+
+function Elementarist:GetSpellCooldownRemaining(spell)
+	local s, d, _ = GetSpellCooldown(spell)
+	if (d) and (d>0) then
+		d = s - GetTime() + d
+	end
+
+	return d
+end
+
+function Elementarist:hasDeBuff(unit, spellName, casterUnit)
+	local i = 1;
+	while true do
+		local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitDebuff(unit, i);
+		if not name then
+			break;
+		end
+		if (name) and (spellName) then
+			if string.match(name, spellName) and ((unitCaster == casterUnit) or (casterUnit == nil)) then
+				return name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable;
+			end
+		end
+		i = i + 1;
+	end
+end
+
+function Elementarist:hasBuff(unit, spellName, stealableOnly, getByID)
+	local i = 1;
+	while true do
+		local name, rank, icon, count, buffType, duration, expirationTime, source, isStealable, _, spellId = UnitBuff(unit, i);
+		if not name then
+			break;
+		end
+		if (not getByID) and (name) and (spellName) then
+			if string.match(name, spellName) then
+				if (not stealableOnly) or (isStealable) then
+					return name, rank, icon, count, buffType, duration, expirationTime, unitCaster, isStealable;
+				end
+			end
+		else
+			if (getByID == spellId) then
+				return name, rank, icon, count, buffType, duration, expirationTime, unitCaster, isStealable;
+			end
+		end
+		i = i + 1;
+	end
+end
+
+function Elementarist:hasTotem(unit, spellName)
+	local i = 1;
+	while true do
+		local name, rank, icon, count, buffType, duration, expirationTime, source, isStealable = UnitBuff(unit, i);
+		if not name then
+			break;
+		end
+		if (string.match(name, spellName) or (string.match(icon, spellName))) and (expirationTime==0) then
+	   		return name, rank, icon, count, buffType, duration, expirationTime, unitCaster, isStealable;
+		end
+		i = i + 1;
+	end
+end
+
+function Elementarist:SpellAvailable(spell)
+	if (not spell) then
+		return false
+	end
+	if (IsUsableSpell(spell)) then
+		return true
+	else
+		return false
+	end
+end
+
+function Elementarist:NextSpell(timeshift,exspell1,exspell2)
+	local guid = UnitGUID("target")
+	local currentTime = GetTime()
+	local s,d,e
+	local name, fsExpiration, unitCaster
+	local lastSpell
+
+	if (exspell1) then
+		if (exspell2) then
+			lastSpell = exspell2
+		else
+			lastSpell = exspell1
+		end
+	else
+		lastSpell = Elementarist.lastSpell
+	end
+
+	Elementarist.lastBaseGCD = 1.5 - (1.5 * Elementarist.spellHaste * .01)
+
+	local flameshockavail = false
+	local LvBct = 2 - (2 * Elementarist.spellHaste * .01)
+
+	-- check Shock CD
+	local s, d = GetSpellCooldown(Elementarist.SpellList["Flame Shock"])
+	if (d) and (d>0) then
+		Elementarist.lastShockCD = d
+	end
+	local s, d = GetSpellCooldown(Elementarist.SpellList["Earth Shock"])
+	if (d) and (d>0) then
+		Elementarist.lastShockCD = d
+	end
+
+	-- if target is dead, return ""
+	if (UnitHealth("target")<=0) then
+		return ""
+	end
+
+	if (not timeshift) then
+		timeshift = 0
+	end
+
+	-- check current spell
+	local spellInCast, _, _, _, sICstartTime, sICendTime = UnitCastingInfo("player")
+	if (sepllInCast) then
+		if ( (sICendTime - sICstartTime) / 1000 ) < Elementarist.lastBaseGCD then
+			sICendTime = sICstartTime + (Elementarist.lastBaseGCD * 1000)
+		end
+		timeshift = timeshift + (sICendTime / 1000) - GetTime()
+	else
+		-- no spell in cast, check global cd via Flametongue Weapon
+		if (Elementarist.SpellList["Flametongue Weapon"]) then
+			local ftcd = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Flametongue Weapon"])
+			if (ftcd) then
+				timeshift = timeshift + Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Flametongue Weapon"])
+			else
+				timeshift = timeshift + Elementarist.lastBaseGCD
+			end
+		else
+			timeshift = timeshift + Elementarist.lastBaseGCD
+		end
+	end
+
+	-- check if Flame shock applied on target first
+	name, _, _, _, _, _, fsExpiration, unitCaster = Elementarist:hasDeBuff("target", Elementarist.SpellList["Flame Shock"], "player");
+	if (exspell1 ~= Elementarist.SpellList["Flame Shock"]) and (exspell2 ~= Elementarist.SpellList["Flame Shock"]) then
+		if IsSpellInRange(Elementarist.SpellList["Flame Shock"], "target") == 1 then
+			if (not fsExpiration) then
+				fsExpiration = 0
+			end
+			d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Flame Shock"])
+			if ((d - timeshift) <= 0) then
+				flameshockavail = true
+				local doFS = false
+				if (unitCaster ~= "player") then	-- fs debuff is not casted by the player
+					name = false
+					fsExpiration = 0
+				end
+				if (not name) then 	-- no fs debuff on target
+					fsExpiration = 0
+				end
+				if (ElementaristDB.Behaviour == Elementarist.Behaviours["1"]) then
+					doFS = true
+				else	-- if fs before lvb, check lvb cd
+					d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Lava Burst"])
+					if (d <= (timeshift + Elementarist.lastBaseGCD)) then
+						doFS = true
+					end
+				end
+				if (doFS) and ((fsExpiration - GetTime() - timeshift) < 0) then
+					return Elementarist.SpellList["Flame Shock"]
+				end
+			end
+		end
+	end
+
+	-- Unleash Elements if LvB will be available after it, and target has FS debuff, and it will not expire before UE, and no LvB cast before UE
+	-- Weapon enchant has to be Flamtounge Weapon, and Unleash Elements are not on CD
+	if (ElementaristDB.EnableUE) then
+		if (exspell1 ~= Elementarist.SpellList["Unleash Elements"]) and (exspell2 ~= Elementarist.SpellList["Unleash Elements"]) then
+			if (
+				(IsSpellInRange(Elementarist.SpellList["Unleash Elements"], "target") == 1) and
+				(
+					( (Elementarist.SpellList["Lava Burst"]) ~= spellInCast) and
+					( (Elementarist.SpellList["Lava Burst"]) ~= exspell1) and
+					( (Elementarist.SpellList["Lava Burst"]) ~= exspell2)
+				) and
+				(
+					(exspell1 == Elementarist.SpellList["Flame Shock"] ) or
+					(exspell2 == Elementarist.SpellList["Flame Shock"] ) or
+					(fsExpiration > timeshift + (2 * Elementarist.lastBaseGCD ) )
+				)
+			) then
+				local hasMainHandEnchant, _, _, _, _, _ = GetWeaponEnchantInfo()
+				if (hasMainHandEnchant) then
+					d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Lava Burst"])
+					e = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Unleash Elements"])
+					if (d <= (timeshift + Elementarist.lastBaseGCD)) and ((e-timeshift) <= 0) then
+						return Elementarist.SpellList["Unleash Elements"]
+					end
+				end
+			end
+		end
+	end
+
+	if (not fsExpiration) then
+		fsExpiration = 0
+	end
+	if (exspell1 ~= Elementarist.SpellList["Lava Burst"]) and (exspell2 ~= Elementarist.SpellList["Lava Burst"]) then
+		if (IsSpellInRange(Elementarist.SpellList["Lava Burst"], "target") == 1) and
+		(
+			((fsExpiration~=0) and ((fsExpiration-GetTime()-timeshift) > LvBct)) or
+			(exspell1 == Elementarist.SpellList["Flame Shock"]) or
+			(exspell2 == Elementarist.SpellList["Flame Shock"])
+		) then
+			if ((Elementarist.SpellList["Lava Burst"]) ~= spellInCast) then
+				d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Lava Burst"])
+				if ((d-timeshift) <= 0) then
+					return Elementarist.SpellList["Lava Burst"]
+				end
+			end
+		end
+	end
+
+	-- if >=4 foes are available, and Earthquake not on cd
+	if (ElementaristDB.EnableEQ) then
+		if (exspell1 ~= Elementarist.SpellList["Earthquake"]) and (exspell2 ~= Elementarist.SpellList["Earthquake"]) then
+			if (Elementarist.person["foeCount"]>=4) then
+				d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Earthquake"])
+				if ((d-timeshift) <= 0) then
+					return Elementarist.SpellList["Earthquake"]
+				end
+			end
+		end
+	end
+
+	-- if >=4 foes are available, and Fire Nova enabled in settings, and not in cd (and has Flame Shock applied on target)
+	if (exspell1 ~= Elementarist.SpellList["Fire Nova"]) and (exspell2 ~= Elementarist.SpellList["Fire Nova"]) then
+		if (ElementaristDB.FireNova) and (Elementarist.person["foeCount"]>=4) then
+			-- is Flame Shock on target
+			local f = Elementarist:hasDeBuff("target",Elementarist.SpellList["Flame Shock"],"player")
+			if f then
+	            d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Fire Nova"])
+				if ((d-timeshift) <= 0) then
+					return Elementarist.SpellList["Fire Nova"]
+				end
+			end
+		end
+	end
+
+	-- Earth shock if Lightning Shield count >=9 and not on cd or FS debuff remaining between FS and FS cd + 2sec and LS count>=7
+	if ( (exspell1 ~= Elementarist.SpellList["Earth Shock"]) and (exspell2 ~= Elementarist.SpellList["Earth Shock"]) ) then
+		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Earth Shock"])
+		local _, _, _, lscount = Elementarist:hasBuff("player",Elementarist.SpellList["Lightning Shield"])
+		if (
+				( (d) and ((d-timeshift) <= 0) and (lscount) ) and (
+					(lscount>=9) or
+					( (lscount>=7) and
+						( (fsExpiration - GetTime() - timeshift) > Elementarist.lastShockCD ) and
+						( (fsExpiration - GetTime() - timeshift) < Elementarist.lastShockCD + 2 )
+					)
+				)
+			) then
+			return Elementarist.SpellList["Earth Shock"]
+		end
+	end
+
+	-- CL if there are multiple targets, (count in a dirty way from combat log, not to accurate!!!)
+	if (exspell1 ~= Elementarist.SpellList["Chain Lightning"]) and (exspell2 ~= Elementarist.SpellList["Chain Lightning"]) then
+		if (Elementarist.person["foeCount"]>2) then
+			if IsSpellInRange(Elementarist.SpellList["Chain Lightning"], "target") == 1 then
+				if ((Elementarist.SpellList["Chain Lightning"]) ~= spellInCast) then
+					d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Chain Lightning"])
+					if ((d-timeshift) <= 0) then
+						return Elementarist.SpellList["Chain Lightning"]
+					end
+				end
+			end
+		end
+	end
+
+	-- otherwise lightning bolt
+	if IsSpellInRange(Elementarist.SpellList["Lightning Bolt"], "target") == 1 then
+		return Elementarist.SpellList["Lightning Bolt"]
+	end
+
+	-- if nothing works, try flameshock again
+	if flameshockavail then
+		return Elementarist.SpellList["Flame Shock"]
+	end
+
+	return ""
+end
+
+function Elementarist:MiscSpell()
+	-- Miscelaneous spell order:
+	-- Flametongoue weapon
+	-- Lightning Shield
+	-- Searing Totem
+	-- Totem of Wrath
+	-- Wrath of Air totem
+	-- Elemental Mastery
+	-- Berserking troll racial (if available)
+	-- Blood Fury orc racial
+	-- Lifeblood Herbalism spell
+
+	local d, e
+	local name, expirationTime
+
+	-- Alchemy Flask of Enhancement
+	if GetItemCount(Elementarist.CustomIDs["Flask of Enhancement Item"]) ~= 0 then
+		name = Elementarist:hasBuff("player", Elementarist.SpellList["Flask of the Draconic Mind"]);
+		if (name == nil) then
+			name, _, _, _, _, _, expirationTime = Elementarist:hasBuff("player", Elementarist.SpellList["Flask of Enhancement"], false, Elementarist.CustomIDs["Flask of Enhancement Spell"]);
+			if (name == nil) or (expirationTime < 2) then
+				if (icon == nil) then
+					icon = GetItemIcon(Elementarist.CustomIDs["Flask of Enhancement Item"])
+				end
+				return nil,icon
+			end
+		end
+	end
+
+	-- Flametongue weapon
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Flametongue Weapon"]) then
+		local hasMainHandEnchant, mainHandExpiration, _, _, _, _ = GetWeaponEnchantInfo()
+		if (hasMainHandEnchant == nil) or ((mainHandExpiration / 60000) < 1) then
+			return Elementarist.SpellList["Flametongue Weapon"]
+		end
+	end
+
+	-- Lightning Shield
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Lightning Shield"]) then
+		name, _, _, _, _, _, expirationTime = Elementarist:hasBuff("player", Elementarist.SpellList["Lightning Shield"]);
+		if (name == nil) or (expirationTime < 1) then
+			return Elementarist.SpellList["Lightning Shield"]
+		end
+	end
+
+	-- Searing Totem
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Searing Totem"]) then
+		local haveFireTotem,fireTotemName,_,_ = GetTotemInfo(1)
+		if (fireTotemName == "") then
+			-- no fire totem
+			return Elementarist.SpellList["Searing Totem"]
+		end
+	end
+
+	-- Wrath of Air totem
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Wrath of Air Totem"]) then
+		if (
+			(Elementarist:hasTotem("player", Elementarist.SpellList["Wrath of Air Totem"]) == nil) and
+			(Elementarist:hasBuff("player", GetSpellInfo(Elementarist.CustomIDs["Moonkin Aura"]), false, Elementarist.CustomIDs["Moonkin Aura"]) == nil) and
+			(Elementarist:hasBuff("player", GetSpellInfo(Elementarist.CustomIDs["Mind Quickening"]), false, Elementarist.CustomIDs["Mind Quickening"]) == nil)
+		) then
+			return Elementarist.SpellList["Wrath of Air Totem"]
+		end
+	end
+
+	-- Elemental Mastery
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Elemental Mastery"]) then
+		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Elemental Mastery"])
+		if d <= 0.5 then
+			return Elementarist.SpellList["Elemental Mastery"]
+		end
+	end
+
+	-- Berserking
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Berserking"]) then
+		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Berserking"])
+		if d <= 0.5 then
+			return Elementarist.SpellList["Berserking"]
+		end
+	end
+
+	-- Blood Fury
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Blood Fury"]) then
+		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Blood Fury"])
+		if d <= 0.5 then
+			return Elementarist.SpellList["Blood Fury"]
+		end
+	end
+
+	-- Lifeblood
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Lifeblood"]) then
+		d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Lifeblood"])
+		if d <= 0.5 then
+			return Elementarist.SpellList["Lifeblood"]
+		end
+	end
+
+	return ""
+
+end
+
+function Elementarist:IntSpell()
+	-- interruptions, mana recharge wia thunderstorm, and purge on target
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Wind Shear"]) then
+		if IsSpellInRange(Elementarist.SpellList["Wind Shear"], "target") == 1 then
+			local _, status, threatpct, _, _ = UnitDetailedThreatSituation("player", "target")
+			if ((UnitCastingInfo("target")) or (UnitChannelInfo("target"))) or ((status) and (threatpct>80) and (Elementarist.person["friendCount"]>1) and (Elementarist.inParty>0)) then
+				local d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Wind Shear"])
+				if (d) and (d<0.5) and (IsSpellInRange(Elementarist.SpellList["Wind Shear"], "target") ) then
+					return Elementarist.SpellList["Wind Shear"]
+				end
+			end
+
+			if (UnitChannelInfo("target")) then
+				local d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Wind Shear"])
+				if (d<0.5) and (interruptable) and (IsSpellInRange(Elementarist.SpellList["Wind Shear"], "target") ) then
+					return Elementarist.SpellList["Wind Shear"]
+				end
+			end
+		end
+	end
+
+	-- check if mana is below 70% and Thunderstorm available
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Thunderstorm"]) then
+		local d = GetSpellCooldown(Elementarist.SpellList["Thunderstorm"])
+		if (d) and ((UnitPower("player",0) / UnitPowerMax("player",0)) < 0.7) and (d < 0.5) then
+			return Elementarist.SpellList["Thunderstorm"]
+		end
+	end
+
+	-- check if purgeable buff is on target (not sure if this is ok)
+	if Elementarist:SpellAvailable(Elementarist.SpellList["Purge"]) then
+		if IsSpellInRange(Elementarist.SpellList["Purge"], "target") == 1 then
+			if (Elementarist:hasBuff("target", ".", 1)) then
+				local d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Purge"])
+				if (d<0.5) then
+					return Elementarist.SpellList["Purge"]
+				end
+			end
+		end
+	end
+
+	return ""
+end
+
+function Elementarist:FlashSpell(spell,spelltype)
+	local color = "White"
+	if (Elementarist.SpellFlash) and (Elementarist.SFHistory[spelltype] ~= spell) and (Elementarist.SpellFlash.Flashable(spell)) then
+		if (spelltype == "int") then
+			color = "Aqua"
+		end
+		if (spelltype == "misc") then
+			color = "Green"
+		end
+		Elementarist.SpellFlash.Flash(spell,color)
+		Elementarist.SFHistory.spell=spell
+	end
+end
+
+function Elementarist:DecideSpells()
+
+	Elementarist.timeSinceLastUpdate = 0;
+	local currentTime = GetTime()
+
+	local guid = UnitGUID("target")
+	local guid = UnitGUID("target")
+	if  UnitName("target") == nil or UnitIsFriend("player","target") ~= nil or UnitHealth("target") == 0 then
+		guid = nil
+	end
+
+	if UnitInVehicle("player") then
+		-- player is in a "vehicle" don't suggest spell
+		Elementarist.textureList["next"]:SetTexture("")
+		Elementarist.textureList["next1"]:SetTexture("")
+		Elementarist.textureList["next2"]:SetTexture("")
+		Elementarist.textureList["misc"]:SetTexture("")
+		Elementarist.textureList["int"]:SetTexture("")
+
+		return
+	end
+
+	if guid == nil then
+		Elementarist.textureList["next"]:SetTexture("")
+		Elementarist.textureList["next1"]:SetTexture("")
+		Elementarist.textureList["next2"]:SetTexture("")
+		Elementarist.textureList["misc"]:SetTexture("")
+		Elementarist.textureList["int"]:SetTexture("")
+
+		return
+	end
+  	if (UnitHealth("target") == 0) then
+		Elementarist.textureList["next"]:SetTexture("")
+		Elementarist.textureList["next1"]:SetTexture("")
+		Elementarist.textureList["next2"]:SetTexture("")
+
+		return
+  	end
+
+	local spell = ""
+	spell = Elementarist:NextSpell()
+	Elementarist:FlashSpell(spell,"spell")
+	local d = Elementarist:GetSpellCooldownRemaining(spell)
+	if (d) and (d>0) then
+		local cdStart = currentTime - Elementarist.lastBaseGCD + d  -- should be less then the base gcd if we are suggesting it
+		if (cdStart) and (Elementarist.lastBaseGCD) then
+			Elementarist.cooldownFrame:SetCooldown(cdStart, Elementarist.lastBaseGCD)
+		end
+	end
+	Elementarist.textureList["next"]:SetTexture(GetSpellTexture(spell))
+
+	local _,_,_,_,_,_,ct1=GetSpellInfo(spell)
+	if (not ct1) then
+		ct1 = 0
+	else
+		ct1 = (ct1 / 1000)
+	end
+	local spell1 = Elementarist:NextSpell(ct1,spell)
+	Elementarist.textureList["next1"]:SetTexture(GetSpellTexture(spell1))
+
+	local _,_,_,_,_,_,ct2=GetSpellInfo(spell1)
+	if (not ct2) then
+		ct2 = 0
+	else
+		ct2 = (ct2 / 1000)
+	end
+	if (not ct2) or (ct2 < Elementarist.lastBaseGCD) then
+		ct2 = Elementarist.lastBaseGCD
+	end
+	local spell2 = Elementarist:NextSpell(ct1+ct2,spell,spell1)
+	Elementarist.textureList["next2"]:SetTexture(GetSpellTexture(spell2))
+
+	local icon
+
+	spell,icon = Elementarist:MiscSpell()
+	Elementarist:FlashSpell(spell,"misc")
+
+	if (icon) then
+		Elementarist.textureList["misc"]:SetTexture(icon)
+	else
+		if (spell) then
+			Elementarist.textureList["misc"]:SetTexture(GetSpellTexture(spell))
+		end
+	end
+
+	spell = Elementarist:IntSpell()
+	Elementarist:FlashSpell(spell,"int")
+	Elementarist.textureList["int"]:SetTexture(GetSpellTexture(spell))
+
+
+end
+
+function Elementarist:OnUpdate(elapsed)
+	if (Elementarist:isEnabled()) then
+		Elementarist.timeSinceLastUpdate = Elementarist.timeSinceLastUpdate + elapsed
+
+		if (Elementarist.timeSinceLastUpdate > (1.5 - (1.5 * Elementarist.spellHaste * .01)) * 0.3) then
+			Elementarist:DecideSpells()
+		end
+		if (not ElementaristDB.debuffdisabled) then
+			Elementarist.debuffTrackerUpdate = Elementarist.debuffTrackerUpdate + elapsed
+			if (
+				((Elementarist.OmniCC) and (Elementarist.debuffTrackerUpdate >= 1)) or
+				((not Elementarist.OmniCC) and (Elementarist.debuffTrackerUpdate >= 1))
+			) then
+				Elementarist:UpdateDebuffTracker()
+			end
+		end
+		if (not ElementaristDB.shielddisabled) then
+			Elementarist.shieldTrackerUpdate = Elementarist.shieldTrackerUpdate + elapsed
+			if (
+				((Elementarist.OmniCC) and (Elementarist.shieldTrackerUpdate >= 1)) or
+				((not Elementarist.OmniCC) and (Elementarist.shieldTrackerUpdate >= 1))
+			) then
+				Elementarist:UpdateShieldTracker()
+			end
+		end
+	end
+end
diff --git a/Elementarist.toc b/Elementarist.toc
index 109f4df..526eeb1 100755
--- a/Elementarist.toc
+++ b/Elementarist.toc
@@ -1,12 +1,12 @@
-## Interface: 40100
-## Title: Elementarist
-## Notes: Elemental shaman spell rotation helper
-## Author: Taracque, Felmosórongy of Arathor
-## Version: 2.0.2
-## SavedVariables: ElementaristDB
-## OptionalDeps: OmniCC, SpellFlash
-## Dependencies:
-
-Elementarist.lua
-Ele_GUI.lua
-Localization_enUS.lua
+## Interface: 40100
+## Title: Elementarist
+## Notes: Elemental shaman spell rotation helper
+## Author: Taracque, Felmosórongy of Arathor
+## Version: 2.0.2
+## SavedVariables: ElementaristDB
+## OptionalDeps: OmniCC, SpellFlash
+## Dependencies:
+
+Elementarist.lua
+Ele_GUI.lua
+Localization_enUS.lua
diff --git a/License.txt b/License.txt
index 818433e..94a9ed0 100755
--- a/License.txt
+++ b/License.txt
@@ -1,674 +1,674 @@
-                    GNU GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-                            Preamble
-
-  The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
-  The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works.  By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.  We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors.  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
-  To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights.  Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received.  You must make sure that they, too, receive
-or can get the source code.  And you must show them these terms so they
-know their rights.
-
-  Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
-  For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software.  For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
-  Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so.  This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software.  The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable.  Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products.  If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
-  Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary.  To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-                       TERMS AND CONDITIONS
-
-  0. Definitions.
-
-  "This License" refers to version 3 of the GNU General Public License.
-
-  "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
-  "The Program" refers to any copyrightable work licensed under this
-License.  Each licensee is addressed as "you".  "Licensees" and
-"recipients" may be individuals or organizations.
-
-  To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy.  The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
-  A "covered work" means either the unmodified Program or a work based
-on the Program.
-
-  To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy.  Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
-  To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies.  Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
-  An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License.  If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
-  1. Source Code.
-
-  The "source code" for a work means the preferred form of the work
-for making modifications to it.  "Object code" means any non-source
-form of a work.
-
-  A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
-  The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form.  A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
-  The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities.  However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work.  For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
-  The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
-  The Corresponding Source for a work in source code form is that
-same work.
-
-  2. Basic Permissions.
-
-  All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met.  This License explicitly affirms your unlimited
-permission to run the unmodified Program.  The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work.  This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
-  You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force.  You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright.  Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
-  Conveying under any other circumstances is permitted solely under
-the conditions stated below.  Sublicensing is not allowed; section 10
-makes it unnecessary.
-
-  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
-  No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
-  When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
-  4. Conveying Verbatim Copies.
-
-  You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
-  You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
-  5. Conveying Modified Source Versions.
-
-  You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
-    a) The work must carry prominent notices stating that you modified
-    it, and giving a relevant date.
-
-    b) The work must carry prominent notices stating that it is
-    released under this License and any conditions added under section
-    7.  This requirement modifies the requirement in section 4 to
-    "keep intact all notices".
-
-    c) You must license the entire work, as a whole, under this
-    License to anyone who comes into possession of a copy.  This
-    License will therefore apply, along with any applicable section 7
-    additional terms, to the whole of the work, and all its parts,
-    regardless of how they are packaged.  This License gives no
-    permission to license the work in any other way, but it does not
-    invalidate such permission if you have separately received it.
-
-    d) If the work has interactive user interfaces, each must display
-    Appropriate Legal Notices; however, if the Program has interactive
-    interfaces that do not display Appropriate Legal Notices, your
-    work need not make them do so.
-
-  A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit.  Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
-  6. Conveying Non-Source Forms.
-
-  You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
-    a) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by the
-    Corresponding Source fixed on a durable physical medium
-    customarily used for software interchange.
-
-    b) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by a
-    written offer, valid for at least three years and valid for as
-    long as you offer spare parts or customer support for that product
-    model, to give anyone who possesses the object code either (1) a
-    copy of the Corresponding Source for all the software in the
-    product that is covered by this License, on a durable physical
-    medium customarily used for software interchange, for a price no
-    more than your reasonable cost of physically performing this
-    conveying of source, or (2) access to copy the
-    Corresponding Source from a network server at no charge.
-
-    c) Convey individual copies of the object code with a copy of the
-    written offer to provide the Corresponding Source.  This
-    alternative is allowed only occasionally and noncommercially, and
-    only if you received the object code with such an offer, in accord
-    with subsection 6b.
-
-    d) Convey the object code by offering access from a designated
-    place (gratis or for a charge), and offer equivalent access to the
-    Corresponding Source in the same way through the same place at no
-    further charge.  You need not require recipients to copy the
-    Corresponding Source along with the object code.  If the place to
-    copy the object code is a network server, the Corresponding Source
-    may be on a different server (operated by you or a third party)
-    that supports equivalent copying facilities, provided you maintain
-    clear directions next to the object code saying where to find the
-    Corresponding Source.  Regardless of what server hosts the
-    Corresponding Source, you remain obligated to ensure that it is
-    available for as long as needed to satisfy these requirements.
-
-    e) Convey the object code using peer-to-peer transmission, provided
-    you inform other peers where the object code and Corresponding
-    Source of the work are being offered to the general public at no
-    charge under subsection 6d.
-
-  A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
-  A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling.  In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage.  For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product.  A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
-  "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source.  The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
-  If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information.  But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
-  The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed.  Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
-  Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
-  7. Additional Terms.
-
-  "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law.  If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
-  When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it.  (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.)  You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
-  Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
-    a) Disclaiming warranty or limiting liability differently from the
-    terms of sections 15 and 16 of this License; or
-
-    b) Requiring preservation of specified reasonable legal notices or
-    author attributions in that material or in the Appropriate Legal
-    Notices displayed by works containing it; or
-
-    c) Prohibiting misrepresentation of the origin of that material, or
-    requiring that modified versions of such material be marked in
-    reasonable ways as different from the original version; or
-
-    d) Limiting the use for publicity purposes of names of licensors or
-    authors of the material; or
-
-    e) Declining to grant rights under trademark law for use of some
-    trade names, trademarks, or service marks; or
-
-    f) Requiring indemnification of licensors and authors of that
-    material by anyone who conveys the material (or modified versions of
-    it) with contractual assumptions of liability to the recipient, for
-    any liability that these contractual assumptions directly impose on
-    those licensors and authors.
-
-  All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10.  If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term.  If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
-  If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
-  Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
-  8. Termination.
-
-  You may not propagate or modify a covered work except as expressly
-provided under this License.  Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
-  However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
-  Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-  Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License.  If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
-  9. Acceptance Not Required for Having Copies.
-
-  You are not required to accept this License in order to receive or
-run a copy of the Program.  Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance.  However,
-nothing other than this License grants you permission to propagate or
-modify any covered work.  These actions infringe copyright if you do
-not accept this License.  Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
-  10. Automatic Licensing of Downstream Recipients.
-
-  Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License.  You are not responsible
-for enforcing compliance by third parties with this License.
-
-  An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations.  If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
-  You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License.  For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
-  11. Patents.
-
-  A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based.  The
-work thus licensed is called the contributor's "contributor version".
-
-  A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version.  For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
-  Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
-  In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement).  To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
-  If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients.  "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
-  If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
-  A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License.  You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
-  Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
-  12. No Surrender of Others' Freedom.
-
-  If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all.  For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
-  13. Use with the GNU Affero General Public License.
-
-  Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work.  The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
-  14. Revised Versions of this License.
-
-  The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-  Each version is given a distinguishing version number.  If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation.  If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
-  If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
-  Later license versions may give you additional or different
-permissions.  However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
-  15. Disclaimer of Warranty.
-
-  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. Limitation of Liability.
-
-  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
-  17. Interpretation of Sections 15 and 16.
-
-  If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
-                     END OF TERMS AND CONDITIONS
-
-            How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
-  If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
-    <program>  Copyright (C) <year>  <name of author>
-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
-  You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
-  The GNU General Public License does not permit incorporating your program
-into proprietary programs.  If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/Localization_enUS.lua b/Localization_enUS.lua
index b982c0b..d5136b3 100755
--- a/Localization_enUS.lua
+++ b/Localization_enUS.lua
@@ -1,35 +1,35 @@
--- enUS localization file for Elementarist
-
--- This is the default locale.
-
-if GetLocale() then
-	local L = Elementarist.Locals
-
-	L.BEHAVIOUR_KEEP_FS_UP = "Keep Flame Shock up"
-	L.BEHAVIOUR_FS_BEFORE_LVB = "Flame Shock before Lava"
-	L.THREAT_WARNING_SUFFIX = "% threat!"
-	L.THREAT_WARNING_PREFIX = ""
-	L.CONFIG_ENABLED = "Enabled"
-	L.CONFIG_ONLY_ON_ELE = "Disable when not on elemental talent"
-	L.CONFIG_LOCK_FRAMES = "Lock elementarist frames"
-	L.CONFIG_SPELL_ADV_SCALE = "Spell advisor scale"
-	L.CONFIG_SPELL_ADV_ALPHA = "Spell advisor alpha"
-	L.CONFIG_DISABLE_DEBUFF_TRACKER = "Disable debuff tracker"
-	L.CONFIG_DEBUFF_TRACKER_SCALE = "Debuff tracker scale"
-	L.CONFIG_DEBUFF_TRACKER_ALPHA = "Debuff tracker alpha"
-	L.CONFIG_ENABLE_NOVA = "Enable Fire Nova in rotation"
-	L.CONFIG_BEHAVIOUR = "Flame Shock behaviour"
-	L.CONFIG_THREAT_WARNING = "Threat warning"
-	L.CONFIG_RESET_POSITIONS = "Reset frame positions"
-	L.CONFIG_CLSTBEHAVIOUR = "Chain Lightning single target behaviour"
-	L.CLSTBEHAVIOUR_CL_AFTER_LVB = "Chain Lightning after Lava"
-	L.CLSTBEHAVIOUR_CL_ON_CD = "Chain Lightning on Cooldown"
-	L.CLSTBEHAVIOUR_NONE = "None"
--- new for 1.9
-	L.CONFIG_SHIELD_TRACKER_SCALE = "Shield tracker scale"
-	L.CONFIG_SHIELD_TRACKER_ALPHA = "Shield tracker alpha"
-	L.CONFIG_DISABLE_SHIELD_TRACKER = "Disable shield tracker"
-	L.CONFIG_ENABLE_UE_SPELL = "Enable Unleash Elements in rotation"
--- new for 2.0
-	L.CONFIG_ENABLE_EQ_SPELL = "Enable Earthquake in rotation"
+-- enUS localization file for Elementarist
+
+-- This is the default locale.
+
+if GetLocale() then
+	local L = Elementarist.Locals
+
+	L.BEHAVIOUR_KEEP_FS_UP = "Keep Flame Shock up"
+	L.BEHAVIOUR_FS_BEFORE_LVB = "Flame Shock before Lava"
+	L.THREAT_WARNING_SUFFIX = "% threat!"
+	L.THREAT_WARNING_PREFIX = ""
+	L.CONFIG_ENABLED = "Enabled"
+	L.CONFIG_ONLY_ON_ELE = "Disable when not on elemental talent"
+	L.CONFIG_LOCK_FRAMES = "Lock elementarist frames"
+	L.CONFIG_SPELL_ADV_SCALE = "Spell advisor scale"
+	L.CONFIG_SPELL_ADV_ALPHA = "Spell advisor alpha"
+	L.CONFIG_DISABLE_DEBUFF_TRACKER = "Disable debuff tracker"
+	L.CONFIG_DEBUFF_TRACKER_SCALE = "Debuff tracker scale"
+	L.CONFIG_DEBUFF_TRACKER_ALPHA = "Debuff tracker alpha"
+	L.CONFIG_ENABLE_NOVA = "Enable Fire Nova in rotation"
+	L.CONFIG_BEHAVIOUR = "Flame Shock behaviour"
+	L.CONFIG_THREAT_WARNING = "Threat warning"
+	L.CONFIG_RESET_POSITIONS = "Reset frame positions"
+	L.CONFIG_CLSTBEHAVIOUR = "Chain Lightning single target behaviour"
+	L.CLSTBEHAVIOUR_CL_AFTER_LVB = "Chain Lightning after Lava"
+	L.CLSTBEHAVIOUR_CL_ON_CD = "Chain Lightning on Cooldown"
+	L.CLSTBEHAVIOUR_NONE = "None"
+-- new for 1.9
+	L.CONFIG_SHIELD_TRACKER_SCALE = "Shield tracker scale"
+	L.CONFIG_SHIELD_TRACKER_ALPHA = "Shield tracker alpha"
+	L.CONFIG_DISABLE_SHIELD_TRACKER = "Disable shield tracker"
+	L.CONFIG_ENABLE_UE_SPELL = "Enable Unleash Elements in rotation"
+-- new for 2.0
+	L.CONFIG_ENABLE_EQ_SPELL = "Enable Earthquake in rotation"
 end
\ No newline at end of file