Quantcast

Code consistency.

Johnny C. Lam [03-19-13 - 23:31]
Code consistency.

Make local copies of all Blizzard API functions and prefix them with
"API_". This makes it simpler to automatically audit the use of Blizzard
API functions.

Rename all private static variables by adding a "self_" prefix.  This
reduces namespace conflicts with variable names when writing functions.

Rename all constants and constant tables to be in all-capitals and to
start with an "OVALE_" prefix.  This makes it clear what values are
immutable and which may be changed.

Also remove ``Ovale'' from the global namespace as a final clean-up.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@797 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Ovale.lua
OvaleActionBar.lua
OvaleAura.lua
OvaleBestAction.lua
OvaleComboPoints.lua
OvaleCompile.lua
OvaleCondition.lua
OvaleData.lua
OvaleEnemies.lua
OvaleEquipement.lua
OvaleFrame.lua
OvaleFuture.lua
OvaleGUID.lua
OvaleIcone.lua
OvaleOptions.lua
OvalePaperDoll.lua
OvalePool.lua
OvaleSpellDamage.lua
OvaleStance.lua
OvaleState.lua
OvaleSwing.lua
diff --git a/Ovale.lua b/Ovale.lua
index 8fc5b3a..03d9b68 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -8,23 +8,33 @@
 ----------------------------------------------------------------------]]

 local _, Ovale = ...
-_G.Ovale = LibStub("AceAddon-3.0"):NewAddon(Ovale, "Ovale", "AceConsole-3.0", "AceEvent-3.0")
+local OvaleAddon = LibStub("AceAddon-3.0"):NewAddon(Ovale, "Ovale", "AceConsole-3.0", "AceEvent-3.0")

 --<private-static-properties>
 local L = LibStub("AceLocale-3.0"):GetLocale("Ovale")
 local OvaleOptions = nil

-local ipairs, pairs, strsplit, tinsert, tsort = ipairs, pairs, string.split, table.insert, table.sort
-local SendAddonMessage, UnitAura, UnitCanAttack = SendAddonMessage, UnitAura, UnitCanAttack
-local UnitExists, UnitHasVehicleUI, UnitIsDead = UnitExists, UnitHasVehicleUI, UnitIsDead
-
-local damageMeterModules = {}
+local ipairs = ipairs
+local pairs = pairs
+local strsplit = string.split
+local tinsert = table.insert
+local tsort = table.sort
+local API_GetTime = GetTime
+local API_RegisterAddonMessagePrefix = RegisterAddonMessagePrefix
+local API_SendAddonMessage = SendAddonMessage
+local API_UnitAura = UnitAura
+local API_UnitCanAttack = UnitCanAttack
+local API_UnitExists = UnitExists
+local API_UnitHasVehicleUI = UnitHasVehicleUI
+local API_UnitIsDead = UnitIsDead
+
+local self_damageMeterModules = {}
 --</private-static-properties>

 --<public-static-properties>
 Ovale.L = L
 --The current time, updated once per frame refresh.
-Ovale.now = GetTime()
+Ovale.now = API_GetTime()
 --The table of check boxes definition
 Ovale.casesACocher = {}
 --the frame with the icons
@@ -70,7 +80,7 @@ function Ovale:DebugListAura(target, filter)
 	local i = 1
 	local array = {}
 	while true do
-		local name, _, _, _, _, _, _, _, _, _, spellId =  UnitAura(target, i, filter)
+		local name, _, _, _, _, _, _, _, _, _, spellId =  API_UnitAura(target, i, filter)
 		if not name then
 			break
 		end
@@ -85,7 +95,7 @@ end

 function Ovale:OnEnable()
     -- Called when the addon is enabled
-	RegisterAddonMessagePrefix("Ovale")
+	API_RegisterAddonMessagePrefix("Ovale")
 	self:RegisterEvent("PLAYER_REGEN_ENABLED");
 	self:RegisterEvent("PLAYER_REGEN_DISABLED");
 	self:RegisterEvent("PLAYER_TARGET_CHANGED")
@@ -132,7 +142,7 @@ end

 function Ovale:PLAYER_REGEN_DISABLED()
 	if self.maxScore>0 then
-		SendAddonMessage("Ovale", self.score..";"..self.maxScore..";"..UnitGUID("player"), "RAID")
+		API_SendAddonMessage("Ovale", self.score..";"..self.maxScore..";"..UnitGUID("player"), "RAID")
 	end
 	self.enCombat = true
 	self.score = 0
@@ -142,15 +152,15 @@ function Ovale:PLAYER_REGEN_DISABLED()
 end

 function Ovale:AddDamageMeter(name, module)
-	damageMeterModules[name] = module
+	self_damageMeterModules[name] = module
 end

 function Ovale:RemoveDamageMeter(name)
-	damageMeterModules[name] = nil
+	self_damageMeterModules[name] = nil
 end

 function Ovale:SendScoreToDamageMeter(name, guid, scored, scoreMax)
-	for _, module in pairs(damageMeterModules) do
+	for _, module in pairs(self_damageMeterModules) do
 		module:SendScoreToDamageMeter(name, guid, scored, scoreMax)
 	end
 end
@@ -188,11 +198,11 @@ function Ovale:UpdateVisibility()
 	end

 	self.frame:Show()
-	if profile.apparence.hideVehicule and UnitHasVehicleUI("player") then
+	if profile.apparence.hideVehicule and API_UnitHasVehicleUI("player") then
 		self.frame:Hide()
 	end

-	if profile.apparence.avecCible and not UnitExists("target") then
+	if profile.apparence.avecCible and not API_UnitExists("target") then
 		self.frame:Hide()
 	end

@@ -200,7 +210,7 @@ function Ovale:UpdateVisibility()
 		self.frame:Hide()
 	end

-	if profile.apparence.targetHostileOnly and (UnitIsDead("target") or not UnitCanAttack("player", "target")) then
+	if profile.apparence.targetHostileOnly and (API_UnitIsDead("target") or not API_UnitCanAttack("player", "target")) then
 		self.frame:Hide()
 	end
 end
diff --git a/OvaleActionBar.lua b/OvaleActionBar.lua
index 71bd930..cca93c8 100644
--- a/OvaleActionBar.lua
+++ b/OvaleActionBar.lua
@@ -14,16 +14,16 @@ Ovale.OvaleActionBar = OvaleActionBar

 --<private-static-properties>
 local tonumber = tonumber
-local wipe = wipe
-
-local GetActionInfo = GetActionInfo
-local GetActionText = GetActionText
+local wipe = table.wipe
+local API_GetActionInfo = GetActionInfo
+local API_GetActionText = GetActionText
+local API_GetBindingKey = GetBindingKey

 --key: spell name / value: action icon id
-actionSpell = {}
-actionMacro = {}
-actionItem = {}
-keybind = {}
+self_actionSpell = {}
+self_actionMacro = {}
+self_actionItem = {}
+self_keybind = {}
 --</private-static-properties>

 --<public-static-methods>
@@ -55,26 +55,26 @@ end

 function OvaleActionBar:FillActionIndexes(event)
 	Ovale:DebugPrint("action_bar", "Mapping buttons to spells/macros for " ..event)
-	wipe(actionSpell)
-	wipe(actionMacro)
-	wipe(actionItem)
-	wipe(keybind)
+	wipe(self_actionSpell)
+	wipe(self_actionMacro)
+	wipe(self_actionItem)
+	wipe(self_keybind)
 	for i=1,120 do
 		self:FillActionIndex(i)
 	end
 end

 function OvaleActionBar:FillActionIndex(i)
-	keybind[i] = self:FindKeyBinding(i)
-	local actionText = GetActionText(i)
+	self_keybind[i] = self:FindKeyBinding(i)
+	local actionText = API_GetActionText(i)
 	if actionText then
-		actionMacro[actionText] = i
+		self_actionMacro[actionText] = i
 	else
-		local type, spellId = GetActionInfo(i);
+		local type, spellId = API_GetActionInfo(i);
 		if (type=="spell") then
-			actionSpell[spellId] = i
+			self_actionSpell[spellId] = i
 		elseif (type =="item") then
-			actionItem[spellId] = i
+			self_actionItem[spellId] = i
 		end
 	end
 end
@@ -97,7 +97,7 @@ function OvaleActionBar:FindKeyBinding(id)
 	else
 		name = "MULTIACTIONBAR1BUTTON"..(id-60);
 	end
-	local key = GetBindingKey(name);
+	local key = API_GetBindingKey(name);
 --[[	if (not key) then
 		DEFAULT_CHAT_FRAME:AddMessage(id.."=>"..name.." introuvable")
 	else
@@ -108,20 +108,20 @@ end

 -- Get the action id that match a spell id
 function OvaleActionBar:GetForSpell(spellId)
-	return actionSpell[spellId]
+	return self_actionSpell[spellId]
 end

 -- Get the action id that match a macro id
 function OvaleActionBar:GetForMacro(macroId)
-	return actionMacro[macroId]
+	return self_actionMacro[macroId]
 end

 -- Get the action id that match an item id
 function OvaleActionBar:GetForItem(itemId)
-	return actionItem[itemId]
+	return self_actionItem[itemId]
 end

 function OvaleActionBar:GetBinding(actionId)
-	return keybind[actionId]
+	return self_keybind[actionId]
 end
 --</public-static-methods>
diff --git a/OvaleAura.lua b/OvaleAura.lua
index 70aee02..28a83ce 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -20,23 +20,22 @@ local OvaleGUID = Ovale.OvaleGUID
 local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvalePool = Ovale.OvalePool

-local baseDamageMultiplier = 1
-local playerGUID = nil
-local auraPool = OvalePool:NewPool("OvaleAura_auraPool")
-local OvaleAura_aura = {}
-local OvaleAura_serial = 0
-
 local pairs = pairs
 local select = select
 local strfind = string.find
-local wipe = wipe
-local UnitAura = UnitAura
-local UnitGUID = UnitGUID
+local API_UnitAura = UnitAura
+local API_UnitGUID = UnitGUID
+
+local self_baseDamageMultiplier = 1
+local self_playerGUID = nil
+local self_pool = OvalePool:NewPool("OvaleAura_pool")
+local self_aura = {}
+local self_serial = 0
 --</private-static-properties>

 --<private-static-methods>
-function AddAura(unitGUID, spellId, unitCaster, icon, count, debuffType, duration, expirationTime, isStealable, name, value)
-	local auraList = OvaleAura_aura[unitGUID]
+local function AddAura(unitGUID, spellId, unitCaster, icon, count, debuffType, duration, expirationTime, isStealable, name, value)
+	local auraList = self_aura[unitGUID]
 	if not auraList[spellId] then
 		auraList[spellId] = {}
 	end
@@ -47,21 +46,21 @@ function AddAura(unitGUID, spellId, unitCaster, icon, count, debuffType, duratio
 	local aura
 	if mine then
 		if not auraList[spellId].mine then
-			aura = auraPool:Get()
+			aura = self_pool:Get()
 			aura.gain = Ovale.now
 			auraList[spellId].mine = aura
 		end
 		aura = auraList[spellId].mine
 	else
 		if not auraList[spellId].other then
-			aura = auraPool:Get()
+			aura = self_pool:Get()
 			aura.gain = Ovale.now
 			auraList[spellId].other = aura
 		end
 		aura = auraList[spellId].other
 	end

-	aura.serial = OvaleAura_serial
+	aura.serial = self_serial
 	if count == 0 then
 		count = 1
 	end
@@ -86,18 +85,18 @@ function AddAura(unitGUID, spellId, unitCaster, icon, count, debuffType, duratio
 	end
 end

-function RemoveAurasForGUID(guid)
+local function RemoveAurasForGUID(guid)
 	-- Return all auras for the given GUID to the aura pool.
-	if not guid or not OvaleAura_aura[guid] then return end
+	if not guid or not self_aura[guid] then return end
 	Ovale:DebugPrint("aura", "Removing auras for guid " .. guid)
-	for spellId, whoseTable in pairs(OvaleAura_aura[guid]) do
+	for spellId, whoseTable in pairs(self_aura[guid]) do
 		for whose, aura in pairs(whoseTable) do
 			whoseTable[whose] = nil
-			auraPool:Release(aura)
+			self_pool:Release(aura)
 		end
-		OvaleAura_aura[guid][spellId] = nil
+		self_aura[guid][spellId] = nil
 	end
-	OvaleAura_aura[guid] = nil
+	self_aura[guid] = nil

 	local unitId = OvaleGUID:GetUnitId(guid)
 	if unitId then
@@ -108,7 +107,7 @@ end
 function RemoveAurasForMissingUnits()
 	-- Remove all auras from GUIDs that can no longer be referenced by a unit ID,
 	-- i.e., not in the group or not targeted by anyone in the group or focus.
-	for guid in pairs(OvaleAura_aura) do
+	for guid in pairs(self_aura) do
 		if not OvaleGUID:GetUnitId(guid) then
 			RemoveAurasForGUID(guid)
 		end
@@ -118,7 +117,7 @@ end

 --<public-static-methods>
 function OvaleAura:OnEnable()
-	playerGUID = OvaleGUID.player
+	self_playerGUID = OvaleGUID.player
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 	self:RegisterEvent("PLAYER_ENTERING_WORLD")
 	self:RegisterEvent("UNIT_AURA")
@@ -149,9 +148,9 @@ function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 			self:UpdateAuras(unitId, destGUID)
 		end

-		if sourceGUID == playerGUID and (event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REFRESH" or event == "SPELL_AURA_APPLIED_DOSE") then
+		if sourceGUID == self_playerGUID and (event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REFRESH" or event == "SPELL_AURA_APPLIED_DOSE") then
 			if self:GetAuraByGUID(destGUID, spellId, true) then
-				local aura = OvaleAura_aura[destGUID][spellId].mine
+				local aura = self_aura[destGUID][spellId].mine
 				aura.spellHasteMultiplier = OvalePaperDoll:GetSpellHasteMultiplier()
 			end
 		end
@@ -160,12 +159,12 @@ end

 function OvaleAura:PLAYER_ENTERING_WORLD(event)
 	RemoveAurasForMissingUnits()
-	auraPool:Drain()
+	self_pool:Drain()
 end

 function OvaleAura:UNIT_AURA(event, unitId)
 	if unitId == "player" then
-		self:UpdateAuras("player", playerGUID)
+		self:UpdateAuras("player", self_playerGUID)
 	elseif unitId then
 		self:UpdateAuras(unitId)
 	end
@@ -176,7 +175,7 @@ function OvaleAura:Ovale_InactiveUnit(event, guid)
 end

 function OvaleAura:UpdateAuras(unitId, unitGUID)
-	OvaleAura_serial = OvaleAura_serial + 1
+	self_serial = self_serial + 1

 	local damageMultiplier

@@ -184,10 +183,10 @@ function OvaleAura:UpdateAuras(unitId, unitGUID)
 		return
 	end
 	if not unitGUID and unitId == "player" then
-		unitGUID = playerGUID
+		unitGUID = self_playerGUID
 	end
 	if not unitGUID then
-		unitGUID = UnitGUID(unitId)
+		unitGUID = API_UnitGUID(unitId)
 	end
 	if not unitGUID then
 		return
@@ -197,8 +196,8 @@ function OvaleAura:UpdateAuras(unitId, unitGUID)
 		damageMultiplier = 1
 	end

-	if not OvaleAura_aura[unitGUID] then
-		OvaleAura_aura[unitGUID] = {}
+	if not self_aura[unitGUID] then
+		self_aura[unitGUID] = {}
 	end

 	local i = 1
@@ -208,7 +207,7 @@ function OvaleAura:UpdateAuras(unitId, unitGUID)
 	local canApplyAura, isBossDebuff, isCastByPlayer, value1, value2, value3
 	while (true) do
 		name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId,
-			canApplyAura, isBossDebuff, isCastByPlayer, value1, value2, value3 = UnitAura(unitId, i, mode)
+			canApplyAura, isBossDebuff, isCastByPlayer, value1, value2, value3 = API_UnitAura(unitId, i, mode)
 		if not name then
 			if mode == "HELPFUL" then
 				mode = "HARMFUL"
@@ -234,13 +233,13 @@ function OvaleAura:UpdateAuras(unitId, unitGUID)
 	end

 	--Removes expired auras
-	local auraList = OvaleAura_aura[unitGUID]
+	local auraList = self_aura[unitGUID]
 	for spellId,whoseTable in pairs(auraList) do
 		for whose,aura in pairs(whoseTable) do
-			if aura.serial ~= OvaleAura_serial then
-				Ovale:DebugPrint("aura", "Removing "..aura.name.." from "..whose .. ", serial = " ..OvaleAura_serial.. " aura.serial = " ..aura.serial)
+			if aura.serial ~= self_serial then
+				Ovale:DebugPrint("aura", "Removing "..aura.name.." from "..whose .. ", serial = " ..self_serial.. " aura.serial = " ..aura.serial)
 				whoseTable[whose] = nil
-				auraPool:Release(aura)
+				self_pool:Release(aura)
 			end
 		end
 		if not next(whoseTable) then
@@ -251,11 +250,11 @@ function OvaleAura:UpdateAuras(unitId, unitGUID)

 	--Clear unit if all aura have been deleted
 	if not next(auraList) then
-		OvaleAura_aura[unitGUID] = nil
+		self_aura[unitGUID] = nil
 	end

 	if unitId == "player" then
-		baseDamageMultiplier = damageMultiplier
+		self_baseDamageMultiplier = damageMultiplier
 	end

 	Ovale.refreshNeeded[unitId] = true
@@ -267,7 +266,7 @@ function OvaleAura:GetAuraByGUID(guid, spellId, mine, unitId)
 		Ovale:Log(tostring(guid) .. " does not exists in OvaleAura")
 		return nil
 	end
-	local auraTable = OvaleAura_aura[guid]
+	local auraTable = self_aura[guid]
 	if not auraTable then
 		if not unitId then
 			unitId = OvaleGUID:GetUnitId(guid)
@@ -277,7 +276,7 @@ function OvaleAura:GetAuraByGUID(guid, spellId, mine, unitId)
 			return nil
 		end
 		self:UpdateAuras(unitId, guid)
-		auraTable = OvaleAura_aura[guid]
+		auraTable = self_aura[guid]
 		if not auraTable then
 			-- no aura on target
 			Ovale:Log("Target " .. guid .. " has no aura")
@@ -299,11 +298,11 @@ function OvaleAura:GetAuraByGUID(guid, spellId, mine, unitId)
 end

 function OvaleAura:GetAura(unitId, spellId, mine)
-	return self:GetAuraByGUID(UnitGUID(unitId), spellId, mine, unitId)
+	return self:GetAuraByGUID(API_UnitGUID(unitId), spellId, mine, unitId)
 end

 function OvaleAura:GetStealable(unitId)
-	local auraTable = OvaleAura_aura[UnitGUID(unitId)]
+	local auraTable = self_aura[API_UnitGUID(unitId)]
 	if not auraTable then
 		return nil
 	end
@@ -330,7 +329,7 @@ function OvaleAura:GetExpirationTimeOnAnyTarget(spellId, excludingTarget)
 	local starting = nil
 	local count = 0

-	for unitId,auraTable in pairs(OvaleAura_aura) do
+	for unitId,auraTable in pairs(self_aura) do
 		if unitId ~= excludingTarget then
 			if auraTable[spellId] then
 				local aura = auraTable[spellId].mine
@@ -352,12 +351,12 @@ function OvaleAura:GetExpirationTimeOnAnyTarget(spellId, excludingTarget)
 end

 function OvaleAura:GetDamageMultiplier(spellId)
-	local damageMultiplier = baseDamageMultiplier
+	local damageMultiplier = self_baseDamageMultiplier
 	if spellId then
 		local si = OvaleData.spellInfo[spellId]
 		if si and si.damageAura then
-			self:UpdateAuras("player", playerGUID)
-			local auraTable = OvaleAura_aura[playerGUID]
+			self:UpdateAuras("player", self_playerGUID)
+			local auraTable = self_aura[self_playerGUID]
 			if auraTable then
 				for filter, filterInfo in pairs(si.damageAura) do
 					for auraSpellId, multiplier in pairs(filterInfo) do
@@ -373,8 +372,8 @@ function OvaleAura:GetDamageMultiplier(spellId)
 end

 function OvaleAura:Debug()
-	auraPool:Debug()
-	for guid,auraTable in pairs(OvaleAura_aura) do
+	self_pool:Debug()
+	for guid,auraTable in pairs(self_aura) do
 		Ovale:Print("***"..guid)
 		for spellId,whoseTable in pairs(auraTable) do
 			for whose,aura in pairs(whoseTable) do
diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua
index 95e06d7..cf36ef0 100644
--- a/OvaleBestAction.lua
+++ b/OvaleBestAction.lua
@@ -20,12 +20,26 @@ local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvaleStance = Ovale.OvaleStance
 local OvaleState = Ovale.OvaleState

-local floor, ipairs, loadstring, pairs = math.floor, ipairs, loadstring, pairs
-local strfind, tonumber, tostring = string.find, tonumber, tostring
-local GetActionCooldown, GetActionTexture = GetActionCooldown, GetActionTexture
-local GetItemIcon, GetItemCooldown, GetItemSpell, GetSpellInfo = GetItemIcon, GetItemCooldown, GetItemSpell, GetSpellInfo
-local GetSpellTexture, IsActionInRange, IsCurrentAction = GetSpellTexture, IsActionInRange, IsCurrentAction
-local IsItemInRange, IsSpellInRange, IsUsableAction, IsUsableSpell = IsItemInRange, IsSpellInRange, IsUsableAction, IsUsableSpell
+local floor = math.floor
+local ipairs = ipairs
+local loadstring = loadstring
+local pairs = pairs
+local strfind = string.find
+local tonumber = tonumber
+local tostring = tostring
+local API_GetActionCooldown = GetActionCooldown
+local API_GetActionTexture = GetActionTexture
+local API_GetItemIcon = GetItemIcon
+local API_GetItemCooldown = GetItemCooldown
+local API_GetItemSpell = GetItemSpell
+local API_GetSpellInfo = GetSpellInfo
+local API_GetSpellTexture = GetSpellTexture
+local API_IsActionInRange = IsActionInRange
+local API_IsCurrentAction = IsCurrentAction
+local API_IsItemInRange = IsItemInRange
+local API_IsSpellInRange = IsSpellInRange
+local API_IsUsableAction = IsUsableAction
+local API_IsUsableSpell = IsUsableSpell
 --</private-static-properties>

 --<private-static-methods>
@@ -142,21 +156,21 @@ function OvaleBestAction:GetActionInfo(element)

 		local spellName = OvaleData.spellList[spellId]
 		if not spellName then
-			spellName = GetSpellInfo(spellId)
+			spellName = API_GetSpellInfo(spellId)
 		end
-		actionTexture = GetSpellTexture(spellId)
-		actionInRange = IsSpellInRange(spellName, target)
-		actionUsable = IsUsableSpell(spellId)
+		actionTexture = API_GetSpellTexture(spellId)
+		actionInRange = API_IsSpellInRange(spellName, target)
+		actionUsable = API_IsUsableSpell(spellId)
 		actionShortcut = nil
 	elseif (element.func=="macro") then
 		action = OvaleActionBar:GetForMacro(element.params[1])
 		if action then
-			actionTexture = GetActionTexture(action)
-			actionInRange = IsActionInRange(action, target)
-			actionCooldownStart, actionCooldownDuration, actionEnable = GetActionCooldown(action)
-			actionUsable = IsUsableAction(action)
+			actionTexture = API_GetActionTexture(action)
+			actionInRange = API_IsActionInRange(action, target)
+			actionCooldownStart, actionCooldownDuration, actionEnable = API_GetActionCooldown(action)
+			actionUsable = API_IsUsableAction(action)
 			actionShortcut = OvaleActionBar:GetBinding(action)
-			actionIsCurrent = IsCurrentAction(action)
+			actionIsCurrent = API_IsCurrentAction(action)
 		else
 			Ovale:Log("Unknown macro "..element.params[1])
 		end
@@ -173,13 +187,13 @@ function OvaleBestAction:GetActionInfo(element)
 			Ovale:Print("Item "..tostring(itemId))
 		end

-		local spellName = GetItemSpell(itemId)
+		local spellName = API_GetItemSpell(itemId)
 		actionUsable = (spellName~=nil)

 		action = OvaleActionBar:GetForItem(itemId)
-		actionTexture = GetItemIcon(itemId)
-		actionInRange = IsItemInRange(itemId, target)
-		actionCooldownStart, actionCooldownDuration, actionEnable = GetItemCooldown(itemId)
+		actionTexture = API_GetItemIcon(itemId)
+		actionInRange = API_IsItemInRange(itemId, target)
+		actionCooldownStart, actionCooldownDuration, actionEnable = API_GetItemCooldown(itemId)
 		actionShortcut = nil
 		actionIsCurrent = nil
 	elseif element.func=="texture" then
@@ -192,10 +206,10 @@ function OvaleBestAction:GetActionInfo(element)

 	if action then
 		if actionUsable == nil then
-			actionUsable = IsUsableAction(action)
+			actionUsable = API_IsUsableAction(action)
 		end
 		actionShortcut = OvaleActionBar:GetBinding(action)
-		actionIsCurrent = IsCurrentAction(action)
+		actionIsCurrent = API_IsCurrentAction(action)
 	end

 	local cd = OvaleState:GetCD(spellId)
@@ -248,7 +262,7 @@ function OvaleBestAction:Compute(element)
 			if spellId and OvaleData.spellInfo[spellId] and OvaleData.spellInfo[spellId].casttime then
 				element.castTime = OvaleData.spellInfo[spellId].casttime
 			elseif spellId then
-				local spell, rank, icon, cost, isFunnel, powerType, castTime = GetSpellInfo(spellId)
+				local spell, rank, icon, cost, isFunnel, powerType, castTime = API_GetSpellInfo(spellId)
 				if castTime then
 					element.castTime = castTime/1000
 				else
diff --git a/OvaleComboPoints.lua b/OvaleComboPoints.lua
index 64882b7..5d72a20 100644
--- a/OvaleComboPoints.lua
+++ b/OvaleComboPoints.lua
@@ -18,12 +18,12 @@ local OvaleData = Ovale.OvaleData
 local OvaleGUID = Ovale.OvaleGUID
 local OvalePaperDoll = Ovale.OvalePaperDoll

-local GetComboPoints = GetComboPoints
-local UnitGUID = UnitGUID
+local API_GetComboPoints = GetComboPoints
+local API_UnitGUID = UnitGUID
 local MAX_COMBO_POINTS = MAX_COMBO_POINTS

-local playerGUID = nil
-local targetGUID = nil
+local self_playerGUID = nil
+local self_targetGUID = nil
 --</private-static-properties>

 --<public-static-properties>
@@ -32,7 +32,7 @@ OvaleComboPoints.combo = 0

 --<public-static-methods>
 function OvaleComboPoints:OnEnable()
-	playerGUID = OvaleGUID.player
+	self_playerGUID = OvaleGUID.player
 	if OvalePaperDoll.class == "ROGUE" or OvalePaperDoll.class == "DRUID" then
 		self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 		self:RegisterEvent("PLAYER_ENTERING_WORLD")
@@ -64,7 +64,7 @@ the number of extra combo points to add, e.g., critcombo=1.
 --]]
 function OvaleComboPoints:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 	local _, event, _, sourceGUID, _, _, _,	destGUID = ...
-	if sourceGUID == playerGUID and destGUID == targetGUID then
+	if sourceGUID == self_playerGUID and destGUID == self_targetGUID then
 		if event == "SPELL_DAMAGE" then
 			local spellId, _, _, _, _, _, _, _, _, critical = select(12, ...)
 			local si = OvaleData.spellInfo[spellId]
@@ -83,7 +83,7 @@ function OvaleComboPoints:PLAYER_ENTERING_WORLD(event)
 end

 function OvaleComboPoints:PLAYER_TARGET_CHANGED(event)
-	targetGUID = UnitGUID("target")
+	self_targetGUID = API_UnitGUID("target")
 	self:Refresh()
 end

@@ -95,10 +95,10 @@ function OvaleComboPoints:UNIT_COMBO_POINTS(event, ...)
 end

 function OvaleComboPoints:Refresh()
-	self.combo = GetComboPoints("player") or 0
+	self.combo = API_GetComboPoints("player") or 0
 end

 function OvaleComboPoints:Debug()
-	Ovale:Print("Player has " .. self.combo .. " combo points on target " ..targetGUID.. ".")
+	Ovale:Print("Player has " .. self.combo .. " combo points on target " ..self_targetGUID.. ".")
 end
 --</public-static-methods>
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index 1cdaead..c914355 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -22,21 +22,30 @@ local OvalePool = Ovale.OvalePool
 local OvaleScripts = Ovale.OvaleScripts
 local OvaleStance = Ovale.OvaleStance

-local node = {}
-local nodePool = OvalePool:NewPool("OvaleCompile_nodePool")
-local defines = {}
-local customFunctions = {}
-local missingSpellList = {}
-
--- Whether to trigger a script compilation if items or stances change.
-local compileOnItems = false
-local compileOnStances = false
-
-local ipairs, pairs, tonumber = ipairs, pairs, tonumber
-local strfind, strgmatch, strgsub = string.find, string.gmatch, string.gsub
-local strlen, strlower, strmatch, strsub = string.len, string.lower, string.match, string.sub
+local ipairs = ipairs
+local pairs = pairs
+local tonumber = tonumber
+local strfind = string.find
+local strgmatch = string.gmatch
+local strgsub = string.gsub
+local strlen = string.len
+local strlower = string.lower
+local strmatch = string.match
+local strsub = string.sub
 local tinsert = table.insert
 local tremove = table.remove
+local wipe = table.wipe
+local API_GetSpellInfo = GetSpellInfo
+
+local self_node = {}
+local self_pool = OvalePool:NewPool("OvaleCompile_pool")
+local self_defines = {}
+local self_customFunctions = {}
+local self_missingSpellList = {}
+
+-- Whether to trigger a script compilation if items or stances change.
+local self_compileOnItems = false
+local self_compileOnStances = false
 --</private-static-properties>

 --<public-static-properties>
@@ -45,9 +54,9 @@ OvaleCompile.masterNodes = {}
 --</public-static-properties>

 --<private-static-methods>
-local function AddNode(newNode)
-	tinsert(node, newNode)
-	return "node" .. #node
+local function AddNode(node)
+	tinsert(self_node, node)
+	return "node" .. #self_node
 end

 local function ParseParameters(params)
@@ -100,7 +109,7 @@ local function TestConditions(paramList)
 		return false
 	end
 	if paramList.if_stance then
-		compileOnStances = true
+		self_compileOnStances = true
 		if not OvaleStance:IsStance(paramList.if_stance) then
 			return false
 		end
@@ -144,7 +153,7 @@ local function TestConditions(paramList)
 	end
 	if paramList.itemset and paramList.itemcount then
 		local equippedCount = OvaleEquipement:GetArmorSetCount(paramList.itemset)
-		compileOnItems = true
+		self_compileOnItems = true
 		if equippedCount < paramList.itemcount then
 			return false
 		end
@@ -153,19 +162,19 @@ local function TestConditions(paramList)
 end

 local function ParseTime(value)
-	local newNode = nodePool:Get()
-	newNode.type = "time"
-	newNode.value = tonumber(value)
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "time"
+	node.value = tonumber(value)
+	return AddNode(node)
 end

 local function ParseNumber(dummy, value)
-	local newNode = nodePool:Get()
-	newNode.type = "value"
-	newNode.value = tonumber(value)
-	newNode.origin = 0
-	newNode.rate = 0
-	return dummy..AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "value"
+	node.value = tonumber(value)
+	node.origin = 0
+	node.rate = 0
+	return dummy..AddNode(node)
 end

 local function ParseFunction(prefix, func, params)
@@ -183,17 +192,17 @@ local function ParseFunction(prefix, func, params)
 		end
 	end

-	if customFunctions[func] then
-		return customFunctions[func]
+	if self_customFunctions[func] then
+		return self_customFunctions[func]
 	end

 	func = strlower(func)

-	local newNode = nodePool:Get()
-	newNode.type = "function"
-	newNode.func = func
-	newNode.params = paramList
-	local newNodeName = AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "function"
+	node.func = func
+	node.params = paramList
+	local nodeName = AddNode(node)

 	local mine = true
 	if paramList.any then
@@ -206,15 +215,15 @@ local function ParseFunction(prefix, func, params)
 		-- is a variant of a spell with the same name as one already in the
 		-- spellbook.  If it is, then add that variant spell ID to our spellList.
 		if OvaleCondition.spellbookConditions[func] then
-			if not OvaleData.spellList[spellId] and not missingSpellList[spellId] then
+			if not OvaleData.spellList[spellId] and not self_missingSpellList[spellId] then
 				local spellName
 				if type(spellId) == "number" then
-					spellName = GetSpellInfo(spellId)
+					spellName = API_GetSpellInfo(spellId)
 				end
 				if spellName then
-					if spellName == GetSpellInfo(spellName) then
+					if spellName == API_GetSpellInfo(spellName) then
 						Ovale:DebugPrint("missing_spells", "Learning spell "..tostring(spellName).." with ID "..spellId)
-						missingSpellList[spellId] = spellName
+						self_missingSpellList[spellId] = spellName
 					end
 				else
 					Ovale:DebugPrint("unknown_spells", "Unknown spell with ID "..spellId)
@@ -223,7 +232,7 @@ local function ParseFunction(prefix, func, params)
 		end
 	end

-	return newNodeName
+	return nodeName
 end

 local function ParseSpellAddDebuff(params)
@@ -328,106 +337,106 @@ local function ParseItemList(name, params)
 end

 local function ParseIf(a, b)
-	local newNode = nodePool:Get()
-	newNode.type = "if"
-	newNode.a = node[tonumber(a)]
-	newNode.b = node[tonumber(b)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "if"
+	node.a = self_node[tonumber(a)]
+	node.b = self_node[tonumber(b)]
+	return AddNode(node)
 end

 local function ParseUnless(a, b)
-	local newNode = nodePool:Get()
-	newNode.type = "unless"
-	newNode.a = node[tonumber(a)]
-	newNode.b = node[tonumber(b)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "unless"
+	node.a = self_node[tonumber(a)]
+	node.b = self_node[tonumber(b)]
+	return AddNode(node)
 end

 local function ParseWait(a)
-	local newNode = nodePool:Get()
-	newNode.type = "wait"
-	newNode.a = node[tonumber(a)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "wait"
+	node.a = self_node[tonumber(a)]
+	return AddNode(node)
 end

 local function ParseAnd(a,b)
-	local newNode = nodePool:Get()
-	newNode.type = "and"
-	newNode.a = node[tonumber(a)]
-	newNode.b = node[tonumber(b)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "and"
+	node.a = self_node[tonumber(a)]
+	node.b = self_node[tonumber(b)]
+	return AddNode(node)
 end

 local function ParseNot(a)
-	local newNode = nodePool:Get()
-	newNode.type = "not"
-	newNode.a = node[tonumber(a)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "not"
+	node.a = self_node[tonumber(a)]
+	return AddNode(node)
 end

 local function ParseBefore(t,a)
-	local newNode = nodePool:Get()
-	newNode.type = "before"
-	newNode.time = node[tonumber(t)]
-	newNode.a = node[tonumber(a)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "before"
+	node.time = self_node[tonumber(t)]
+	node.a = self_node[tonumber(a)]
+	return AddNode(node)
 end

 local function ParseAfter(t,a)
-	local newNode = nodePool:Get()
-	newNode.type = "after"
-	newNode.time = node[tonumber(t)]
-	newNode.a = node[tonumber(a)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "after"
+	node.time = self_node[tonumber(t)]
+	node.a = self_node[tonumber(a)]
+	return AddNode(node)
 end

 local function ParseBetween(a,b)
-	local newNode = nodePool:Get()
-	newNode.type = "between"
-	newNode.a = node[tonumber(a)]
-	newNode.b = node[tonumber(b)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "between"
+	node.a = self_node[tonumber(a)]
+	node.b = self_node[tonumber(b)]
+	return AddNode(node)
 end

 local function ParseFromUntil(a,b)
-	local newNode = nodePool:Get()
-	newNode.type = "fromuntil"
-	newNode.a = node[tonumber(a)]
-	newNode.b = node[tonumber(b)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "fromuntil"
+	node.a = self_node[tonumber(a)]
+	node.b = self_node[tonumber(b)]
+	return AddNode(node)
 end

 local function ParseOr(a,b)
-	local newNode = nodePool:Get()
-	newNode.type = "or"
-	newNode.a = node[tonumber(a)]
-	newNode.b = node[tonumber(b)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "or"
+	node.a = self_node[tonumber(a)]
+	node.b = self_node[tonumber(b)]
+	return AddNode(node)
 end

 local function ParseOp(a, op, b)
-	local newNode = nodePool:Get()
-	newNode.type = "operator"
-	newNode.operator = op
-	newNode.a = node[tonumber(a)]
-	newNode.b = node[tonumber(b)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "operator"
+	node.operator = op
+	node.a = self_node[tonumber(a)]
+	node.b = self_node[tonumber(b)]
+	return AddNode(node)
 end

 local function ParseCompare(comp,t,a)
-	local newNode = nodePool:Get()
-	newNode.type = "compare"
-	newNode.comparison = comp
-	newNode.time = node[tonumber(t)]
-	newNode.b = node[tonumber(b)]
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "compare"
+	node.comparison = comp
+	node.time = self_node[tonumber(t)]
+	node.b = self_node[tonumber(b)]
+	return AddNode(node)
 end

 local function ParseGroup(text)
 	local nodes = {}

 	for w in strgmatch(text, "node(%d+)") do
-		tinsert(nodes, node[tonumber(w)])
+		tinsert(nodes, self_node[tonumber(w)])
 	end

 	text = strgsub(text, "node%d+", "")
@@ -437,10 +446,10 @@ local function ParseGroup(text)
 		return nil
 	end

-	local newNode = nodePool:Get()
-	newNode.type = "group"
-	newNode.nodes = nodes
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "group"
+	node.nodes = nodes
+	return AddNode(node)
 end

 local function ParseAddListItem(list, item, text, params)
@@ -474,19 +483,19 @@ local function ParseAddCheckBox(item, text, params)
 end

 local function ParseDefine(key, value)
-	defines[key] = value
+	self_defines[key] = value
 	return ""
 end

 local function ReplaceDefine(key)
-	return defines[key]
+	return self_defines[key]
 end

 local function ParseLua(text)
-	local newNode = nodePool:Get()
-	newNode.type = "lua"
-	newNode.lua = strsub(text, 2, strlen(text)-1)
-	return AddNode(newNode)
+	local node = self_pool:Get()
+	node.type = "lua"
+	node.lua = strsub(text, 2, strlen(text)-1)
+	return AddNode(node)
 end

 local function ParseCommands(text)
@@ -570,7 +579,7 @@ local function ParseAddIcon(params, text, secure)
 	-- On convertit le numéro de node en node
 	local masterNode = ParseCommands(text)
 	if not masterNode then return nil end
-	masterNode = node[tonumber(masterNode)]
+	masterNode = self_node[tonumber(masterNode)]
 	masterNode.params = ParseParameters(params)
 	masterNode.secure = secure
 	if not TestConditions(masterNode.params) then
@@ -653,30 +662,30 @@ local function CompileDeclarations(text)
 end

 local function CompileScript(text)
-	compileOnItems = false
-	compileOnStances = false
+	self_compileOnItems = false
+	self_compileOnStances = false
 	Ovale.bug = false

-	wipe(defines)
-	wipe(missingSpellList)
+	wipe(self_defines)
+	wipe(self_missingSpellList)

 	-- Return all existing nodes to the node pool.
-	local oldNode
+	local node
 	while true do
-		oldNode = tremove(node)
-		if not oldNode then break end
-		nodePool:Release(oldNode)
+		node = tremove(self_node)
+		if not node then break end
+		self_pool:Release(node)
 	end
-	wipe(node)
+	wipe(self_node)

 	text = CompileComments(text)
 	text = CompileDeclarations(text)
 	text = CompileInputs(text)

 	for p,t in strgmatch(text, "AddFunction%s+(%w+)%s*(%b{})") do
-		local newNode = ParseCommands(t)
-		if newNode then
-			customFunctions[p] = "node"..newNode
+		local node = ParseCommands(t)
+		if node then
+			self_customFunctions[p] = "node"..node
 		end
 	end

@@ -685,21 +694,21 @@ local function CompileScript(text)

 	-- On compile les AddIcon
 	for p,t in strgmatch(text, "AddActionIcon%s*(.-)%s*(%b{})") do
-		local newNode = ParseAddIcon(p,t,true)
-		if newNode then
-			tinsert(masterNodes, newNode)
+		local node = ParseAddIcon(p,t,true)
+		if node then
+			tinsert(masterNodes, node)
 		end
 	end

 	for p,t in strgmatch(text, "AddIcon%s*(.-)%s*(%b{})") do
-		local newNode = ParseAddIcon(p,t)
-		if newNode then
-			tinsert(masterNodes, newNode)
+		local node = ParseAddIcon(p,t)
+		if node then
+			tinsert(masterNodes, node)
 		end
 	end

 	-- Add any missing spells found while compiling the script into the spellbook.
-	for k, v in pairs(missingSpellList) do
+	for k, v in pairs(self_missingSpellList) do
 		OvaleData.spellList[k] = v
 	end
 end
@@ -726,7 +735,7 @@ function OvaleCompile:OnDisable()
 	self:UnregisterMessage("Ovale_SpellsChanged")
 	self:UnregisterMessage("Ovale_StanceChanged")
 	self:UnregisterMessage("Ovale_TalentsChanged")
-	nodePool:Drain()
+	self_pool:Drain()
 end

 function OvaleCompile:EventHandler(event)
@@ -735,14 +744,14 @@ function OvaleCompile:EventHandler(event)
 end

 function OvaleCompile:Ovale_EquipmentChanged(event)
-	if compileOnItems then
+	if self_compileOnItems then
 		self:EventHandler(event)
 	end
 	Ovale.refreshNeeded.player = true
 end

 function OvaleCompile:Ovale_StanceChanged(event)
-	if compileOnStances then
+	if self_compileOnStances then
 		self:EventHandler(event)
 	end
 	Ovale.refreshNeeded.player = true
@@ -758,7 +767,7 @@ function OvaleCompile:Compile()
 end

 function OvaleCompile:Debug()
-	nodePool:Debug()
+	self_pool:Debug()
 	Ovale:Print(self:DebugNode(self.masterNodes[1]))
 end

diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index 71e7559..57ec64c 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -25,10 +25,55 @@ local OvaleStance = Ovale.OvaleStance
 local OvaleState = Ovale.OvaleState
 local OvaleSwing = Ovale.OvaleSwing

-local runes = {}
-local runesCD = {}
+local floor = floor
+local pairs = pairs
+local select = select
+local strfind = string.dinf
+local tostring = tostring
+local API_GetBuildInfo = GetBuildInfo
+local API_GetItemCooldown = GetItemCooldown
+local API_GetItemCount = GetItemCount
+local API_GetNumTrackingTypes = GetNumTrackingTypes
+local API_GetSpellCharges = GetSpellCharges
+local API_GetSpellInfo = GetSpellInfo
+local API_GetTotemInfo = GetTotemInfo
+local API_GetTrackingInfo = GetTrackingInfo
+local API_GetUnitSpeed = GetUnitSpeed
+local API_GetWeaponEnchantInfo = GetWeaponEnchantInfo
+local API_HasFullControl = HasFullControl
+local API_IsHarmfulSpell = IsHarmfulSpell
+local API_IsHelpfulSpell = IsHelpfulSpell
+local API_IsSpellInRange = IsSpellInRange
+local API_IsStealthed = IsStealthed
+local API_IsUsableSpell = IsUsableSpell
+local API_UnitCastingInfo = UnitCastingInfo
+local API_UnitChannelInfo = UnitChannelInfo
+local API_UnitClass = UnitClass
+local API_UnitClassification = UnitClassification
+local API_UnitCreatureFamily = UnitCreatureFamily
+local API_UnitCreatureType = UnitCreatureType
+local API_UnitDebuff = UnitDebuff
+local API_UnitDetailedThreatSituation = UnitDetailedThreatSituation
+local API_UnitExists = UnitExists
+local API_UnitGUID = UnitGUID
+local API_UnitHealth = UnitHealth
+local API_UnitHealthMax = UnitHealthMax
+local API_UnitIsDead = UnitIsDead
+local API_UnitIsFriend = UnitIsFriend
+local API_UnitIsUnit = UnitIsUnit
+local API_UnitLevel = UnitLevel
+local API_UnitPower = UnitPower
+local API_UnitPowerMax = UnitPowerMax
+
+local self_runes = {}
+local self_runesCD = {}
+
+local self_lastSaved = {}
+local self_savedHealth = {}
+local self_targetGUID = {}
+local self_lastSPD = {}

-local runeType =
+local OVALE_RUNETYPE =
 {
 	blood = 1,
 	unholy = 2,
@@ -36,7 +81,7 @@ local runeType =
 	death = 4
 }

-local totemType =
+local OVALE_TOTEMTYPE =
 {
 	-- Death Knights
 	ghoul = 1,
@@ -48,31 +93,13 @@ local totemType =
 	water = 3,
 	air = 4
 }
-
-local lastSaved = {}
-local savedHealth = {}
-local targetGUID = {}
-local lastSPD = {}
-
-local floor, pairs, select, strfind, tostring = math.floor, pairs, select, string.find, tostring
-local GetItemCooldown, GetItemCount = GetItemCooldown, GetItemCount
-local GetSpellCharges = GetSpellCharges
-local GetSpellInfo, GetTotemInfo, GetTrackingInfo = GetSpellInfo, GetTotemInfo, GetTrackingInfo
-local GetUnitSpeed, HasFullControl, IsSpellInRange = GetUnitSpeed, HasFullControl, IsSpellInRange
-local IsStealthed, IsUsableSpell = IsStealthed, IsUsableSpell
-local UnitCastingInfo, UnitChannelInfo, UnitClass = UnitCastingInfo, UnitChannelInfo, UnitClass
-local UnitClassification, UnitCreatureFamily, UnitCreatureType = UnitClassification, UnitCreatureFamily, UnitCreatureType
-local UnitDebuff, UnitDetailedThreatSituation, UnitExists = UnitDebuff, UnitDetailedThreatSituation, UnitExists
-local UnitHealth, UnitHealthMax, UnitIsDead = UnitHealth, UnitHealthMax, UnitIsDead
-local UnitIsFriend, UnitIsUnit, UnitLevel = UnitIsFriend, UnitIsUnit, UnitLevel
-local UnitPower, UnitPowerMax = UnitPower, UnitPowerMax
 --</private-static-properties>

 --<private-static-methods>
 local function isDebuffInList(list)
 	local i=1;
 	while (true) do
-		local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId =  UnitDebuff("player", i);
+		local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId =  API_UnitDebuff("player", i);
 		if (not name) then
 			break
 		end
@@ -184,7 +211,7 @@ end
 -- Returns nil if the debuff is not present
 local function getOtherAura(spellId, suppTime, excludingTarget)
 	if excludingTarget then
-		excludingTarget = UnitGUID(excludingTarget)
+		excludingTarget = API_UnitGUID(excludingTarget)
 	end
 	return OvaleState:GetExpirationTimeOnAnyTarget(spellId, excludingTarget)
 end
@@ -193,7 +220,7 @@ local function GetRuneCount(type, death)
 	local ret = 0
 	local atTime = nil
 	local rate = nil
-	type = runeType[type]
+	type = OVALE_RUNETYPE[type]
 	for i=1,6 do
 		local rune = OvaleState.state.rune[i]
 		if rune and (rune.type == type or (rune.type == 4 and death==1)) then
@@ -220,31 +247,31 @@ local function GetRune(condition)
 	local maxCD = nil

 	for i=1,4 do
-		runes[i] = 0
-		runesCD[i] = 0
+		self_runes[i] = 0
+		self_runesCD[i] = 0
 	end

 	local k=1
 	while true do
-		local type = runeType[condition[k*2-1]]
+		local type = OVALE_RUNETYPE[condition[k*2-1]]
 		if not type then
 			break
 		end
 		local howMany = condition[k*2]
-		runes[type] = runes[type] + howMany
+		self_runes[type] = self_runes[type] + howMany
 		k = k + 1
 	end

 	for i=1,6 do
 		local rune = OvaleState.state.rune[i]
 		if rune then
-			if runes[rune.type] > 0 then
-				runes[rune.type] = runes[rune.type] - 1
-				if rune.cd > runesCD[rune.type] then
-					runesCD[rune.type] = rune.cd
+			if self_runes[rune.type] > 0 then
+				self_runes[rune.type] = self_runes[rune.type] - 1
+				if rune.cd > self_runesCD[rune.type] then
+					self_runesCD[rune.type] = rune.cd
 				end
-			elseif rune.cd < runesCD[rune.type] then
-				runesCD[rune.type] = rune.cd
+			elseif rune.cd < self_runesCD[rune.type] then
+				self_runesCD[rune.type] = rune.cd
 			end
 		end
 	end
@@ -254,14 +281,14 @@ local function GetRune(condition)
 			local rune = OvaleState.state.rune[i]
 			if rune and rune.type == 4 then
 				for j=1,3 do
-					if runes[j]>0 then
-						runes[j] = runes[j] - 1
-						if rune.cd > runesCD[j] then
-							runesCD[j] = rune.cd
+					if self_runes[j]>0 then
+						self_runes[j] = self_runes[j] - 1
+						if rune.cd > self_runesCD[j] then
+							self_runesCD[j] = rune.cd
 						end
 						break
-					elseif rune.cd < runesCD[j] then
-						runesCD[j] = rune.cd
+					elseif rune.cd < self_runesCD[j] then
+						self_runesCD[j] = rune.cd
 						break
 					end
 				end
@@ -270,11 +297,11 @@ local function GetRune(condition)
 	end

 	for i=1,4 do
-		if runes[i]> 0 then
+		if self_runes[i]> 0 then
 			return nil
 		end
-		if not maxCD or runesCD[i]>maxCD then
-			maxCD = runesCD[i]
+		if not maxCD or self_runesCD[i]>maxCD then
+			maxCD = self_runesCD[i]
 		end
 	end
 	return maxCD
@@ -387,36 +414,36 @@ end

 local function getTargetDead(target)
 	local second = math.floor(OvaleState.maintenant)
-	if targetGUID[target] ~=UnitGUID(target) then
-		lastSaved[target] = nil
-		targetGUID[target] = UnitGUID(target)
-		savedHealth[target] = {}
+	if self_targetGUID[target] ~= API_UnitGUID(target) then
+		self_lastSaved[target] = nil
+		self_targetGUID[target] = API_UnitGUID(target)
+		self_savedHealth[target] = {}
 	end
-	local newHealth = UnitHealth(target)
+	local newHealth = API_UnitHealth(target)
 	if newHealth then
 		Ovale:Log("newHealth = " .. newHealth)
 	end
-	if UnitHealthMax(target) <= 2 then
+	if API_UnitHealthMax(target) <= 2 then
 		Ovale:Log("Training Dummy, return in the future")
 		return OvaleState.currentTime + 3600
 	end
-	if second~=lastSaved[target] and targetGUID[target] then
-		lastSaved[target] = second
+	if second~=self_lastSaved[target] and self_targetGUID[target] then
+		self_lastSaved[target] = second
 		local mod10 = second % 10
-		local prevHealth = savedHealth[target][mod10]
-		savedHealth[target][mod10] = newHealth
+		local prevHealth = self_savedHealth[target][mod10]
+		self_savedHealth[target][mod10] = newHealth
 		if prevHealth and prevHealth>newHealth then
-			lastSPD[target] = 10/(prevHealth-newHealth)
-			if lastSPD[target] > 0 then
-				Ovale:Log("dps = " .. (1/lastSPD[target]))
+			self_lastSPD[target] = 10/(prevHealth-newHealth)
+			if self_lastSPD[target] > 0 then
+				Ovale:Log("dps = " .. (1/self_lastSPD[target]))
 			end
 		end
 	end
-	if not lastSPD[target] or lastSPD[target]<=0 then
+	if not self_lastSPD[target] or self_lastSPD[target]<=0 then
 		return OvaleState.currentTime + 3600
 	end
 	-- Rough estimation
-	local duration = newHealth * lastSPD[target]
+	local duration = newHealth * self_lastSPD[target]
 	--if duration < 10000 then
 		return OvaleState.maintenant + duration
 	--else
@@ -428,7 +455,7 @@ local function isSameSpell(spellIdA, spellIdB, spellNameB)
 	if spellIdB then
 		return spellIdA == spellIdB
 	elseif spellIdA and spellNameB then
-		return GetSpellInfo(spellIdA) == spellNameB
+		return API_GetSpellInfo(spellIdA) == spellNameB
 	else
 		return false
 	end
@@ -484,7 +511,7 @@ OvaleCondition.spellbookConditions = { spell = true }
 	--[[AfterWhiteHit = function(condition)
 		local debut = OvaleSwing.starttime
 		local fin = OvaleSwing.duration + debut
-		local maintenant = GetTime()
+		local maintenant = API_GetTime()
 		if (maintenant-debut<condition[1]) then
 			return 0
 		elseif (maintenant<fin-0.1) then
@@ -762,9 +789,9 @@ OvaleCondition.conditions.casting = function(condition)
 		ending = OvaleState.endCast
 		castSpellId = OvaleState.currentSpellId
 	else
-		castSpellName, _, _, _, start, ending = UnitCastingInfo(target)
+		castSpellName, _, _, _, start, ending = API_UnitCastingInfo(target)
 		if not castSpellName then
-			castSpellName, _, _, _, start, ending = UnitChannelInfo(target)
+			castSpellName, _, _, _, start, ending = API_UnitChannelInfo(target)
 		end
 	end
 	if not castSpellId and not castSpellName then
@@ -788,18 +815,18 @@ OvaleCondition.conditions.casting = function(condition)
 		return nil
 	elseif spellId == "harmful" then
 		if not castSpellName then
-			castSpellName = GetSpellInfo(castSpellId)
+			castSpellName = API_GetSpellInfo(castSpellId)
 		end
-		if IsHarmfulSpell(castSpellName) then
+		if API_IsHarmfulSpell(castSpellName) then
 			return start, ending
 		else
 			return nil
 		end
 	elseif spellId == "helpful" then
 		if not castSpellName then
-			castSpellName = GetSpellInfo(castSpellId)
+			castSpellName = API_GetSpellInfo(castSpellId)
 		end
-		if IsHelpfulSpell(castSpellName) then
+		if API_IsHelpfulSpell(castSpellName) then
 			return start, ending
 		else
 			return nil
@@ -841,7 +868,7 @@ end
 -- @return A boolean value for the result of the comparison.

 OvaleCondition.conditions.charges = function(condition)
-	local currentCharges, maxCharges, timeLastCast, cooldownDuration = GetSpellCharges(condition[1])
+	local currentCharges, maxCharges, timeLastCast, cooldownDuration = API_GetSpellCharges(condition[1])
 	return compare(currentCharges, condition[2], condition[3])
 end

@@ -916,7 +943,7 @@ end
 -- if target.Class(PRIEST) Spell(cheap_shot)

 OvaleCondition.conditions.class = function(condition)
-	local loc, noloc = UnitClass(getTarget(condition.target))
+	local loc, noloc = API_UnitClass(getTarget(condition.target))
 	return testbool(noloc == condition[1], condition[2])
 end

@@ -938,10 +965,10 @@ end
 OvaleCondition.conditions.classification = function(condition)
 	local classification
 	local target = getTarget(condition.target)
-	if UnitLevel(target)==-1 then
+	if API_UnitLevel(target) == -1 then
 		classification = "worldboss"
 	else
-		classification = UnitClassification(target);
+		classification = API_UnitClassification(target);
 		if (classification == "rareelite") then
 			classification = "elite"
 		elseif (classification == "rare") then
@@ -1006,7 +1033,7 @@ end
 --     Spell(hibernate)

 OvaleCondition.conditions.creaturefamily = function(condition)
-	return testbool(UnitCreatureFamily(getTarget(condition.target)) == LBCT[condition[1]], condition[2])
+	return testbool(API_UnitCreatureFamily(getTarget(condition.target)) == LBCT[condition[1]], condition[2])
 end

 --- Test if the target is any of the listed creature types.
@@ -1024,7 +1051,7 @@ end
 --     Spell(polymorph)

 OvaleCondition.conditions.creaturetype = function(condition)
-	local creatureType = UnitCreatureType(getTarget(condition.target))
+	local creatureType = API_UnitCreatureType(getTarget(condition.target))
 	for _,v in pairs(condition) do
 		if (creatureType == LBCT[v]) then
 			return 0
@@ -1242,7 +1269,7 @@ end
 -- if pet.Exists(no) Spell(summon_imp)

 OvaleCondition.conditions.exists = function(condition)
-	return testbool(UnitExists(getTarget(condition.target)) == 1, condition[1])
+	return testbool(API_UnitExists(getTarget(condition.target)) == 1, condition[1])
 end

 --- A condition that always returns false.
@@ -1326,7 +1353,7 @@ end
 -- if HasFullControl(no) Spell(barkskin)

 OvaleCondition.conditions.hasfullcontrol = function(condition)
-	return testbool(HasFullControl(), condition[1])
+	return testbool(API_HasFullControl(), condition[1])
 end

 --- Test if the player has a shield equipped.
@@ -1451,8 +1478,8 @@ end

 OvaleCondition.conditions.inrange = function(condition)
 	--TODO is IsSpellInRange using spell id now?
-	local spellName = GetSpellInfo(condition[1])
-	return testbool(IsSpellInRange(spellName,getTarget(condition.target))==1,condition[2])
+	local spellName = API_GetSpellInfo(condition[1])
+	return testbool(API_IsSpellInRange(spellName, getTarget(condition.target)) == 1,condition[2])
 end

 --- Get the cooldown time in seconds of an item, e.g., trinket.
@@ -1465,7 +1492,7 @@ end
 --     Spell(berserk_cat)

 OvaleCondition.conditions.itemcooldown = function(condition)
-	local actionCooldownStart, actionCooldownDuration, actionEnable = GetItemCooldown(condition[1])
+	local actionCooldownStart, actionCooldownDuration, actionEnable = API_GetItemCooldown(condition[1])
 	return 0, nil, actionCooldownDuration, actionCooldownStart, -1
 end

@@ -1482,7 +1509,7 @@ end
 -- if ItemCount(mana_gem equal 0) Spell(conjure_mana_gem)

 OvaleCondition.conditions.itemcount = function(condition)
-	return compare(GetItemCount(condition[1]), condition[2], condition[3])
+	return compare(API_GetItemCount(condition[1]), condition[2], condition[3])
 end

 --- Get the current number of charges of the given item in the player's inventory.
@@ -1499,7 +1526,7 @@ end
 --     Spell(conjure_mana_gem)

 OvaleCondition.conditions.itemcharges = function(condition)
-	return compare(GetItemCount(condition[1], false, true), condition[2], condition[3])
+	return compare(API_GetItemCount(condition[1], false, true), condition[2], condition[3])
 end

 --- Test if the target's primary aggro is on the player.
@@ -1518,7 +1545,7 @@ end
 -- if target.IsAggroed() Spell(feign_death)

 OvaleCondition.conditions.isaggroed = function(condition)
-	return testbool(UnitDetailedThreatSituation("player", getTarget(condition.target)), condition[1])
+	return testbool(API_UnitDetailedThreatSituation("player", getTarget(condition.target)), condition[1])
 end

 --- Test if the player is feared.
@@ -1533,7 +1560,7 @@ end

 OvaleCondition.conditions.isfeared = function(condition)
 	local fearSpellList = OvaleData:GetFearSpellList()
-	return testbool(not HasFullControl() and isDebuffInList(fearSpellList), condition[1])
+	return testbool(not API_HasFullControl() and isDebuffInList(fearSpellList), condition[1])
 end

 --- Test if the target is friendly to the player.
@@ -1550,7 +1577,7 @@ end
 -- if target.IsFriend() Spell(healing_touch)

 OvaleCondition.conditions.isfriend = function(condition)
-	return testbool(UnitIsFriend("player", getTarget(condition.target)), condition[1])
+	return testbool(API_UnitIsFriend("player", getTarget(condition.target)), condition[1])
 end

 --- Test if the player is incapacitated.
@@ -1565,7 +1592,7 @@ end

 OvaleCondition.conditions.isincapacitated = function(condition)
 	local incapacitateSpellList = OvaleData:GetIncapacitateSpellList()
-	return testbool(not HasFullControl() and isDebuffInList(incapacitateSpellList), condition[1])
+	return testbool(not API_HasFullControl() and isDebuffInList(incapacitateSpellList), condition[1])
 end

 --- Test if the target is currently casting an interruptible spell.
@@ -1583,9 +1610,9 @@ end

 OvaleCondition.conditions.isinterruptible = function(condition)
 	local target = getTarget(condition.target)
-	local spell, rank, name, icon, start, ending, isTradeSkill, castID, protected = UnitCastingInfo(target)
+	local spell, rank, name, icon, start, ending, isTradeSkill, castID, protected = API_UnitCastingInfo(target)
 	if not spell then
-		spell, rank, name, icon, start, ending, isTradeSkill, protected = UnitChannelInfo(target)
+		spell, rank, name, icon, start, ending, isTradeSkill, protected = API_UnitChannelInfo(target)
 	end
 	return testbool(protected ~= nil and not protected, condition[1])
 end
@@ -1617,7 +1644,7 @@ end

 OvaleCondition.conditions.isstunned = function(condition)
 	local stunSpellList = OvaleData:GetStunSpellList()
-	return testbool(not HasFullControl() and isDebuffInList(stunSpellList), condition[1])
+	return testbool(not API_HasFullControl() and isDebuffInList(stunSpellList), condition[1])
 end

 --- Get the damage done by the most recent damage event for the given spell.
@@ -1782,7 +1809,7 @@ OvaleCondition.conditions.level = function(condition)
 	if target == "player" then
 		level = OvalePaperDoll.level
 	else
-		level = UnitLevel(target)
+		level = API_UnitLevel(target)
 	end
 	return compare(level, condition[1], condition[2])
 end
@@ -1804,7 +1831,7 @@ end

 OvaleCondition.conditions.life = function(condition)
 	local target = getTarget(condition.target)
-	return compare(UnitHealth(target), condition[1], condition[2])
+	return compare(API_UnitHealth(target), condition[1], condition[2])
 end
 OvaleCondition.conditions.health = OvaleCondition.conditions.life

@@ -1825,7 +1852,7 @@ OvaleCondition.conditions.health = OvaleCondition.conditions.life

 OvaleCondition.conditions.lifemissing = function(condition)
 	local target = getTarget(condition.target)
-	return compare(UnitHealthMax(target)-UnitHealth(target), condition[1], condition[2])
+	return compare(API_UnitHealthMax(target) - API_UnitHealth(target), condition[1], condition[2])
 end
 OvaleCondition.conditions.healthmissing = OvaleCondition.conditions.lifemissing

@@ -1847,10 +1874,11 @@ OvaleCondition.conditions.healthmissing = OvaleCondition.conditions.lifemissing
 OvaleCondition.conditions.lifepercent = function(condition)
 	--TODO: use prediction based on the DPS on the target
 	local target = getTarget(condition.target)
-	if UnitHealthMax(target) == nil or UnitHealthMax(target) == 0 then
+	local targetHealthMax = API_UnitHealthMax(target) or 0
+	if targetHealthMax == 0 then
 		return nil
 	end
-	return compare(100*UnitHealth(target)/UnitHealthMax(target), condition[1], condition[2])
+	return compare(100 * API_UnitHealth(target) / targetHealthMax, condition[1], condition[2])
 end
 OvaleCondition.conditions.healthpercent = OvaleCondition.conditions.lifepercent

@@ -1892,7 +1920,7 @@ OvaleCondition.conditions.mana = function(condition)
 	if target == "player" then
 		return testValue(condition[1], condition[2], OvaleState.state.mana, OvaleState.currentTime, OvaleState.powerRate.mana)
 	else
-		return compare(UnitPower(target), condition[1], condition[2])
+		return compare(API_UnitPower(target), condition[1], condition[2])
 	end
 end

@@ -1912,15 +1940,15 @@ end

 OvaleCondition.conditions.manapercent = function(condition)
 	local target = getTarget(condition.target)
-	local powerMax = UnitPowerMax(target, 0)
-	if not powerMax or powerMax == 0 then
+	local powerMax = API_UnitPowerMax(target, 0) or 0
+	if powerMax == 0 then
 		return nil
 	end
 	if target == "player "then
-		local conversion = 100/powerMax
+		local conversion = 100 / powerMax
 		return testValue(condition[1], condition[2], OvaleState.state.mana * conversion, OvaleState.currentTime, OvaleState.powerRate.mana * conversion)
 	else
-		return compare(UnitPower(target, 0)*100/powerMax, condition[1], condition[2])
+		return compare(API_UnitPower(target, 0)*100 / powerMax, condition[1], condition[2])
 	end
 end

@@ -1958,7 +1986,7 @@ end

 OvaleCondition.conditions.maxhealth = function(condition)
 	local target = getTarget(condition.target)
-	return compare(UnitHealthMax(target), condition[1], condition[2])
+	return compare(API_UnitHealthMax(target), condition[1], condition[2])
 end

 --- Get the level of mana of the target when it is at full mana.
@@ -1975,7 +2003,7 @@ end
 -- if {MaxMana() - Mana()} > 12500 Item(mana_gem)

 OvaleCondition.conditions.maxmana = function(condition)
-	return compare(UnitPowerMax(getTarget(condition.target)), condition[1], condition[2])
+	return compare(API_UnitPowerMax(getTarget(condition.target)), condition[1], condition[2])
 end

 --- Get the time in seconds until the player's next melee swing (white attack).
@@ -2063,8 +2091,8 @@ end
 --     Spell(pet_pummel)

 OvaleCondition.conditions.present = function(condition)
-	local present = UnitExists(getTarget(condition.target)) and not UnitIsDead(getTarget(condition.target))
-	return testbool(present, condition[1])
+	local target = getTarget(condition.target)
+	return testbool(API_UnitExists(target) and not API_UnitIsDead(target), condition[1])
 end

 --- Test if the previous spell cast matches the given spell.
@@ -2094,8 +2122,7 @@ end
 --     Spell(pet_pummel)

 OvaleCondition.conditions.petpresent = function(condition)
-	local present = UnitExists("pet") and not UnitIsDead("pet")
-	return testbool(present, condition[1])
+	return testbool(API_UnitExists("pet") and not API_UnitIsDead("pet"), condition[1])
 end

 --- Test if the game is on a PTR server
@@ -2105,7 +2132,8 @@ end
 --     Valid values: yes, no.
 -- @return A boolean value
 OvaleCondition.conditions.ptr = function(condition)
-	return testbool(GetBuildInfo() == "5.2.0", condition[1])
+	local uiVersion = select(4, API_GetBuildInfo())
+	return testbool(uiVersion > 50200, condition[1])
 end

 --- Get the current amount of rage for guardian druids and warriors.
@@ -2145,7 +2173,7 @@ OvaleCondition.conditions.relativelevel = function(condition)
 	if target == "player" then
 		level = OvalePaperDoll.level
 	else
-		level = UnitLevel(target)
+		level = API_UnitLevel(target)
 	end
 	if level < 0 then
 		difference = 3
@@ -2168,7 +2196,7 @@ end
 --     Spell(cloak_of_shadows)

 OvaleCondition.conditions.remainingcasttime = function(condition)
-	local name, nameSubtext, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitCastingInfo(getTarget(condition.target))
+	local name, nameSubtext, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = API_UnitCastingInfo(getTarget(condition.target))
 	if not endTime then
 		return nil
 	end
@@ -2302,7 +2330,7 @@ end
 --     Spell(aspect_of_the_fox)

 OvaleCondition.conditions.speed = function(condition)
-	return compare(GetUnitSpeed(getTarget(condition.target))*100/7, condition[1], condition[2])
+	return compare(API_GetUnitSpeed(getTarget(condition.target))*100/7, condition[1], condition[2])
 end

 --- Test if the given spell is usable.
@@ -2318,7 +2346,7 @@ end
 -- if SpellUsable(tigers_fury) Spell(berserk_cat)

 OvaleCondition.conditions.spellusable = function(condition)
-	return testbool(IsUsableSpell(condition[1]), condition[2])
+	return testbool(API_IsUsableSpell(condition[1]), condition[2])
 end
 OvaleCondition.spellbookConditions.spellusable = true

@@ -2336,7 +2364,7 @@ OvaleCondition.spellbookConditions.spellusable = true
 --     Spell(savage_defense)

 OvaleCondition.conditions.spellcharges = function(condition)
-	local charges = GetSpellCharges(condition[1])
+	local charges = API_GetSpellCharges(condition[1])
 	return compare(charges, condition[2], condition[3])
 end
 OvaleCondition.spellbookConditions.spellcharges = true
@@ -2352,7 +2380,7 @@ OvaleCondition.spellbookConditions.spellcharges = true
 --     Spell(roll usable=1)

 OvaleCondition.conditions.spellchargecooldown = function(condition)
-	local charges, maxCharges, cooldownStart, cooldownDuration = GetSpellCharges(condition[1])
+	local charges, maxCharges, cooldownStart, cooldownDuration = API_GetSpellCharges(condition[1])
 	if charges < maxCharges then
 		return 0, nil, cooldownDuration, cooldownStart, -1
 	else
@@ -2456,7 +2484,7 @@ end
 --     Spell(ambush)

 OvaleCondition.conditions.stealthed = function(condition)
-	return testbool(IsStealthed(), condition[1])
+	return testbool(API_IsStealthed(), condition[1])
 end

 --- Get the number of points spent in a talent (0 or 1)
@@ -2488,7 +2516,7 @@ end
 -- if target.TargetIsPlayer() Spell(feign_death)

 OvaleCondition.conditions.targetisplayer = function(condition)
-	return testbool(UnitIsUnit("player",getTarget(condition.target).."target"), condition[1])
+	return testbool(API_UnitIsUnit("player", getTarget(condition.target).."target"), condition[1])
 end

 --- Get the amount of threat on the current target relative to the its primary aggro target, scaled to between 0 (zero) and 100.
@@ -2504,7 +2532,7 @@ end
 -- if Threat(more 90) Spell(fade)

 OvaleCondition.conditions.threat = function(condition)
-	local isTanking, status, threatpct = UnitDetailedThreatSituation("player", getTarget(condition.target))
+	local isTanking, status, threatpct = API_UnitDetailedThreatSituation("player", getTarget(condition.target))
 	return compare(threatpct, condition[1], condition[2])
 end

@@ -2679,10 +2707,10 @@ end

 OvaleCondition.conditions.totemexpires = function(condition)
 	if type(condition[1]) ~= "number" then
-		condition[1] = totemType[condition[1]]
+		condition[1] = OVALE_TOTEMTYPE[condition[1]]
 	end

-	local haveTotem, totemName, startTime, duration = GetTotemInfo(condition[1])
+	local haveTotem, totemName, startTime, duration = API_GetTotemInfo(condition[1])
 	if not startTime then
 		return 0
 	end
@@ -2707,10 +2735,10 @@ end

 OvaleCondition.conditions.totempresent = function(condition)
 	if type(condition[1]) ~= "number" then
-		condition[1] = totemType[condition[1]]
+		condition[1] = OVALE_TOTEMTYPE[condition[1]]
 	end

-	local haveTotem, totemName, startTime, duration = GetTotemInfo(condition[1])
+	local haveTotem, totemName, startTime, duration = API_GetTotemInfo(condition[1])
 	if not startTime then
 		return nil
 	end
@@ -2725,10 +2753,10 @@ end
 	-- return bool
 OvaleCondition.conditions.tracking = function(condition)
 	local what = OvaleData:GetSpellInfoOrNil(condition[1])
-	local numTrackingTypes = GetNumTrackingTypes()
+	local numTrackingTypes = API_GetNumTrackingTypes()
 	local present = false
 	for i=1,numTrackingTypes do
-		local name, texture, active = GetTrackingInfo(i)
+		local name, texture, active = API_GetTrackingInfo(i)
 		if name == what then
 			present = (active == 1)
 			break
@@ -2758,7 +2786,7 @@ end
 -- if WeaponEnchantExpires(mainhand) Spell(windfury_weapon)

 OvaleCondition.conditions.weaponenchantexpires = function(condition)
-	local hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo()
+	local hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges = API_GetWeaponEnchantInfo()
 	if (condition[1] == "mainhand") then
 		if (not hasMainHandEnchant) then
 			return 0
diff --git a/OvaleData.lua b/OvaleData.lua
index 23edfb9..8e776e1 100644
--- a/OvaleData.lua
+++ b/OvaleData.lua
@@ -15,13 +15,22 @@ Ovale.OvaleData = OvaleData
 local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvaleStance = Ovale.OvaleStance

-local ipairs, pairs, tinsert, tonumber, tostring, tsort = ipairs, pairs, table.insert, tonumber, tostring, table.sort
-local GetNumGlyphSockets = GetNumGlyphSockets
-local GetGlyphSocketInfo = GetGlyphSocketInfo
-local GetSpellCooldown = GetSpellCooldown
-local GetSpellBookItemInfo, GetSpellBookItemName = GetSpellBookItemInfo, GetSpellBookItemName
-local GetSpellInfo, GetSpellTabInfo, GetTalentInfo = GetSpellInfo, GetSpellTabInfo, GetTalentInfo
-local HasPetSpells = HasPetSpells
+local ipairs = ipairs
+local pairs = pairs
+local tinsert = table.insert
+local tonumber = tonumber
+local tostring = tostring
+local tsort = table.sort
+local wipe = table.wipe
+local API_GetNumGlyphSockets = GetNumGlyphSockets
+local API_GetGlyphSocketInfo = GetGlyphSocketInfo
+local API_GetSpellCooldown = GetSpellCooldown
+local API_GetSpellBookItemInfo = GetSpellBookItemInfo
+local API_GetSpellBookItemName = GetSpellBookItemName
+local API_GetSpellInfo = GetSpellInfo
+local API_GetSpellTabInfo = GetSpellTabInfo
+local API_GetTalentInfo = GetTalentInfo
+local API_HasPetSpells = HasPetSpells
 local BOOKTYPE_SPELL, BOOKTYPE_PET = BOOKTYPE_SPELL, BOOKTYPE_PET
 local SPELL_POWER_ALTERNATE_POWER = SPELL_POWER_ALTERNATE_POWER
 local SPELL_POWER_BURNING_EMBERS = SPELL_POWER_BURNING_EMBERS
@@ -379,7 +388,7 @@ end

 function OvaleData:GetSpellInfoOrNil(spell)
 	if (spell) then
-		return GetSpellInfo(spell)
+		return API_GetSpellInfo(spell)
 	else
 		return nil
 	end
@@ -388,13 +397,13 @@ end
 function OvaleData:FillPetSpellList()
 	--TODO pas moyen d'avoir le nombre de skills pour le pet
 	local book=BOOKTYPE_PET
-	local numSpells, _ = HasPetSpells()
+	local numSpells, _ = API_HasPetSpells()
 	if not numSpells then return end
 	local i=1
 	while i <= numSpells do
-		local skillType, spellId = GetSpellBookItemInfo(i, book)
+		local skillType, spellId = API_GetSpellBookItemInfo(i, book)
 		if skillType~="FUTURESPELL" and spellId then
-			local spellName = GetSpellBookItemName(i, book)
+			local spellName = API_GetSpellBookItemName(i, book)
 			self.spellList[spellId] = spellName
 		end
 		i = i + 1
@@ -406,15 +415,15 @@ function OvaleData:FillSpellList()

 	--TODO pas moyen d'avoir le nombre de skills pour le pet
 	local book=BOOKTYPE_SPELL
-	local name, texture, offset, numSpells, isGuild = GetSpellTabInfo(2)
+	local name, texture, offset, numSpells, isGuild = API_GetSpellTabInfo(2)

 	numSpells = numSpells + offset

 	local i=1
 	while i <= numSpells do
-		local skillType, spellId = GetSpellBookItemInfo(i, book)
+		local skillType, spellId = API_GetSpellBookItemInfo(i, book)
 		if skillType~="FUTURESPELL" and spellId then
-			local spellName = GetSpellBookItemName(i, book)
+			local spellName = API_GetSpellBookItemName(i, book)
 			self.spellList[spellId] = spellName
 		end
 		i = i + 1
@@ -427,7 +436,7 @@ function OvaleData:RemplirListeTalents()
 	local talentId = 1
 	local talentsChanged = false
 	while true do
-		local name, texture, tier, column, selected, available = GetTalentInfo(talentId)
+		local name, texture, tier, column, selected, available = API_GetTalentInfo(talentId)
 		if not name then
 			break
 		end
@@ -468,8 +477,8 @@ end

 function OvaleData:UpdateGlyphs()
 	wipe(self.glyphs)
-	for i = 1, GetNumGlyphSockets() do
-		local enabled, _, _, glyphSpell, _ = GetGlyphSocketInfo(i)
+	for i = 1, API_GetNumGlyphSockets() do
+		local enabled, _, _, glyphSpell, _ = API_GetGlyphSocketInfo(i)
 		if enabled and glyphSpell then
 			self.glyphs[glyphSpell] = true
 		end
@@ -480,7 +489,7 @@ end
 function OvaleData:DebugGlyphs()
 	local array = {}
 	for glyphId in pairs(self.glyphs) do
-		tinsert(array, GetSpellInfo(glyphId) .. ": " .. glyphId)
+		tinsert(array, API_GetSpellInfo(glyphId) .. ": " .. glyphId)
 	end
 	tsort(array)
 	for _, v in ipairs(array) do
@@ -531,9 +540,9 @@ end

 --Compute the spell Cooldown
 function OvaleData:GetSpellCD(spellId)
-	local actionCooldownStart, actionCooldownDuration, actionEnable = GetSpellCooldown(spellId)
+	local actionCooldownStart, actionCooldownDuration, actionEnable = API_GetSpellCooldown(spellId)
 	if self.spellInfo[spellId] and self.spellInfo[spellId].forcecd then
-		actionCooldownStart, actionCooldownDuration = GetSpellCooldown(self.spellInfo[spellId].forcecd)
+		actionCooldownStart, actionCooldownDuration = API_GetSpellCooldown(self.spellInfo[spellId].forcecd)
 	end
 	return actionCooldownStart, actionCooldownDuration, actionEnable
 end
diff --git a/OvaleEnemies.lua b/OvaleEnemies.lua
index 883af1f..6efe61d 100644
--- a/OvaleEnemies.lua
+++ b/OvaleEnemies.lua
@@ -17,19 +17,17 @@ Ovale.OvaleEnemies = OvaleEnemies
 local bit_band = bit.band
 local pairs = pairs
 local select = select
-local time = time
 local tostring = tostring
 local wipe = table.wipe
-
 local COMBATLOG_OBJECT_AFFILIATION_OUTSIDER = COMBATLOG_OBJECT_AFFILIATION_OUTSIDER
 local COMBATLOG_OBJECT_REACTION_HOSTILE = COMBATLOG_OBJECT_REACTION_HOSTILE

--- enemyLastSeen[guid] = timestamp
-local enemyLastSeen = {}
--- enemyName[guid] = name
-local enemyName = {}
+-- self_enemyLastSeen[guid] = timestamp
+local self_enemyLastSeen = {}
+-- self_enemyName[guid] = name
+local self_enemyName = {}
 -- timer for reaper function to remove inactive enemies
-local reaperTimer = nil
+local self_reaperTimer = nil
 local REAP_INTERVAL = 3
 --</private-static-properties>

@@ -38,11 +36,11 @@ OvaleEnemies.activeEnemies = 0
 --</public-static-properties>

 --<private-static-methods>
-function AddEnemy(guid, name, timestamp)
+local function AddEnemy(guid, name, timestamp)
 	if not guid then return end
-	local seen = enemyLastSeen[guid]
-	enemyLastSeen[guid] = timestamp
-	enemyName[guid] = name
+	local seen = self_enemyLastSeen[guid]
+	self_enemyLastSeen[guid] = timestamp
+	self_enemyName[guid] = name
 	if not seen then
 		OvaleEnemies.activeEnemies = OvaleEnemies.activeEnemies + 1
 		Ovale:DebugPrint("enemy", "New enemy (" .. OvaleEnemies.activeEnemies .. " total): " .. guid .. "(" .. tostring(name) .. ")")
@@ -50,11 +48,11 @@ function AddEnemy(guid, name, timestamp)
 	end
 end

-function RemoveEnemy(guid, isDead)
+local function RemoveEnemy(guid, isDead)
 	if not guid then return end
-	local seen = enemyLastSeen[guid]
-	local name = enemyName[guid]
-	enemyLastSeen[guid] = nil
+	local seen = self_enemyLastSeen[guid]
+	local name = self_enemyName[guid]
+	self_enemyLastSeen[guid] = nil
 	if seen then
 		if OvaleEnemies.activeEnemies > 0 then
 			OvaleEnemies.activeEnemies = OvaleEnemies.activeEnemies - 1
@@ -72,17 +70,17 @@ end

 --<public-static-methods>
 function OvaleEnemies:OnEnable()
-	if not reaperTimer then
-		reaperTimer = self:ScheduleRepeatingTimer("RemoveInactiveEnemies", REAP_INTERVAL)
+	if not self_reaperTimer then
+		self_reaperTimer = self:ScheduleRepeatingTimer("RemoveInactiveEnemies", REAP_INTERVAL)
 	end
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 	self:RegisterEvent("PLAYER_REGEN_DISABLED")
 end

 function OvaleEnemies:OnDisable()
-	if not reaperTimer then
-		self:CancelTimer(reaperTimer)
-		reaperTimer = nil
+	if not self_reaperTimer then
+		self:CancelTimer(self_reaperTimer)
+		self_reaperTimer = nil
 	end
 	self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 	self:UnregisterEvent("PLAYER_REGEN_DISABLED")
@@ -106,8 +104,8 @@ end

 function OvaleEnemies:PLAYER_REGEN_DISABLED()
 	-- Reset enemy tracking when combat starts.
-	wipe(enemyLastSeen)
-	wipe(enemyName)
+	wipe(self_enemyLastSeen)
+	wipe(self_enemyName)
 	self.activeEnemies = 0
 end

@@ -115,7 +113,7 @@ end
 -- These enemies are not in combat with your group, out of range, or
 -- incapacitated and shouldn't count toward the number of active enemies.
 function OvaleEnemies:RemoveInactiveEnemies()
-	for guid, timestamp in pairs(enemyLastSeen) do
+	for guid, timestamp in pairs(self_enemyLastSeen) do
 		if Ovale.now - timestamp > REAP_INTERVAL then
 			RemoveEnemy(guid)
 		end
@@ -123,8 +121,8 @@ function OvaleEnemies:RemoveInactiveEnemies()
 end

 function OvaleEnemies:Debug()
-	for guid, timestamp in pairs(enemyLastSeen) do
-		Ovale:Print("enemy " .. guid .. " (" .. tostring(enemyName[guid]) .. ") last seen at " .. timestamp)
+	for guid, timestamp in pairs(self_enemyLastSeen) do
+		Ovale:Print("enemy " .. guid .. " (" .. tostring(self_enemyName[guid]) .. ") last seen at " .. timestamp)
 	end
 end
 --</public-static-methods>
diff --git a/OvaleEquipement.lua b/OvaleEquipement.lua
index b679816..73f95f9 100644
--- a/OvaleEquipement.lua
+++ b/OvaleEquipement.lua
@@ -15,12 +15,11 @@ Ovale.OvaleEquipement = OvaleEquipement
 local pairs = pairs
 local select = select
 local tostring = tostring
-local wipe = wipe
-
-local GetInventoryItemID = GetInventoryItemID
-local GetInventorySlotInfo = GetInventorySlotInfo
-local GetItemInfo = GetItemInfo
+local wipe = table.wipe

+local API_GetInventoryItemID = GetInventoryItemID
+local API_GetInventorySlotInfo = GetInventorySlotInfo
+local API_GetItemInfo = GetItemInfo
 local INVSLOT_AMMO = INVSLOT_AMMO
 local INVSLOT_BACK = INVSLOT_BACK
 local INVSLOT_BODY = INVSLOT_BODY
@@ -45,9 +44,16 @@ local INVSLOT_WAIST = INVSLOT_WAIST
 local INVSLOT_WRIST = INVSLOT_WRIST

 -- item IDs of equipped items, indexed by slot ID
-local equippedItems = {}
+local self_equippedItems = {}
+-- type of main-hand item equipped
+local self_mainHandItemType
+-- type of off-hand item equipped
+local self_offHandItemType
+-- count of equipped pieces of an armor set: self_armorSetCount[armorSetName] = equippedCount
+local self_armorSetCount = {}
+
 -- equipment slot names
-local slotName = {
+local OVALE_SLOTNAME = {
 	AmmoSlot = true,
 	BackSlot = true,
 	ChestSlot = true,
@@ -69,16 +75,10 @@ local slotName = {
 	WaistSlot = true,
 	WristSlot = true,
 }
--- type of main-hand item equipped
-local mainHandItemType
--- type of off-hand item equipped
-local offHandItemType
 -- slots that can contain pieces from armor sets
-local armorSetSlotIDs = { INVSLOT_CHEST, INVSLOT_HAND, INVSLOT_HEAD, INVSLOT_LEGS, INVSLOT_SHOULDER }
--- count of equipped pieces of an armor set: armorSetCount[armorSetName] = equippedCount
-local armorSetCount = {}
--- database of armor set items: armorSet[itemId] = armorSetName
-local armorSet = {
+local OVALE_ARMORSET_SLOT_IDS = { INVSLOT_CHEST, INVSLOT_HAND, INVSLOT_HEAD, INVSLOT_LEGS, INVSLOT_SHOULDER }
+-- database of armor set items: OVALE_ARMORSET[itemId] = armorSetName
+local OVALE_ARMORSET = {
 	-- Death Knight
 	[85314] = "T14_tank",
 	[85315] = "T14_tank",
@@ -947,7 +947,7 @@ local armorSet = {
 local function GetEquippedItemType(slotId)
 	local itemId = OvaleEquipement:GetEquippedItem(slotId)
 	if not itemId then return nil end
-	local inventoryType = select(9, GetItemInfo(itemId))
+	local inventoryType = select(9, API_GetItemInfo(itemId))
 	return inventoryType
 end
 --</private-static-methods>
@@ -967,18 +967,18 @@ end

 function OvaleEquipement:PLAYER_EQUIPMENT_CHANGED(event, slotId, hasItem)
 	if hasItem then
-		equippedItems[slotId] = GetInventoryItemID("player", slotId)
+		self_equippedItems[slotId] = API_GetInventoryItemID("player", slotId)
 		if slotId == INVSLOT_MAINHAND then
-			mainHandItemType = GetEquippedItemType(slotId)
+			self_mainHandItemType = GetEquippedItemType(slotId)
 		elseif slotId == INVSLOT_OFFHAND then
-			offHandItemType = GetEquippedItemType(slotId)
+			self_offHandItemType = GetEquippedItemType(slotId)
 		end
 	else
-		equippedItems[slotId] = nil
+		self_equippedItems[slotId] = nil
 		if slotId == INVSLOT_MAINHAND then
-			mainHandItemType = nil
+			self_mainHandItemType = nil
 		elseif slotId == INVSLOT_OFFHAND then
-			offHandItemType = nil
+			self_offHandItemType = nil
 		end
 	end

@@ -987,35 +987,35 @@ function OvaleEquipement:PLAYER_EQUIPMENT_CHANGED(event, slotId, hasItem)
 end

 function OvaleEquipement:GetArmorSetCount(name)
-	if not armorSetCount[name] then
+	if not self_armorSetCount[name] then
 		return 0
 	else
-		return armorSetCount[name]
+		return self_armorSetCount[name]
 	end
 end

 function OvaleEquipement:GetEquippedItem(slotId)
 	if type(slotId) ~= "number" then
-		if not slotName[slotId] then return nil end
-		slotId = GetInventorySlotInfo(slotId)
+		if not OVALE_SLOTNAME[slotId] then return nil end
+		slotId = API_GetInventorySlotInfo(slotId)
 		if not slotId then return nil end
 	end
-	return equippedItems[slotId]
+	return self_equippedItems[slotId]
 end

 function OvaleEquipement:HasMainHandWeapon()
-	return mainHandItemType == "INVTYPE_WEAPON"
-		or mainHandItemType == "INVTYPE_WEAPONMAINHAND"
-		or mainHandItemType == "INVTYPE_2HWEAPON"
+	return self_mainHandItemType == "INVTYPE_WEAPON"
+		or self_mainHandItemType == "INVTYPE_WEAPONMAINHAND"
+		or self_mainHandItemType == "INVTYPE_2HWEAPON"
 end

 function OvaleEquipement:HasOffHandWeapon()
-	return offHandItemType == "INVTYPE_WEAPON"
-		or offHandItemType == "INVTYPE_WEAPONOFFHAND"
+	return self_offHandItemType == "INVTYPE_WEAPON"
+		or self_offHandItemType == "INVTYPE_WEAPONOFFHAND"
 end

 function OvaleEquipement:HasShield()
-	return offHandItemType == "INVTYPE_SHIELD"
+	return self_offHandItemType == "INVTYPE_SHIELD"
 end

 function OvaleEquipement:HasTrinket(itemId)
@@ -1024,20 +1024,20 @@ function OvaleEquipement:HasTrinket(itemId)
 end

 function OvaleEquipement:HasTwoHandedWeapon()
-	return mainHandItemType == "INVTYPE_2HWEAPON"
+	return self_mainHandItemType == "INVTYPE_2HWEAPON"
 end

 function OvaleEquipement:UpdateArmorSetCount()
-	wipe(armorSetCount)
-	for i = 1, #armorSetSlotIDs do
-		local itemId = self:GetEquippedItem(armorSetSlotIDs[i])
+	wipe(self_armorSetCount)
+	for i = 1, #OVALE_ARMORSET_SLOT_IDS do
+		local itemId = self:GetEquippedItem(OVALE_ARMORSET_SLOT_IDS[i])
 		if itemId then
-			local name = armorSet[itemId]
+			local name = OVALE_ARMORSET[itemId]
 			if name then
-				if not armorSetCount[name] then
-					armorSetCount[name] = 1
+				if not self_armorSetCount[name] then
+					self_armorSetCount[name] = 1
 				else
-					armorSetCount[name] = armorSetCount[name] + 1
+					self_armorSetCount[name] = self_armorSetCount[name] + 1
 				end
 			end
 		end
@@ -1048,14 +1048,14 @@ function OvaleEquipement:UpdateEquippedItems()
 	local changed = false
 	local item
 	for slotId = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
-		item = GetInventoryItemID("player", slotId)
-		if item ~= equippedItems[slotId] then
-			equippedItems[slotId] = GetInventoryItemID("player", slotId)
+		item = API_GetInventoryItemID("player", slotId)
+		if item ~= self_equippedItems[slotId] then
+			self_equippedItems[slotId] = item
 			changed = true
 		end
 	end
-	mainHandItemType = GetEquippedItemType(INVSLOT_MAINHAND)
-	offHandItemType = GetEquippedItemType(INVSLOT_OFFHAND)
+	self_mainHandItemType = GetEquippedItemType(INVSLOT_MAINHAND)
+	self_offHandItemType = GetEquippedItemType(INVSLOT_OFFHAND)

 	if changed then
 		self:UpdateArmorSetCount()
@@ -1067,9 +1067,9 @@ function OvaleEquipement:Debug()
 	for slotId = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
 		Ovale:Print("Slot " ..slotId.. " = " .. tostring(self:GetEquippedItem(slotId)))
 	end
-	Ovale:Print("Main-hand item type: " .. tostring(mainHandItemType))
-	Ovale:Print("Off-hand item type: " .. tostring(offHandItemType))
-	for k, v in pairs(armorSetCount) do
+	Ovale:Print("Main-hand item type: " .. tostring(self_mainHandItemType))
+	Ovale:Print("Off-hand item type: " .. tostring(self_offHandItemType))
+	for k, v in pairs(self_armorSetCount) do
 		Ovale:Print("Player has " ..v.. "piece(s) of " ..k.. " armor set")
 	end
 end
diff --git a/OvaleFrame.lua b/OvaleFrame.lua
index a4cfba8..97605f4 100644
--- a/OvaleFrame.lua
+++ b/OvaleFrame.lua
@@ -25,8 +25,11 @@ do
 	local Version = 7

 	local pairs = pairs
-	local CreateFrame, GetSpellInfo = CreateFrame, GetSpellInfo
-	local GetTime = GetTime
+	local wipe = table.wipe
+	local API_CreateFrame = CreateFrame
+	local API_GetSpellInfo = GetSpellInfo
+	local API_GetTime = GetTime
+	local API_UnitGUID = UnitGUID
 --</private-static-properties>

 --<public-methods>
@@ -152,7 +155,7 @@ do

 	local function OnUpdate(self)
 		-- Update current time.
-		Ovale.now = GetTime()
+		Ovale.now = API_GetTime()

 		local profile = OvaleOptions:GetProfile()
 		local forceRefresh = not self.lastUpdate or (now > self.lastUpdate + profile.apparence.updateInterval)
@@ -244,7 +247,7 @@ do
 						if start then
 							local castTime=0
 							if spellId then
-								local _, _, _, _, _, _, _castTime = GetSpellInfo(spellId)
+								local _, _, _, _, _, _, _castTime = API_GetSpellInfo(spellId)
 								if _castTime and _castTime>0 then
 									castTime = _castTime/1000
 								end
@@ -266,7 +269,7 @@ do
 							if spellTarget == "target" or not spellTarget then
 								spellTarget = target
 							end
-							OvaleState:AddSpellToStack(spellId, start, start + castTime, nextCast, false, UnitGUID(spellTarget))
+							OvaleState:AddSpellToStack(spellId, start, start + castTime, nextCast, false, API_UnitGUID(spellTarget))
 							start, ending, priorite, element = OvaleBestAction:Compute(node)
 							icons[2]:Update(element, start, OvaleBestAction:GetActionInfo(element))
 						else
@@ -364,12 +367,12 @@ do
 				local icon
 				if not node.secure then
 					if not action.icons[l] then
-						action.icons[l] = CreateFrame("CheckButton", "Icon"..k.."n"..l,self.frame,"OvaleIconTemplate");
+						action.icons[l] = API_CreateFrame("CheckButton", "Icon"..k.."n"..l,self.frame,"OvaleIconTemplate");
 					end
 					icon = action.icons[l]
 				else
 					if not action.secureIcons[l] then
-						action.secureIcons[l] = CreateFrame("CheckButton", "SecureIcon"..k.."n"..l,self.frame,"SecureOvaleIconTemplate");
+						action.secureIcons[l] = API_CreateFrame("CheckButton", "SecureIcon"..k.."n"..l,self.frame,"SecureOvaleIconTemplate");
 					end
 					icon = action.secureIcons[l]
 				end
@@ -418,7 +421,7 @@ do
 	end

 	local function Constructor()
-		local frame = CreateFrame("Frame",nil,UIParent)
+		local frame = API_CreateFrame("Frame",nil,UIParent)
 		local self = {}
 		local profile = OvaleOptions:GetProfile()

@@ -439,9 +442,9 @@ do
 		self.localstatus = {}
 		self.actions = {}
 		self.frame = frame
-		self.updateFrame = CreateFrame("Frame")
+		self.updateFrame = API_CreateFrame("Frame")
 		self.barre = self.frame:CreateTexture();
-		self.content = CreateFrame("Frame",nil,frame)
+		self.content = API_CreateFrame("Frame",nil,frame)
 		if Masque then
 			self.skinGroup = Masque:Group("Ovale")
 		end
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index e18fb51..9a6f13a 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -26,19 +26,16 @@ local select = select
 local strfind = string.find
 local tinsert = table.insert
 local tremove = table.remove
-
-local GetSpellInfo = GetSpellInfo
-local GetTime = GetTime
-local UnitBuff = UnitBuff
-local UnitCastingInfo = UnitCastingInfo
-local UnitChannelInfo = UnitChannelInfo
-local UnitGUID = UnitGUID
-local UnitName = UnitName
+local API_GetSpellInfo = GetSpellInfo
+local API_UnitCastingInfo = UnitCastingInfo
+local API_UnitChannelInfo = UnitChannelInfo
+local API_UnitGUID = UnitGUID
+local API_UnitName = UnitName

 -- The spells that the player is casting or has cast but are still in-flight toward their targets.
-local lastSpell = {}
-local playerGUID = nil
-local playerName = nil
+local self_lastSpell = {}
+local self_playerGUID = nil
+local self_playerName = nil
 --</private-static-properties>

 --<public-static-properties>
@@ -60,8 +57,8 @@ OvaleFuture.traceSpellId = nil
 -- Events
 --<public-static-methods>
 function OvaleFuture:OnEnable()
-	playerGUID = OvaleGUID.player
-	playerName = UnitName("player")
+	self_playerGUID = OvaleGUID.player
+	self_playerName = API_UnitName("player")
 	self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
 	self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
@@ -84,9 +81,9 @@ end

 function OvaleFuture:UNIT_SPELLCAST_CHANNEL_START(event, unit, name, rank, lineId, spellId)
 	if unit=="player" then
-		local startTime, endTime = select(5, UnitChannelInfo("player"))
+		local startTime, endTime = select(5, API_UnitChannelInfo("player"))
 		if self.traceSpellId and self.traceSpellId == spellId then
-			Ovale:Print(event.. ": " ..GetTime().. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
+			Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
 			Ovale:Print("    startTime = " ..startTime.. ", endTime = " ..endTime)
 		end
 		self:AddSpellToList(spellId, lineId, startTime/1000, endTime/1000, true, false)
@@ -96,7 +93,7 @@ end
 function OvaleFuture:UNIT_SPELLCAST_CHANNEL_STOP(event, unit, name, rank, lineId, spellId)
 	if unit == "player" then
 		if self.traceSpellId and self.traceSpellId == spellId then
-			Ovale:Print(event.. ": " ..GetTime().. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
+			Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
 		end
 		self:RemoveSpellFromList(spellId, lineId)
 	end
@@ -105,9 +102,9 @@ end
 --Called when a spell started its cast
 function OvaleFuture:UNIT_SPELLCAST_START(event, unit, name, rank, lineId, spellId)
 	if unit=="player" then
-		local startTime, endTime = select(5, UnitCastingInfo("player"))
+		local startTime, endTime = select(5, API_UnitCastingInfo("player"))
 		if self.traceSpellId and self.traceSpellId == spellId then
-			Ovale:Print(event.. ": " ..GetTime().. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
+			Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
 			Ovale:Print("    startTime = " ..startTime.. ", endTime = " ..endTime)
 		end
 		self:AddSpellToList(spellId, lineId, startTime/1000, endTime/1000, false, false)
@@ -115,11 +112,11 @@ function OvaleFuture:UNIT_SPELLCAST_START(event, unit, name, rank, lineId, spell
 end

 --Called if the player interrupted early his cast
---The spell is removed from the lastSpell table
+--The spell is removed from the self_lastSpell table
 function OvaleFuture:UNIT_SPELLCAST_INTERRUPTED(event, unit, name, rank, lineId, spellId)
 	if unit == "player" then
 		if self.traceSpellId and self.traceSpellId == spellId then
-			Ovale:Print(event.. ": " ..GetTime().. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
+			Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
 		end
 		self:RemoveSpellFromList(spellId, lineId)
 	end
@@ -129,18 +126,18 @@ function OvaleFuture:UNIT_SPELLCAST_SENT(event, unit, spell, rank, target, lineI
 	if unit == "player" then
 		local targetGUID
 		--The UNIT_TARGET event may come a bit late
-		if target == UnitName("target") then
-			targetGUID = UnitGUID("target")
+		if target == API_UnitName("target") then
+			targetGUID = API_UnitGUID("target")
 		else
 			targetGUID = OvaleGUID.nameToGUID[target]
 		end
 		self.nextSpellTarget = targetGUID
 		self.nextSpellLineID = lineId
 		if self.traceSpellId and self.traceSpellId == spellId then
-			Ovale:Print(event.. ": " ..GetTime().. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
+			Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
 			Ovale:Print("    targetGUID = " ..targetGUID)
 		end
-		for i,v in ipairs(lastSpell) do
+		for i,v in ipairs(self_lastSpell) do
 			if v.lineId == lineId then
 				v.target = targetGUID
 			end
@@ -151,18 +148,18 @@ end
 function OvaleFuture:UNIT_SPELLCAST_SUCCEEDED(event, unit, name, rank, lineId, spellId)
 	if unit == "player" then
 		if self.traceSpellId and self.traceSpellId == spellId then
-			Ovale:Print(event.. ": " ..GetTime().. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
+			Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId)
 		end
-		for i,v in ipairs(lastSpell) do
+		for i,v in ipairs(self_lastSpell) do
 			if v.lineId == lineId then
 				--Already added in UNIT_SPELLCAST_START
 				v.allowRemove = true
 				return
 			end
 		end
-		if not UnitChannelInfo("player") then
+		if not API_UnitChannelInfo("player") then
 			--A UNIT_SPELLCAST_SUCCEEDED is received when channeling a spell, with a different lineId!
-			local now = GetTime()
+			local now = Ovale.now
 			self:AddSpellToList(spellId, lineId, now, now, false, true)
 		end
 	end
@@ -209,18 +206,18 @@ function OvaleFuture:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 	SPELL_PERIODIC_DAMAGE
 	SPELL_PERIODIC_DAMAGE]]

-	if sourceGUID == playerGUID then
+	if sourceGUID == self_playerGUID then
 		--Called when a missile reached or missed its target
-		--Update lastSpell accordingly
+		--Update self_lastSpell accordingly
 		--Do not use SPELL_CAST_SUCCESS because it is sent when the missile has not reached the target

-			--Ovale:Print("SPELL_CAST_START " .. GetTime())
+			--Ovale:Print("SPELL_CAST_START " .. Ovale.now)
 		--if strfind(event, "SPELL") == 1 then
 		--	local spellId, spellName = select(12, ...)
-		--	Ovale:Print(event .. " " ..spellName .. " " ..GetTime())
+		--	Ovale:Print(event .. " " ..spellName .. " " ..Ovale.now)
 		--end
 			-- local spellId, spellName = select(12, ...)
-			-- for i,v in ipairs(lastSpell) do
+			-- for i,v in ipairs(self_lastSpell) do

 			-- end
 		--end
@@ -234,17 +231,17 @@ function OvaleFuture:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 				or strfind(event, "SPELL_CAST_FAILED") == 1 then
 			local spellId, spellName = select(12, ...)
 			if self.traceSpellId and self.traceSpellId == spellId then
-				Ovale:Print(event.. ": " ..GetTime().. " " ..spellName.. " (" ..spellId.. ")")
+				Ovale:Print(event.. ": " ..Ovale.now.. " " ..spellName.. " (" ..spellId.. ")")
 			end
-			for i,v in ipairs(lastSpell) do
+			for i,v in ipairs(self_lastSpell) do
 				if (v.spellId == spellId or v.auraSpellId == spellId) and v.allowRemove then
 					if not v.channeled and (v.removeOnSuccess or
 								strfind(event, "SPELL_CAST_SUCCESS") ~= 1) then
 						if self.traceSpellId and self.traceSpellId == spellId then
-							local spellName = OvaleData.spellList[spellId] or GetSpellInfo(spellId)
-							Ovale:Print("    Spell landed: " ..GetTime().. " " ..spellName.. " (" ..spellId.. ")")
+							local spellName = OvaleData.spellList[spellId] or API_GetSpellInfo(spellId)
+							Ovale:Print("    Spell landed: " ..Ovale.now.. " " ..spellName.. " (" ..spellId.. ")")
 						end
-						tremove(lastSpell, i)
+						tremove(self_lastSpell, i)
 						Ovale.refreshNeeded["player"] = true
 					end
 					break
@@ -268,11 +265,11 @@ function OvaleFuture:AddSpellToList(spellId, lineId, startTime, endTime, channel
 		-- Ovale:Print("found lineId " .. lineId .. " target is " .. self.nextSpellTarget)
 		newSpell.target = self.nextSpellTarget
 	else
-		newSpell.target = UnitGUID("target")
+		newSpell.target = API_UnitGUID("target")
 	end
 	if self.traceSpellId and self.traceSpellId == spellId then
-		local spellName = OvaleData.spellList[spellId] or GetSpellInfo(spellId)
-		Ovale:Print("    AddSpellToList: " ..GetTime().. " " ..spellName.. " (" ..spellId.. "), lineId = " ..lineId)
+		local spellName = OvaleData.spellList[spellId] or API_GetSpellInfo(spellId)
+		Ovale:Print("    AddSpellToList: " ..Ovale.now.. " " ..spellName.. " (" ..spellId.. "), lineId = " ..lineId)
 		Ovale:Print("        startTime = " ..startTime.. ", endTime = " ..endTime)
 		Ovale:Print("        target = " ..newSpell.target.. (channeled and "(channeled)" or "") .. (allowRemove and "(allowRemove)" or ""))
 	end
@@ -282,7 +279,7 @@ function OvaleFuture:AddSpellToList(spellId, lineId, startTime, endTime, channel
 	self.lastSpellSP[spellId] = OvalePaperDoll.spellBonusDamage
 	self.lastSpellDM[spellId] = OvaleAura:GetDamageMultiplier(spellId)
 	self.lastSpellMastery[spellId] = OvalePaperDoll.masteryEffect
-	tinsert(lastSpell, newSpell)
+	tinsert(self_lastSpell, newSpell)

 	local si = OvaleData.spellInfo[spellId]
 	if si then
@@ -310,7 +307,7 @@ function OvaleFuture:AddSpellToList(spellId, lineId, startTime, endTime, channel
 			end
 		end

-		if si.buffnocd and UnitBuff("player", GetSpellInfo(si.buffnocd)) then
+		if si.buffnocd and OvaleAura:GetAura("player", si.buffnocd) then
 			newSpell.nocd = true
 		else
 			newSpell.nocd = false
@@ -340,7 +337,7 @@ function OvaleFuture:AddSpellToList(spellId, lineId, startTime, endTime, channel
 			if scored~=nil then
 				Ovale.score = Ovale.score + scored
 				Ovale.maxScore = Ovale.maxScore + 1
-				Ovale:SendScoreToDamageMeter(playerName, playerGUID, scored, 1)
+				Ovale:SendScoreToDamageMeter(self_playerName, self_playerGUID, scored, 1)
 			end
 		end
 	end
@@ -348,13 +345,13 @@ function OvaleFuture:AddSpellToList(spellId, lineId, startTime, endTime, channel
 end

 function OvaleFuture:RemoveSpellFromList(spellId, lineId)
-	for i,v in ipairs(lastSpell) do
+	for i,v in ipairs(self_lastSpell) do
 		if v.lineId == lineId then
 			if self.traceSpellId and self.traceSpellId == spellId then
-				local spellName = OvaleData.spellList[spellId] or GetSpellInfo(spellId)
-				Ovale:Print("    RemoveSpellFromList: " ..GetTime().. " " ..spellName.. " (" ..spellId.. ")")
+				local spellName = OvaleData.spellList[spellId] or API_GetSpellInfo(spellId)
+				Ovale:Print("    RemoveSpellFromList: " ..Ovale.now.. " " ..spellName.. " (" ..spellId.. ")")
 			end
-			tremove(lastSpell, i)
+			tremove(self_lastSpell, i)
 			break
 		end
 	end
@@ -379,9 +376,9 @@ function OvaleFuture:InFlightSpells(now)
 	return function()
 		while true do
 			index = index + 1
-			if index > #lastSpell then return end
+			if index > #self_lastSpell then return end

-			cast = lastSpell[index]
+			cast = self_lastSpell[index]
 			si = OvaleData.spellInfo[cast.spellId]
 			-- skip over spells that are toggles for other spells
 			if not (si and si.toggle) then
@@ -389,7 +386,7 @@ function OvaleFuture:InFlightSpells(now)
 				if now - cast.stop < 5 then
 					return cast.spellId, cast.lineId, cast.start, cast.stop, cast.stop, cast.nocd, cast.target
 				else
-					tremove(lastSpell, index)
+					tremove(self_lastSpell, index)
 					-- Decrement current index since item was removed and rest of items shifted up.
 					index = index - 1
 				end
@@ -400,7 +397,7 @@ function OvaleFuture:InFlightSpells(now)
 end

 function OvaleFuture:InFlight(spellId)
-	for i,v in ipairs(lastSpell) do
+	for i,v in ipairs(self_lastSpell) do
 		if v.spellId == spellId then
 			return true
 		end
@@ -409,13 +406,13 @@ function OvaleFuture:InFlight(spellId)
 end

 function OvaleFuture:Debug()
-	if next(lastSpell) then
+	if next(self_lastSpell) then
 		Ovale:Print("Spells in flight:")
 	else
 		Ovale:Print("No spells in flight!")
 	end
-	for spellId, lineId in self:InFlightSpells(GetTime()) do
-		local spellName = OvaleData.spellList[spellId] or GetSpellInfo(spellId)
+	for spellId, lineId in self:InFlightSpells(Ovale.now) do
+		local spellName = OvaleData.spellList[spellId] or API_GetSpellInfo(spellId)
 		Ovale:Print("    " ..spellName.. " (" ..spellId.. "), lineId = " ..tostring(lineId))
 	end
 end
diff --git a/OvaleGUID.lua b/OvaleGUID.lua
index 24bb63c..b98d79b 100644
--- a/OvaleGUID.lua
+++ b/OvaleGUID.lua
@@ -15,8 +15,11 @@ local OvaleGUID = Ovale:NewModule("OvaleGUID", "AceEvent-3.0", "AceConsole-3.0")
 Ovale.OvaleGUID = OvaleGUID

 --<private-static-properties>
-local strfind, strsub = string.find, string.sub
-local GetNumGroupMembers, UnitGUID, UnitName = GetNumGroupMembers, UnitGUID, UnitName
+local strfind = string.find
+local strsub = string.sub
+local API_GetNumGroupMembers = GetNumGroupMembers
+local API_UnitGUID = UnitGUID
+local API_UnitName = UnitName
 --</private-static-properties>

 --<public-static-properties>
@@ -53,7 +56,7 @@ end

 function OvaleGUID:Update(unitId)
 	--self:Print("Update " .. unitId)
-	local guid = UnitGUID(unitId)
+	local guid = API_UnitGUID(unitId)
 	local previousGuid = self.guid[unitId]
 	if unitId == "player" then
 		self.player = guid
@@ -74,7 +77,7 @@ function OvaleGUID:Update(unitId)
 			self.unitId[guid][unitId] = true
 		end
 	end
-	local name = UnitName(unitId)
+	local name = API_UnitName(unitId)
 	if name and (not self.nameToGUID[name] or unitId == "target"
 			or self.nameToUnit[name] == "mouseover") then
 		self.nameToGUID[name] = guid
@@ -105,7 +108,7 @@ function OvaleGUID:UNIT_TARGET(event, unitId)
 end

 function OvaleGUID:GROUP_ROSTER_UPDATE(event)
-	for i=1, GetNumGroupMembers() do
+	for i=1, API_GetNumGroupMembers() do
 		self:UpdateWithTarget("raid"..i)
 		self:UpdateWithTarget("raidpet"..i)
 	end
diff --git a/OvaleIcone.lua b/OvaleIcone.lua
index 7fec759..f2a31b6 100644
--- a/OvaleIcone.lua
+++ b/OvaleIcone.lua
@@ -17,7 +17,9 @@ local OvaleData = Ovale.OvaleData
 local OvaleOptions = Ovale.OvaleOptions
 local OvaleState = Ovale.OvaleState

-local strfind, strformat, strsub = string.find, string.format, string.sub
+local strfind = string.find
+local strformat = string.format
+local strsub = string.sub
 --</private-static-properties>

 --<public-methods>
diff --git a/OvaleOptions.lua b/OvaleOptions.lua
index 2aa72cb..23a59c0 100644
--- a/OvaleOptions.lua
+++ b/OvaleOptions.lua
@@ -20,7 +20,9 @@ local OvaleScripts = Ovale.OvaleScripts
 local OvaleStance = Ovale.OvaleStance
 local OvaleState = Ovale.OvaleState

-local strgmatch, strgsub, tostring = string.gmatch, string.gsub, tostring
+local strgmatch = string.gmatch
+local strgsub = string.gsub
+local tostring = tostring
 --</private-static-properties>

 --<public-static-properties>
@@ -34,7 +36,7 @@ local LibDualSpec = LibStub("LibDualSpec-1.0")
 local L = LibStub("AceLocale-3.0"):GetLocale("Ovale")

 --GUI option
-local options =
+local self_options =
 {
 	type = "group",
 	args =
@@ -541,17 +543,17 @@ function OvaleOptions:OnInitialize()
 		}
 	})

-	options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
+	self_options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)

 	-- Add dual-spec support
 	LibDualSpec:EnhanceDatabase(self.db, "Ovale")
-	LibDualSpec:EnhanceOptions(options.args.profile, self.db)
+	LibDualSpec:EnhanceOptions(self_options.args.profile, self.db)

-	AceConfig:RegisterOptionsTable("Ovale", options.args.code)
-	AceConfig:RegisterOptionsTable("Ovale Actions", options.args.actions, "Ovale")
-	AceConfig:RegisterOptionsTable("Ovale Profile", options.args.profile)
-	AceConfig:RegisterOptionsTable("Ovale Apparence", options.args.apparence)
-	AceConfig:RegisterOptionsTable("Ovale Debug", options.args.debug)
+	AceConfig:RegisterOptionsTable("Ovale", self_options.args.code)
+	AceConfig:RegisterOptionsTable("Ovale Actions", self_options.args.actions, "Ovale")
+	AceConfig:RegisterOptionsTable("Ovale Profile", self_options.args.profile)
+	AceConfig:RegisterOptionsTable("Ovale Apparence", self_options.args.apparence)
+	AceConfig:RegisterOptionsTable("Ovale Debug", self_options.args.debug)

 	AceConfigDialog:AddToBlizOptions("Ovale", "Ovale")
 	AceConfigDialog:AddToBlizOptions("Ovale Profile", "Profile", "Ovale")
diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua
index e570db4..bef4ded 100644
--- a/OvalePaperDoll.lua
+++ b/OvalePaperDoll.lua
@@ -16,26 +16,46 @@ Ovale.OvalePaperDoll = OvalePaperDoll
 --<private-static-properties>
 local select = select
 local tonumber = tonumber
-
-local GetMasteryEffect = GetMasteryEffect
-local GetMeleeHaste = GetMeleeHaste
-local GetRangedHaste = GetRangedHaste
-local GetSpecialization = GetSpecialization
-local GetSpellBonusDamage = GetSpellBonusDamage
-local GetSpellBonusHealing = GetSpellBonusHealing
-local UnitAttackPower = UnitAttackPower
-local UnitClass = UnitClass
-local UnitLevel = UnitLevel
-local UnitRangedAttackPower = UnitRangedAttackPower
-local UnitSpellHaste = UnitSpellHaste
-local UnitStat = UnitStat
+local API_GetMasteryEffect = GetMasteryEffect
+local API_GetMeleeHaste = GetMeleeHaste
+local API_GetRangedHaste = GetRangedHaste
+local API_GetSpecialization = GetSpecialization
+local API_GetSpellBonusDamage = GetSpellBonusDamage
+local API_GetSpellBonusHealing = GetSpellBonusHealing
+local API_UnitAttackPower = UnitAttackPower
+local API_UnitClass = UnitClass
+local API_UnitLevel = UnitLevel
+local API_UnitRangedAttackPower = UnitRangedAttackPower
+local API_UnitSpellHaste = UnitSpellHaste
+local API_UnitStat = UnitStat
+
+local OVALE_SPELLDAMAGE_SCHOOL = {
+	DEATHKNIGHT = 4, -- Nature
+	DRUID = 4, -- Nature
+	HUNTER = 4, -- Nature
+	MAGE = 5, -- Frost
+	MONK = 4, -- Nature
+	PALADIN = 2, -- Holy
+	PRIEST = 2, -- Holy
+	ROGUE = 4, -- Nature
+	SHAMAN = 4, -- Nature
+	WARLOCK = 6, -- Shadow
+	WARRIOR = 4, -- Nature
+}
+local OVALE_HEALING_CLASS = {
+	DRUID = true,
+	MONK = true,
+	PALADIN = true,
+	PRIEST = true,
+	SHAMAN = true,
+}
 --</private-static-properties>

 --<public-static-properties>
 -- player's class token
-OvalePaperDoll.class = select(2, UnitClass("player"))
+OvalePaperDoll.class = select(2, API_UnitClass("player"))
 -- player's level
-OvalePaperDoll.level = UnitLevel("player")
+OvalePaperDoll.level = API_UnitLevel("player")
 -- Player's current specialization.
 OvalePaperDoll.specialization = nil

@@ -99,68 +119,47 @@ function OvalePaperDoll:MASTERY_UPDATE(event)
 	if self.level < 80 then
 		self.masteryEffect = 0
 	else
-		self.masteryEffect = GetMasteryEffect()
+		self.masteryEffect = API_GetMasteryEffect()
 	end
 end

 function OvalePaperDoll:PLAYER_LEVEL_UP(event, level, ...)
-	self.level = tonumber(level) or UnitLevel("player")
+	self.level = tonumber(level) or API_UnitLevel("player")
 end

 function OvalePaperDoll:UNIT_ATTACK_POWER(event, unitId)
 	if unitId ~= "player" then return end
-	local base, posBuff, negBuff = UnitAttackPower(unitId)
+	local base, posBuff, negBuff = API_UnitAttackPower(unitId)
 	self.attackPower = base + posBuff + negBuff
 end

 function OvalePaperDoll:UNIT_LEVEL(event, unitId)
 	if unitId ~= "player" then return end
-	self.level = UnitLevel(unitId)
+	self.level = API_UnitLevel(unitId)
 end

 function OvalePaperDoll:UNIT_RANGEDDAMAGE(event, unitId)
 	if unitId ~= "player" then return end
-	self.rangedHaste = GetRangedHaste()
+	self.rangedHaste = API_GetRangedHaste()
 end

 function OvalePaperDoll:UNIT_RANGED_ATTACK_POWER(event, unitId)
 	if unitId ~= "player" then return end
-	local base, posBuff, negBuff = UnitRangedAttackPower(unitId)
+	local base, posBuff, negBuff = API_UnitRangedAttackPower(unitId)
 	self.rangedAttackPower = base + posBuff + negBuff
 end

 function OvalePaperDoll:UNIT_SPELL_HASTE(event, unitId)
 	if unitId ~= "player" then return end
-	self.meleeHaste = GetMeleeHaste()
-	self.spellHaste = UnitSpellHaste(unitId)
+	self.meleeHaste = API_GetMeleeHaste()
+	self.spellHaste = API_UnitSpellHaste(unitId)
 end

-local classToSchool = {
-	DEATHKNIGHT = 4, -- Nature
-	DRUID = 4, -- Nature
-	HUNTER = 4, -- Nature
-	MAGE = 5, -- Frost
-	MONK = 4, -- Nature
-	PALADIN = 2, -- Holy
-	PRIEST = 2, -- Holy
-	ROGUE = 4, -- Nature
-	SHAMAN = 4, -- Nature
-	WARLOCK = 6, -- Shadow
-	WARRIOR = 4, -- Nature
-}
-local isHealingClass = {
-	DRUID = true,
-	MONK = true,
-	PALADIN = true,
-	PRIEST = true,
-	SHAMAN = true,
-}
-
 function OvalePaperDoll:UNIT_SPELL_POWER(event, unitId)
 	if unitId ~= "player" then return end
-	self.spellBonusDamage = GetSpellBonusDamage(classToSchool[self.class])
-	if isHealingClass[self.class] then
-		self.spellBonusHealing = GetSpellBonusHealing()
+	self.spellBonusDamage = API_GetSpellBonusDamage(OVALE_SPELLDAMAGE_SCHOOL[self.class])
+	if OVALE_HEALING_CLASS[self.class] then
+		self.spellBonusHealing = API_GetSpellBonusHealing()
 	else
 		self.spellBonusHealing = self.spellBonusDamage
 	end
@@ -168,15 +167,15 @@ end

 function OvalePaperDoll:UNIT_STATS(event, unitId)
 	if unitId ~= "player" then return end
-	self.strength = UnitStat(unitId, 1)
-	self.agility = UnitStat(unitId, 2)
-	self.stamina = UnitStat(unitId, 3)
-	self.intellect = UnitStat(unitId, 4)
-	self.spirit = UnitStat(unitId, 5)
+	self.strength = API_UnitStat(unitId, 1)
+	self.agility = API_UnitStat(unitId, 2)
+	self.stamina = API_UnitStat(unitId, 3)
+	self.intellect = API_UnitStat(unitId, 4)
+	self.spirit = API_UnitStat(unitId, 5)
 end

 function OvalePaperDoll:UpdateStats(event)
-	self.specialization = GetSpecialization()
+	self.specialization = API_GetSpecialization()
 	self:MASTERY_UPDATE(event)
 	self:UNIT_ATTACK_POWER(event, "player")
 	self:UNIT_RANGEDDAMAGE(event, "player")
@@ -186,7 +185,6 @@ function OvalePaperDoll:UpdateStats(event)
 	self:UNIT_STATS(event, "player")
 end

-
 function OvalePaperDoll:GetMasteryMultiplier()
 	return 1 + self.masteryEffect / 100
 end
diff --git a/OvalePool.lua b/OvalePool.lua
index 68edf1e..d305d74 100644
--- a/OvalePool.lua
+++ b/OvalePool.lua
@@ -12,12 +12,12 @@ local _, Ovale = ...
 local OvalePool = {}
 Ovale.OvalePool = OvalePool

---<private-static-properties>
+--<public-static-properties>
 OvalePool.name = "OvalePool"
 OvalePool.pool = nil
 OvalePool.size = 0
 OvalePool.unused = 0
---</private-static-properties>
+--</public-static-properties>

 --<public-static-methods>
 function OvalePool:NewPool(name)
diff --git a/OvaleSpellDamage.lua b/OvaleSpellDamage.lua
index 44df4ce..621fd3b 100644
--- a/OvaleSpellDamage.lua
+++ b/OvaleSpellDamage.lua
@@ -19,7 +19,7 @@ local OvaleGUID = Ovale.OvaleGUID
 local select = select
 local strfind = string.find

-local playerGUID = nil
+local self_playerGUID = nil
 --</private-static-properties>

 --<public-static-properties>
@@ -29,7 +29,7 @@ OvaleSpellDamage.value = {}
 -- Events
 --<public-static-methods>
 function OvaleSpellDamage:OnEnable()
-	playerGUID = OvaleGUID.player
+	self_playerGUID = OvaleGUID.player
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 end

@@ -40,7 +40,7 @@ end
 function OvaleSpellDamage:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 	local time, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...)

-	if sourceGUID == playerGUID then
+	if sourceGUID == self_playerGUID then
 		if strfind(event, "SPELL_PERIODIC_DAMAGE")==1 or strfind(event, "SPELL_DAMAGE")==1 then
 			local spellId, spellName, spellSchool, amount = select(12, ...)
 			self.value[spellId] = amount
diff --git a/OvaleStance.lua b/OvaleStance.lua
index 1920899..af6b04e 100644
--- a/OvaleStance.lua
+++ b/OvaleStance.lua
@@ -20,55 +20,56 @@ local strfind = string.find
 local tinsert = table.insert
 local tsort = table.sort
 local wipe = table.wipe
-local GetNumShapeshiftForms = GetNumShapeshiftForms
-local GetShapeshiftForm = GetShapeshiftForm
-local GetSpellInfo = GetSpellInfo
+local API_GetNumShapeshiftForms = GetNumShapeshiftForms
+local API_GetShapeshiftForm = GetShapeshiftForm
+local API_GetShapeshiftFormInfo = GetShapeshiftFormInfo
+local API_GetSpellInfo = GetSpellInfo

-local spellIdToStance = {
+-- List of available stances, populated by CreateStanceList()
+local self_stanceList = {}
+-- Player's current stance.
+local self_stance = nil
+
+local OVALE_SPELLID_TO_STANCE = {
 	-- Death Knight
-	[GetSpellInfo(48263)] = "death_knight_blood_presence",
-	[GetSpellInfo(48265)] = "death_knight_unholy_presence",
-	[GetSpellInfo(48266)] = "death_knight_frost_presence",
+	[API_GetSpellInfo(48263)] = "death_knight_blood_presence",
+	[API_GetSpellInfo(48265)] = "death_knight_unholy_presence",
+	[API_GetSpellInfo(48266)] = "death_knight_frost_presence",
 	-- Druid
-	[GetSpellInfo(768)] = "druid_cat_form",
-	[GetSpellInfo(783)] = "druid_travel_form",
-	[GetSpellInfo(1066)] = "druid_aquatic_form",
-	[GetSpellInfo(5487)] = "druid_bear_form",
-	[GetSpellInfo(24858)] = "druid_moonkin_form",
-	[GetSpellInfo(33943)] = "druid_flight_form",
-	[GetSpellInfo(40120)] = "druid_swift_flight_form",
+	[API_GetSpellInfo(768)] = "druid_cat_form",
+	[API_GetSpellInfo(783)] = "druid_travel_form",
+	[API_GetSpellInfo(1066)] = "druid_aquatic_form",
+	[API_GetSpellInfo(5487)] = "druid_bear_form",
+	[API_GetSpellInfo(24858)] = "druid_moonkin_form",
+	[API_GetSpellInfo(33943)] = "druid_flight_form",
+	[API_GetSpellInfo(40120)] = "druid_swift_flight_form",
 	-- Hunter
-	[GetSpellInfo(5118)] = "hunter_aspect_of_the_cheetah",
-	[GetSpellInfo(13159)] = "hunter_aspect_of_the_pack",
-	[GetSpellInfo(13165)] = "hunter_aspect_of_the_hawk",
-	[GetSpellInfo(109260)] = "hunter_asepct_of_the_iron_hawk",
+	[API_GetSpellInfo(5118)] = "hunter_aspect_of_the_cheetah",
+	[API_GetSpellInfo(13159)] = "hunter_aspect_of_the_pack",
+	[API_GetSpellInfo(13165)] = "hunter_aspect_of_the_hawk",
+	[API_GetSpellInfo(109260)] = "hunter_asepct_of_the_iron_hawk",
 	-- Monk
-	[GetSpellInfo(103985)] = "monk_stance_of_the_fierce_tiger",
-	[GetSpellInfo(115069)] = "monk_stance_of_the_sturdy_ox",
-	[GetSpellInfo(115070)] = "monk_stance_of_the_wise_serpent",
+	[API_GetSpellInfo(103985)] = "monk_stance_of_the_fierce_tiger",
+	[API_GetSpellInfo(115069)] = "monk_stance_of_the_sturdy_ox",
+	[API_GetSpellInfo(115070)] = "monk_stance_of_the_wise_serpent",
 	-- Paladin
-	[GetSpellInfo(20154)] = "paladin_seal_of_righteousness",
-	[GetSpellInfo(20164)] = "paladin_seal_of_justice",
-	[GetSpellInfo(20165)] = "paladin_seal_of_insight",
-	[GetSpellInfo(31801)] = "paladin_seal_of_truth",
-	[GetSpellInfo(105361)] = "paladin_seal_of_command",
+	[API_GetSpellInfo(20154)] = "paladin_seal_of_righteousness",
+	[API_GetSpellInfo(20164)] = "paladin_seal_of_justice",
+	[API_GetSpellInfo(20165)] = "paladin_seal_of_insight",
+	[API_GetSpellInfo(31801)] = "paladin_seal_of_truth",
+	[API_GetSpellInfo(105361)] = "paladin_seal_of_command",
 	-- Priest
-	[GetSpellInfo(15473)] = "priest_shadowform",
+	[API_GetSpellInfo(15473)] = "priest_shadowform",
 	-- Rogue
-	[GetSpellInfo(1784)] = "rogue_stealth",
-	[GetSpellInfo(51713)] = "rogue_shadow_dance",
+	[API_GetSpellInfo(1784)] = "rogue_stealth",
+	[API_GetSpellInfo(51713)] = "rogue_shadow_dance",
 	-- Warlock
-	[GetSpellInfo(103958)] = "warlock_metamorphosis",
+	[API_GetSpellInfo(103958)] = "warlock_metamorphosis",
 	-- Warrior
-	[GetSpellInfo(71)] = "warrior_defensive_stance",
-	[GetSpellInfo(2457)] = "warrior_battle_stance",
-	[GetSpellInfo(2458)] = "warrior_berserker_stance",
+	[API_GetSpellInfo(71)] = "warrior_defensive_stance",
+	[API_GetSpellInfo(2457)] = "warrior_battle_stance",
+	[API_GetSpellInfo(2458)] = "warrior_berserker_stance",
 }
-
--- List of available stances, populated by CreateStanceList()
-local stanceList = {}
--- Player's current stance.
-local stance
 --</private-static-properties>

 --<public-static-methods>
@@ -98,15 +99,15 @@ function OvaleStance:UPDATE_SHAPESHIFT_FORMS(event)
 	self:ShapeshiftEventHandler()
 end

--- Fill stanceList with stance bar index <-> Ovale stance name mappings.
+-- Fill self_stanceList with stance bar index <-> Ovale stance name mappings.
 function OvaleStance:CreateStanceList()
-	wipe(stanceList)
-	local name, stanceName
-	for i = 1, GetNumShapeshiftForms() do
-		_, name = GetShapeshiftFormInfo(i)
-		stanceName = spellIdToStance[name]
+	wipe(self_stanceList)
+	local _, name, stanceName
+	for i = 1, API_GetNumShapeshiftForms() do
+		_, name = API_GetShapeshiftFormInfo(i)
+		stanceName = OVALE_SPELLID_TO_STANCE[name]
 		if stanceName then
-			stanceList[i] = stanceName
+			self_stanceList[i] = stanceName
 		end
 	end
 end
@@ -114,8 +115,8 @@ end
 -- Print out the list of stances in alphabetical order.
 function OvaleStance:DebugStances()
 	local array = {}
-	for k, v in pairs(stanceList) do
-		if stance == k then
+	for k, v in pairs(self_stanceList) do
+		if self_stance == k then
 			tinsert(array, v .. " (active)")
 		else
 			tinsert(array, v)
@@ -128,23 +129,23 @@ function OvaleStance:DebugStances()
 end

 function OvaleStance:Debug()
-	Ovale:Print("current stance: " .. stance)
+	Ovale:Print("current stance: " .. self_stance)
 end

 -- Return true if the current stance matches the given name.
 function OvaleStance:IsStance(name)
-	if not name or not stance then return false end
+	if not name or not self_stance then return false end
 	if type(name) == "number" then
-		return name == stance
+		return name == self_stance
 	else
-		return name == stanceList[stance]
+		return name == self_stanceList[self_stance]
 	end
 end

 function OvaleStance:ShapeshiftEventHandler()
-	local newStance = GetShapeshiftForm()
-	if stance ~= newStance then
-		stance = newStance
+	local newStance = API_GetShapeshiftForm()
+	if self_stance ~= newStance then
+		self_stance = newStance
 		self:SendMessage("Ovale_StanceChanged")
 	end
 end
diff --git a/OvaleState.lua b/OvaleState.lua
index 1bb0940..a175ddf 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -23,11 +23,21 @@ local OvaleGUID = Ovale.OvaleGUID
 local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvaleStance = Ovale.OvaleStance

-local floor, pairs, tostring = math.floor, pairs, tostring
-local GetRuneCooldown, GetRuneType = GetRuneCooldown, GetRuneType
-local GetSpellInfo, UnitGUID, UnitHealth = GetSpellInfo, UnitGUID, UnitHealth
-local UnitHealthMax, UnitPower, UnitPowerMax = UnitHealthMax, UnitPower, UnitPowerMax
+local floor = math.floor
+local pairs = pairs
+local tostring = tostring
+local API_GetRuneCooldown = GetRuneCooldown
+local API_GetRuneType = GetRuneType
+local API_GetSpellInfo = GetSpellInfo
+local API_UnitGUID = UnitGUID
+local API_UnitHealth = UnitHealth
+local API_UnitHealthMax = UnitHealthMax
+local API_UnitPower = UnitPower
+local API_UnitPowerMax = UnitPowerMax
 local MAX_COMBO_POINTS = MAX_COMBO_POINTS
+
+local runes = {}
+local runesCD = {}
 --</private-static-properties>

 --<public-static-properties>
@@ -129,15 +139,15 @@ function OvaleState:Reset()
 	self.attenteFinCast = self.maintenant
 	self.state.combo = OvaleComboPoints.combo
 	for k,v in pairs(OvaleData.power) do
-		self.state[k] = UnitPower("player", v.id, v.segments)
+		self.state[k] = API_UnitPower("player", v.id, v.segments)
 	end

 	self:UpdatePowerRates()

 	if OvalePaperDoll.class == "DEATHKNIGHT" then
 		for i=1,6 do
-			self.state.rune[i].type = GetRuneType(i)
-			local start, duration, runeReady = GetRuneCooldown(i)
+			self.state.rune[i].type = API_GetRuneType(i)
+			local start, duration, runeReady = API_GetRuneCooldown(i)
 			self.state.rune[i].duration = duration
 			if runeReady then
 				self.state.rune[i].cd = start
@@ -218,7 +228,7 @@ function OvaleState:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd,
 	--(donc si il est dj lanc, on n'en tient pas compte)
 	if endCast >= self.maintenant then
 		--Mana
-		local _, _, _, cost, _, powerType = GetSpellInfo(spellId)
+		local _, _, _, cost, _, powerType = API_GetSpellInfo(spellId)
 		local power = OvaleData.powerType[powerType]
 		if cost and power and (not newSpellInfo or not newSpellInfo[power]) then
 			self.state[power] = self.state[power] - cost
@@ -247,7 +257,7 @@ function OvaleState:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd,
 					if v.maxi and self.state[k] > v.maxi then
 						self.state[k] = v.maxi
 					else
-						local maxi = UnitPowerMax("player", v.id, v.segments)
+						local maxi = API_UnitPowerMax("player", v.id, v.segments)
 						if maxi and self.state[k] > maxi then
 							self.state[k] = maxi
 						end
@@ -322,7 +332,7 @@ function OvaleState:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd,
 			end
 			if newSpellInfo.targetlifenocd and not nocd then
 				--TODO
-				if UnitHealth("target")/UnitHealthMax("target")*100<newSpellInfo.targetlifenocd then
+				if API_UnitHealth("target") / API_UnitHealthMax("target") * 100 < newSpellInfo.targetlifenocd then
 					cd.duration = 0
 				end
 			end
@@ -372,7 +382,7 @@ function OvaleState:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd,
 							if target == "target" then
 								auraGUID = targetGUID
 							else
-								auraGUID = UnitGUID(target)
+								auraGUID = API_UnitGUID(target)
 							end

 							-- Set the duration to the proper length if it's a DoT.
@@ -519,7 +529,7 @@ function OvaleState:GetAuraByGUID(guid, spellId, mine, target)
 end

 function OvaleState:GetAura(target, spellId, mine)
-	return self:GetAuraByGUID(UnitGUID(target), spellId, mine, target)
+	return self:GetAuraByGUID(API_UnitGUID(target), spellId, mine, target)
 end

 function OvaleState:GetExpirationTimeOnAnyTarget(spellId, excludingTarget)
@@ -574,9 +584,6 @@ function OvaleState:GetEclipseDir()
 	end
 end

-local runes = {}
-local runesCD = {}
-
 function OvaleState:GetRunes(blood, frost, unholy, death, nodeath)
 	local nombre = 0
 	local nombreCD = 0
diff --git a/OvaleSwing.lua b/OvaleSwing.lua
index 472a29c..b90e118 100644
--- a/OvaleSwing.lua
+++ b/OvaleSwing.lua
@@ -22,6 +22,28 @@ local _, Ovale = ...
 local OvaleSwing = Ovale:NewModule("OvaleSwing", "AceEvent-3.0")
 Ovale.OvaleSwing = OvaleSwing

+--<private-static-properties>
+local OvaleGUID = Ovale.OvaleGUID
+local OvalePaperDoll = Ovale.OvalePaperDoll
+
+local math_abs = math.abs
+local unpack = unpack
+local API_GetSpellInfo = GetSpellInfo
+local API_UnitAttackSpeed = UnitAttackSpeed
+local API_UnitDamage = UnitDamage
+local API_UnitRangedDamage = UnitRangedDamage
+local BOOKTYPE_SPELL = BOOKTYPE_SPELL
+
+local self_playerGUID = nil
+
+local OVALE_AUTOSHOT_NAME = API_GetSpellInfo(75)
+local OVALE_RESET_SPELLS = {}
+local OVALE_DELAY_SPELLS = {
+	[API_GetSpellInfo(1464)] = true, -- Slam
+}
+local OVALE_RESET_AUTOSHOT_SPELLS = {}
+--</private-static-properties>
+
 --<public-static-properties>
 OvaleSwing.ohNext = nil
 OvaleSwing.dual = false
@@ -34,28 +56,9 @@ OvaleSwing.startdelay = nil
 OvaleSwing.swingmode = nil
 --</public-static-properties>

---<private-static-properties>
-local OvaleGUID = Ovale.OvaleGUID
-local OvalePaperDoll = Ovale.OvalePaperDoll
-
-local unpack = unpack
-local math_abs = math.abs
-local GetSpellInfo, GetTime, UnitAttackSpeed = GetSpellInfo, GetTime, UnitAttackSpeed
-local UnitDamage, UnitRangedDamage = UnitDamage, UnitRangedDamage
-local BOOKTYPE_SPELL = BOOKTYPE_SPELL
-
-local playerGUID = nil
-local autoshotname = GetSpellInfo(75)
-local resetspells = {}
-local delayspells = {
-	[GetSpellInfo(1464)] = true, -- Slam
-}
-local resetautoshotspells = {}
---</private-static-properties>
-
 --<public-static-methods>
 function OvaleSwing:OnEnable()
-	playerGUID = OvaleGUID.player
+	self_playerGUID = OvaleGUID.player
 	self.ohNext = false
 	-- fired when autoattack is enabled/disabled.
 	self:RegisterEvent("PLAYER_ENTER_COMBAT")
@@ -78,7 +81,7 @@ function OvaleSwing:OnDisable()
 end

 function OvaleSwing:PLAYER_ENTER_COMBAT()
-	local _,_,offhandlow, offhandhigh = UnitDamage('player')
+	local _,_,offhandlow, offhandhigh = API_UnitDamage('player')
 	if math_abs(offhandlow - offhandhigh) <= 0.1 or OvalePaperDoll.class == "DRUID" then
 		self.dual = false
 	else
@@ -103,7 +106,7 @@ function OvaleSwing:STOP_AUTOREPEAT_SPELL()
 end

 function OvaleSwing:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventName, srcGUID, srcName, srcFlags, dstName, dstGUID, dstFlags, ...)
-	if srcGUID == playerGUID then
+	if srcGUID == self_playerGUID then
 		if eventName == "SWING_DAMAGE" or eventName == "SWING_MISSED" then
 			self:MeleeSwing(Ovale.now)
 		end
@@ -111,31 +114,31 @@ function OvaleSwing:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventName, src
 end

 function OvaleSwing:UNIT_SPELLCAST_START(event, unit, spell)
-	if delayspells[spell] and unit=="player" then
+	if OVALE_DELAY_SPELLS[spell] and unit=="player" then
 		self.startdelay = Ovale.now
-		local name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(spell)
+		local name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = API_GetSpellInfo(spell)
 		self.delay = castTime
 	end
 end

 function OvaleSwing:UNIT_SPELLCAST_INTERRUPTED(event, unit, spell)
-	if unit == "player" and delayspells[spell] and self.startdelay then
-		self.delay = GetTime() - self.startdelay
+	if unit == "player" and OVALE_DELAY_SPELLS[spell] and self.startdelay then
+		self.delay = Ovale.now - self.startdelay
 	end
 end

 function OvaleSwing:UNIT_SPELLCAST_SUCCEEDED(event, unit, spell)
 	if unit == "player" then
-		if resetspells[spell] then
+		if OVALE_RESET_SPELLS[spell] then
 			self:MeleeSwing(Ovale.now)
 		end
-		if delayspells[spell] and self.startdelay then
-			self.delay = GetTime() - self.startdelay
+		if OVALE_DELAY_SPELLS[spell] and self.startdelay then
+			self.delay = Ovale.now - self.startdelay
 		end
-		if spell == autoshotname then
+		if spell == OVALE_AUTOSHOT_NAME then
 			self:Shoot()
 		end
-		if resetautoshotspells[spell] then
+		if OVALE_RESET_AUTOSHOT_SPELLS[spell] then
 			self:Shoot()
 		end
 	end
@@ -146,9 +149,9 @@ function OvaleSwing:UNIT_ATTACK(event, unit)
 		if not self.swingmode then
 			return
 		elseif self.swingmode == 0 then
-			self.duration = UnitAttackSpeed('player')
+			self.duration = API_UnitAttackSpeed('player')
 		else
-			self.duration = UnitRangedDamage('player')
+			self.duration = API_UnitRangedDamage('player')
 		end
 	end]]
 end
@@ -159,7 +162,7 @@ function OvaleSwing:MeleeSwing(timestamp)
 			local prediction = self.ohDuration+self.ohStartTime+self.delay
 			print("Prediction oh = "  .. prediction .. " diff=" .. (timestamp-prediction))
 		end]]
-		self.ohDuration = UnitAttackSpeed('player')
+		self.ohDuration = API_UnitAttackSpeed('player')
 		self.ohStartTime = timestamp
 		--print("MeleeSwing oh = " .. self.ohStartTime)
 		self.ohNext = false
@@ -168,7 +171,7 @@ function OvaleSwing:MeleeSwing(timestamp)
 			local prediction = self.duration+self.starttime+self.delay
 			print("Prediction mh = " .. prediction .. " diff=" .. (timestamp-prediction))
 		end]]
-		self.duration = UnitAttackSpeed('player')
+		self.duration = API_UnitAttackSpeed('player')
 		self.starttime = timestamp
 		--print("MeleeSwing mh = " .. self.starttime)
 		self.ohNext = true
@@ -184,8 +187,8 @@ function OvaleSwing:Shoot()
 	--[[if self.duration then
 		print("Prediction = " ..(self.duration+self.starttime))
 	end]]
-	self.duration = UnitRangedDamage('player')
-	self.starttime = GetTime()
+	self.duration = API_UnitRangedDamage('player')
+	self.starttime = Ovale.now
 	--print("Shoot " .. self.starttime)
 end