Quantcast

Use public, not private, properties to hold module state.

Johnny C. Lam [12-09-13 - 02:13]
Use public, not private, properties to hold module state.

This simplifies debugging and doesn't cause namespace conflicts.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1242 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleActionBar.lua
OvaleAura.lua
OvaleDamageTaken.lua
OvaleEnemies.lua
OvaleEquipement.lua
OvaleGUID.lua
OvaleLatency.lua
OvaleScore.lua
OvaleStance.lua
OvaleState.lua
diff --git a/OvaleActionBar.lua b/OvaleActionBar.lua
index 2b886d8..882bc04 100644
--- a/OvaleActionBar.lua
+++ b/OvaleActionBar.lua
@@ -20,22 +20,24 @@ local API_GetActionInfo = GetActionInfo
 local API_GetActionText = GetActionText
 local API_GetBindingKey = GetBindingKey

--- Maps each action slot (1..120) to the current action: self_action[slot] = action
-local self_action = {}
--- Maps each action slot (1..120) to its current keybind: self_keybind[slot] = keybind
-local self_keybind = {}
-
--- Maps each spell/macro/item ID to its current action slot.
--- self_spell[spellId] = slot
-local self_spell = {}
--- self_macro[macroName] = slot
-local self_macro = {}
--- self_item[itemId] = slot
-local self_item = {}
-
 local OVALE_ACTIONBAR_DEBUG = "action_bar"
 --</private-static-properties>

+--<public-static-properties>
+-- Maps each action slot (1..120) to the current action: action[slot] = action
+OvaleActionBar.action = {}
+-- Maps each action slot (1..120) to its current keybind: keybind[slot] = keybind
+OvaleActionBar.keybind = {}
+
+-- Maps each spell/macro/item ID to its current action slot.
+-- spell[spellId] = slot
+OvaleActionBar.spell = {}
+-- macro[macroName] = slot
+OvaleActionBar.macro = {}
+-- item[itemId] = slot
+OvaleActionBar.item = {}
+--</public-static-properties>
+
 --<private-static-methods>
 local function GetKeyBinding(slot)
 	--[[
@@ -60,51 +62,6 @@ local function GetKeyBinding(slot)
 	local key = name and API_GetBindingKey(name)
 	return key
 end
-
-local function UpdateActionSlot(slot)
-	-- Clear old slot and associated actions.
-	local action = self_action[slot]
-	if self_spell[action] == slot then
-		self_spell[action] = nil
-	elseif self_item[action] == slot then
-		self_item[action] = nil
-	elseif self_macro[action] == slot then
-		self_macro[action] = nil
-	end
-	self_action[slot] = nil
-
-	-- Map the current action in the slot.
-	local actionType, id, subType = API_GetActionInfo(slot)
-	if actionType == "spell" then
-		id = tonumber(id)
-		if id then
-			if self_spell[id] and slot < self_spell[id] then
-				self_spell[id] = slot
-			end
-			self_action[slot] = id
-		end
-	elseif actionType == "item" then
-		id = tonumber(id)
-		if id then
-			if self_item[id] and slot < self_item[id] then
-				self_item[id] = slot
-			end
-			self_action[slot] = id
-		end
-	elseif actionType == "macro" then
-		local actionText = API_GetActionText(slot)
-		if actionText then
-			if self_macro[actionText] and slot < self_macro[actionText] then
-				self_macro[actionText] = slot
-			end
-			self_action[slot] = actionText
-		end
-	end
-	Ovale:DebugPrintf(OVALE_ACTIONBAR_DEBUG, "Mapping button %s to %s", slot, self_action[slot])
-
-	-- Update the keybind for the slot.
-	self_keybind[slot] = GetKeyBinding(slot)
-end
 --</private-static-methods>

 --<public-static-methods>
@@ -129,45 +86,90 @@ function OvaleActionBar:ACTIONBAR_SLOT_CHANGED(event, slot)
 	if slot == 0 then
 		self:UpdateActionSlots(event)
 	elseif slot then
-		UpdateActionSlot(slot)
+		self:UpdateActionSlot(slot)
 	end
 end

 function OvaleActionBar:UPDATE_BINDINGS(event)
 	Ovale:DebugPrintf(OVALE_ACTIONBAR_DEBUG, "%s: Updating key bindings.", event)
 	for slot = 1, 120 do
-		self_keybind[slot] = GetKeyBinding(slot)
+		self.keybind[slot] = GetKeyBinding(slot)
 	end
 end

 function OvaleActionBar:UpdateActionSlots(event)
 	Ovale:DebugPrintf(OVALE_ACTIONBAR_DEBUG, "%s: Updating all action slot mappings.", event)
-	wipe(self_action)
-	wipe(self_item)
-	wipe(self_macro)
-	wipe(self_spell)
+	wipe(self.action)
+	wipe(self.item)
+	wipe(self.macro)
+	wipe(self.spell)
 	for slot = 1, 120 do
-		UpdateActionSlot(slot)
+		self:UpdateActionSlot(slot)
+	end
+end
+
+function OvaleActionBar:UpdateActionSlot(slot)
+	-- Clear old slot and associated actions.
+	local action = self.action[slot]
+	if self.spell[action] == slot then
+		self.spell[action] = nil
+	elseif self.item[action] == slot then
+		self.item[action] = nil
+	elseif self.macro[action] == slot then
+		self.macro[action] = nil
+	end
+	self.action[slot] = nil
+
+	-- Map the current action in the slot.
+	local actionType, id, subType = API_GetActionInfo(slot)
+	if actionType == "spell" then
+		id = tonumber(id)
+		if id then
+			if self.spell[id] and slot < self.spell[id] then
+				self.spell[id] = slot
+			end
+			self.action[slot] = id
+		end
+	elseif actionType == "item" then
+		id = tonumber(id)
+		if id then
+			if self.item[id] and slot < self.item[id] then
+				self.item[id] = slot
+			end
+			self.action[slot] = id
+		end
+	elseif actionType == "macro" then
+		local actionText = API_GetActionText(slot)
+		if actionText then
+			if self.macro[actionText] and slot < self.macro[actionText] then
+				self.macro[actionText] = slot
+			end
+			self.action[slot] = actionText
+		end
 	end
+	Ovale:DebugPrintf(OVALE_ACTIONBAR_DEBUG, "Mapping button %s to %s", slot, self.action[slot])
+
+	-- Update the keybind for the slot.
+	self.keybind[slot] = GetKeyBinding(slot)
 end

 -- Get the action slot that matches a spell ID.
 function OvaleActionBar:GetForSpell(spellId)
-	return self_spell[spellId]
+	return self.spell[spellId]
 end

 -- Get the action slot that matches a macro name.
 function OvaleActionBar:GetForMacro(macroName)
-	return self_macro[macroName]
+	return self.macro[macroName]
 end

 -- Get the action slot that matches an item ID.
 function OvaleActionBar:GetForItem(itemId)
-	return self_item[itemId]
+	return self.item[itemId]
 end

 -- Get the keybinding for an action slot.
 function OvaleActionBar:GetBinding(slot)
-	return self_keybind[slot]
+	return self.keybind[slot]
 end
 --</public-static-methods>
diff --git a/OvaleAura.lua b/OvaleAura.lua
index 276b121..c8ccc43 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -58,11 +58,6 @@ do
 	end
 end

--- Auras on the target (past & present): self_aura[guid][auraId][casterGUID] = aura.
-local self_aura = {}
--- Current age of auras per unit: self_serial[guid] = age.
-local self_serial = {}
-
 -- Aura lag in milliseconds, with respect to the corresponding spellcast.
 -- TODO: Promote this into a slider option in the config panel.
 local self_auraLag = 300
@@ -104,6 +99,13 @@ local CLEU_TICK_EVENTS = {
 local CLEU_SCHOOL_MASK_MAGIC = bit_bor(SCHOOL_MASK_ARCANE, SCHOOL_MASK_FIRE, SCHOOL_MASK_FROST, SCHOOL_MASK_HOLY, SCHOOL_MASK_NATURE, SCHOOL_MASK_SHADOW)
 --</private-static-properties>

+--<public-static-properties>
+-- Auras on the target (past & present): aura[guid][auraId][casterGUID] = aura.
+OvaleAura.aura = {}
+-- Current age of auras per unit: serial[guid] = age.
+OvaleAura.serial = {}
+--</public-static-properties>
+
 --<private-static-methods>
 local function PutAura(auraDB, guid, auraId, casterGUID, aura)
 	if not auraDB[guid] then
@@ -264,8 +266,8 @@ function OvaleAura:OnDisable()
 	self:UnregisterEvent("PLAYER_UNGHOST")
 	self:UnregisterEvent("UNIT_AURA")
 	self:UnregisterMessage("Ovale_GroupChanged")
-	for guid in pairs(self_aura) do
-		RemoveAurasOnGUID(self_aura, guid)
+	for guid in pairs(self.aura) do
+		RemoveAurasOnGUID(self.aura, guid)
 	end
 	self_pool:Drain()
 end
@@ -284,7 +286,7 @@ function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 		local spellId, spellName, spellSchool = select(12, ...)
 		local unitId = OvaleGUID:GetUnitId(destGUID)
 		Ovale:DebugPrintf(OVALE_AURA_DEBUG, "%s: %s", event, unitId)
-		local aura = GetAura(self_aura, destGUID, spellId, self_guid)
+		local aura = GetAura(self.aura, destGUID, spellId, self_guid)
 		if self:IsActiveAura(aura) then
 			local name = aura.name or "Unknown spell"
 			local tick, ticksSeen, lastTickTime = aura.tick, aura.ticksSeen, aura.lastTickTime
@@ -341,12 +343,12 @@ end
 function OvaleAura:RemoveAurasOnInactiveUnits()
 	-- 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(self_aura) do
+	for guid in pairs(self.aura) do
 		local unitId = OvaleGUID:GetUnitId(guid)
 		if not unitId then
 			Ovale:DebugPrintf(OVALE_AURA_DEBUG, "Removing auras from guid %s", guid)
-			RemoveAurasOnGUID(self_aura, guid)
-			self_serial[guid] = nil
+			RemoveAurasOnGUID(self.aura, guid)
+			self.serial[guid] = nil
 		end
 	end
 end
@@ -355,7 +357,7 @@ function OvaleAura:IsActiveAura(aura, now)
 	now = now or API_GetTime()
 	local boolean = false
 	if aura then
-		if aura.serial == self_serial[aura.guid] and aura.stacks > 0 and aura.start <= now and now <= aura.ending then
+		if aura.serial == self.serial[aura.guid] and aura.stacks > 0 and aura.start <= now and now <= aura.ending then
 			boolean = true
 		elseif aura.consumed and IsWithinAuraLag(aura.ending, now) then
 			boolean = true
@@ -375,13 +377,13 @@ function OvaleAura:GainedAuraOnGUID(guid, atTime, auraId, casterGUID, filter, ic
 	duration = (duration and duration > 0) and duration or math.huge
 	expirationTime = (expirationTime and expirationTime > 0) and expirationTime or math.huge

-	local aura = GetAura(self_aura, guid, auraId, casterGUID)
+	local aura = GetAura(self.aura, guid, auraId, casterGUID)
 	local auraIsActive
 	if aura then
 		auraIsActive = (aura.stacks > 0 and aura.start <= atTime and atTime <= aura.ending)
 	else
 		aura = self_pool:Get()
-		PutAura(self_aura, guid, auraId, casterGUID, aura)
+		PutAura(self.aura, guid, auraId, casterGUID, aura)
 		auraIsActive = false
 	end

@@ -395,7 +397,7 @@ function OvaleAura:GainedAuraOnGUID(guid, atTime, auraId, casterGUID, filter, ic
 	)

 	-- Update age of aura, regardless of whether it's changed.
-	aura.serial = self_serial[guid]
+	aura.serial = self.serial[guid]

 	if not auraIsActive or not auraIsUnchanged then
 		Ovale:DebugPrintf(OVALE_AURA_DEBUG, "    Adding %s %s (%s) to %s at %f, aura.serial=%d",
@@ -461,7 +463,7 @@ function OvaleAura:GainedAuraOnGUID(guid, atTime, auraId, casterGUID, filter, ic
 end

 function OvaleAura:LostAuraOnGUID(guid, atTime, auraId, casterGUID)
-	local aura = GetAura(self_aura, guid, auraId, casterGUID)
+	local aura = GetAura(self.aura, guid, auraId, casterGUID)
 	local filter = aura.filter
 	Ovale:DebugPrintf(OVALE_AURA_DEBUG, "    Expiring %s %s (%d) from %s at %f.",
 		filter, aura.name, auraId, guid, atTime)
@@ -513,8 +515,10 @@ function OvaleAura:ScanAurasOnGUID(guid)
 	Ovale:DebugPrintf(OVALE_AURA_DEBUG, "Scanning auras on %s (%s) at %f", guid, unitId, now)

 	-- Advance the age of the unit's auras.
-	self_serial[guid] = self_serial[guid] and (self_serial[guid] + 1) or 1
-	Ovale:DebugPrintf(OVALE_AURA_DEBUG, "    Advancing age of auras for %s (%s) to %d.", guid, unitId, self_serial[guid])
+	local serial = self.serial[guid] or 0
+	serial = serial + 1
+	Ovale:DebugPrintf(OVALE_AURA_DEBUG, "    Advancing age of auras for %s (%s) to %d.", guid, unitId, serial)
+	self.serial[guid] = serial

 	-- Add all auras on the unit into the database.
 	local i = 1
@@ -537,9 +541,8 @@ function OvaleAura:ScanAurasOnGUID(guid)
 	end

 	-- Find recently expired auras on the unit.
-	if self_aura[guid] then
-		local auraTable = self_aura[guid]
-		local serial = self_serial[guid]
+	if self.aura[guid] then
+		local auraTable = self.aura[guid]
 		for auraId, whoseTable in pairs(auraTable) do
 			for casterGUID, aura in pairs(whoseTable) do
 				if aura.serial == serial - 1 then
@@ -559,20 +562,20 @@ end

 function OvaleAura:GetAuraByGUID(guid, auraId, filter, mine)
 	-- If this GUID has no auras in the database, then do an aura scan.
-	if not self_serial[guid] then
+	if not self.serial[guid] then
 		self:ScanAurasOnGUID(guid)
 	end

 	local auraFound
 	if OvaleData.buffSpellList[auraId] then
 		for id in pairs(OvaleData.buffSpellList[auraId]) do
-			local aura = GetAuraOnGUID(self_aura, guid, id, filter, mine)
+			local aura = GetAuraOnGUID(self.aura, guid, id, filter, mine)
 			if aura and (not auraFound or auraFound.ending < aura.ending) then
 				auraFound = aura
 			end
 		end
 	else
-		auraFound = GetAuraOnGUID(self_aura, guid, auraId, filter, mine)
+		auraFound = GetAuraOnGUID(self.aura, guid, auraId, filter, mine)
 	end
 	return auraFound
 end
@@ -651,14 +654,14 @@ end
 local function GetStateAura(state, guid, auraId, casterGUID)
 	local auraFound = GetAura(state.aura, guid, auraId, casterGUID)
 	if not state:IsActiveAura(auraFound) then
-		auraFound = GetAura(self_aura, guid, auraId, casterGUID)
+		auraFound = GetAura(OvaleAura.aura, guid, auraId, casterGUID)
 	end
 	return auraFound
 end

 local function GetStateAuraAnyCaster(state, guid, auraId)
 	local auraFound = GetAuraAnyCaster(state.aura, guid, auraId)
-	local aura = GetAuraAnyCaster(self_aura, guid, auraId)
+	local aura = GetAuraAnyCaster(OvaleAura.aura, guid, auraId)
 	local now = state.currentTime
 	if OvaleAura:IsActiveAura(aura, now) then
 		if not state:IsActiveAura(auraFound, now) or auraFound.ending < aura.ending then
@@ -670,7 +673,7 @@ end

 local function GetStateDebuffType(state, guid, debuffType, filter, casterGUID)
 	local auraFound = GetDebuffType(state.aura, guid, debuffType, filter, casterGUID)
-	local aura = GetDebuffType(self_aura, guid, debuffType, filter, casterGUID)
+	local aura = GetDebuffType(OvaleAura.aura, guid, debuffType, filter, casterGUID)
 	local now = state.currentTime
 	if OvaleAura:IsActiveAura(aura, now) then
 		if not state:IsActiveAura(auraFound, now) or auraFound.ending < aura.ending then
@@ -682,7 +685,7 @@ end

 local function GetStateDebuffTypeAnyCaster(state, guid, debuffType, filter)
 	local auraFound = GetDebuffTypeAnyCaster(state.aura, guid, debuffType, filter)
-	local aura = GetDebuffTypeAnyCaster(self_aura, guid, debuffType, filter)
+	local aura = GetDebuffTypeAnyCaster(OvaleAura.aura, guid, debuffType, filter)
 	local now = state.currentTime
 	if OvaleAura:IsActiveAura(aura, now) then
 		if not state:IsActiveAura(auraFound, now) or auraFound.ending < aura.ending then
@@ -746,8 +749,8 @@ do
 	statePrototype.PrintUnitAuras = function(state, unitId, filter)
 		wipe(array)
 		local guid = OvaleGUID:GetGUID(unitId)
-		if self_aura[guid] then
-			for auraId, whoseTable in pairs(self_aura[guid]) do
+		if OvaleAura.aura[guid] then
+			for auraId, whoseTable in pairs(OvaleAura.aura[guid]) do
 				for casterGUID in pairs(whoseTable) do
 					local aura = GetStateAura(state, guid, auraId, casterGUID)
 					if state:IsActiveAura(aura, now) and aura.filter == filter and not aura.state then
@@ -968,8 +971,8 @@ statePrototype.GetStealable = function(state, unitId)
 	local now = state.currentTime

 	-- Loop through auras not kept in the simulator that match the criteria.
-	if self_aura[guid] then
-		for auraId, whoseTable in pairs(self_aura[guid]) do
+	if OvaleAura.aura[guid] then
+		for auraId, whoseTable in pairs(OvaleAura.aura[guid]) do
 			for casterGUID in pairs(whoseTable) do
 				local aura = GetStateAura(state, guid, auraId, self_guid)
 				if state:IsActiveAura(aura, now) and not aura.state then
@@ -1037,7 +1040,7 @@ do
 		local now = state.currentTime

 		-- Loop through auras not kept in the simulator that match the criteria.
-		for guid, auraTable in pairs(self_aura) do
+		for guid, auraTable in pairs(OvaleAura.aura) do
 			if auraTable[auraId] then
 				if mine then
 					local aura = GetStateAura(state, guid, auraId, self_guid)
diff --git a/OvaleDamageTaken.lua b/OvaleDamageTaken.lua
index 910302d..10b9886 100644
--- a/OvaleDamageTaken.lua
+++ b/OvaleDamageTaken.lua
@@ -28,24 +28,16 @@ local API_UnitGUID = UnitGUID
 local self_guid = nil
 -- Damage event pool.
 local self_pool = OvalePool("OvaleDamageTaken_pool")
--- Damage event queue: new events are inserted at the front of the queue.
-local self_damageEvent = OvaleQueue:NewDeque("OvaleDamageTaken_damageEvent")
 -- Time window (past number of seconds) for which damage events are stored.
 local DAMAGE_TAKEN_WINDOW = 20

 local OVALE_DAMAGE_TAKEN_DEBUG = "damage_taken"
 --</private-static-properties>

---<private-static-methods>
-local function AddDamageTaken(timestamp, damage)
-	local self = OvaleDamageTaken
-	local event = self_pool:Get()
-	event.timestamp = timestamp
-	event.damage = damage
-	self_damageEvent:InsertFront(event)
-	self:RemoveExpiredEvents(timestamp)
-end
---</private-static-methods>
+--<public-static-properties>
+-- Damage event queue: new events are inserted at the front of the queue.
+OvaleDamageTaken.damageEvent = OvaleQueue:NewDeque("OvaleDamageTaken_damageEvent")
+--</public-static-properties>

 --<public-static-methods>
 function OvaleDamageTaken:OnInitialize()
@@ -72,12 +64,12 @@ function OvaleDamageTaken:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 		if event:find("SWING_") == 1 then
 			local amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = select(12, ...)
 			Ovale:DebugPrintf(OVALE_DAMAGE_TAKEN_DEBUG, "%s caused %d damage.", event, amount)
-			AddDamageTaken(now, amount)
+			self:AddDamageTaken(now, amount)
 		elseif event:find("RANGE_") == 1 or event:find("SPELL_") == 1 then
 			local spellId, spellName, spellSchool = select(12, ...)
 			local amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = select(15, ...)
 			Ovale:DebugPrintf(OVALE_DAMAGE_TAKEN_DEBUG, "%s (%s) caused %d damage.", event, spellName, amount)
-			AddDamageTaken(now, amount)
+			self:AddDamageTaken(now, amount)
 		end
 	end
 end
@@ -86,6 +78,14 @@ function OvaleDamageTaken:PLAYER_REGEN_ENABLED(event)
 	self_pool:Drain()
 end

+function OvaleDamageTaken:AddDamageTaken(timestamp, damage)
+	local event = self_pool:Get()
+	event.timestamp = timestamp
+	event.damage = damage
+	self.damageEvent:InsertFront(event)
+	self:RemoveExpiredEvents(timestamp)
+end
+
 -- Return the total damage taken in the previous time interval (in seconds).
 function OvaleDamageTaken:GetRecentDamage(interval, lagCorrection)
 	local now = API_GetTime()
@@ -96,7 +96,7 @@ function OvaleDamageTaken:GetRecentDamage(interval, lagCorrection)
 	self:RemoveExpiredEvents(now)

 	local total = 0
-	for i, event in self_damageEvent:FrontToBackIterator() do
+	for i, event in self.damageEvent:FrontToBackIterator() do
 		if event.timestamp < lowerBound then
 			break
 		end
@@ -108,21 +108,21 @@ end
 -- Remove all events that are more than DAMAGE_TAKEN_WINDOW seconds before the given timestamp.
 function OvaleDamageTaken:RemoveExpiredEvents(timestamp)
 	while true do
-		local event = self_damageEvent:Back()
+		local event = self.damageEvent:Back()
 		if not event then break end
 		if event then
 			if timestamp - event.timestamp < DAMAGE_TAKEN_WINDOW then
 				break
 			end
-			self_damageEvent:RemoveBack()
+			self.damageEvent:RemoveBack()
 			self_pool:Release(event)
 		end
 	end
 end

 function OvaleDamageTaken:Debug()
-	self_damageEvent:Debug()
-	for i, event in self_damageEvent:BackToFrontIterator() do
+	self.damageEvent:Debug()
+	for i, event in self.damageEvent:BackToFrontIterator() do
 		Ovale:FormatPrint("%d: %d damage", event.timestamp, event.damage)
 	end
 end
diff --git a/OvaleEnemies.lua b/OvaleEnemies.lua
index 64bbace..a18695d 100644
--- a/OvaleEnemies.lua
+++ b/OvaleEnemies.lua
@@ -24,11 +24,7 @@ local API_GetTime = GetTime
 local COMBATLOG_OBJECT_AFFILIATION_OUTSIDER = COMBATLOG_OBJECT_AFFILIATION_OUTSIDER
 local COMBATLOG_OBJECT_REACTION_HOSTILE = COMBATLOG_OBJECT_REACTION_HOSTILE

--- self_enemyLastSeen[guid] = timestamp
-local self_enemyLastSeen = {}
--- self_enemyName[guid] = name
-local self_enemyName = {}
--- timer for reaper function to remove inactive enemies
+-- Timer for reaper function to remove inactive enemies.
 local self_reaperTimer = nil
 local REAP_INTERVAL = 3

@@ -36,44 +32,15 @@ local OVALE_ENEMIES_DEBUG = "enemy"
 --</private-static-properties>

 --<public-static-properties>
+-- enemyLastSeen[guid] = timestamp
+OvaleEnemies.enemyLastSeen = {}
+-- enemyName[guid] = name
+OvaleEnemies.enemyName = {}
+
+-- Total number of active enemies.
 OvaleEnemies.activeEnemies = 0
 --</public-static-properties>

---<private-static-methods>
-local function AddEnemy(guid, name, timestamp)
-	if not guid then return end
-	local self = OvaleEnemies
-	local seen = self_enemyLastSeen[guid]
-	self_enemyLastSeen[guid] = timestamp
-	self_enemyName[guid] = name
-	if not seen then
-		self.activeEnemies = self.activeEnemies + 1
-		Ovale:DebugPrintf(OVALE_ENEMIES_DEBUG, "New enemy (%d total): %s (%s)", self.activeEnemies, guid, name)
-		Ovale.refreshNeeded["player"] = true
-	end
-end
-
-local function RemoveEnemy(guid, isDead)
-	if not guid then return end
-	local self = OvaleEnemies
-	local seen = self_enemyLastSeen[guid]
-	local name = self_enemyName[guid]
-	self_enemyLastSeen[guid] = nil
-	if seen then
-		if self.activeEnemies > 0 then
-			self.activeEnemies = self.activeEnemies - 1
-		end
-		if isDead then
-			Ovale:DebugPrintf(OVALE_ENEMIES_DEBUG, "Enemy died (%d total): %s (%s)", self.activeEnemies, guid, name)
-		else
-			Ovale:DebugPrintf(OVALE_ENEMIES_DEBUG, "Enemy removed (%d total): %s (%s), last seen at %f", self.activeEnemies, guid, name, seen)
-		end
-		self:SendMessage("Ovale_InactiveUnit", guid)
-		Ovale.refreshNeeded["player"] = true
-	end
-end
---</private-static-methods>
-
 --<public-static-methods>
 function OvaleEnemies:OnEnable()
 	if not self_reaperTimer then
@@ -96,22 +63,22 @@ function OvaleEnemies:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 	local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...)
 	local now = API_GetTime()
 	if event == "UNIT_DIED" then
-		RemoveEnemy(destGUID, true)
+		self:RemoveEnemy(destGUID, true)
 	elseif sourceFlags and bit_band(sourceFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) > 0
 			and bit_band(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) > 0
 			and destFlags and bit_band(destFlags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == 0 then
-		AddEnemy(sourceGUID, sourceName, now)
+		self:AddEnemy(sourceGUID, sourceName, now)
 	elseif destGUID and bit_band(destFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) > 0
 			and bit_band(destFlags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) > 0
 			and sourceFlags and bit_band(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == 0 then
-		AddEnemy(destGUID, destName, now)
+		self:AddEnemy(destGUID, destName, now)
 	end
 end

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

@@ -120,16 +87,47 @@ end
 -- incapacitated and shouldn't count toward the number of active enemies.
 function OvaleEnemies:RemoveInactiveEnemies()
 	local now = API_GetTime()
-	for guid, timestamp in pairs(self_enemyLastSeen) do
+	for guid, timestamp in pairs(self.enemyLastSeen) do
 		if now - timestamp > REAP_INTERVAL then
-			RemoveEnemy(guid)
+			self:RemoveEnemy(guid)
 		end
 	end
 end

+function OvaleEnemies:AddEnemy(guid, name, timestamp)
+	if not guid then return end
+	local seen = self.enemyLastSeen[guid]
+	self.enemyLastSeen[guid] = timestamp
+	self.enemyName[guid] = name
+	if not seen then
+		self.activeEnemies = self.activeEnemies + 1
+		Ovale:DebugPrintf(OVALE_ENEMIES_DEBUG, "New enemy (%d total): %s (%s)", self.activeEnemies, guid, name)
+		Ovale.refreshNeeded["player"] = true
+	end
+end
+
+function OvaleEnemies:RemoveEnemy(guid, isDead)
+	if not guid then return end
+	local seen = self.enemyLastSeen[guid]
+	local name = self.enemyName[guid]
+	self.enemyLastSeen[guid] = nil
+	if seen then
+		if self.activeEnemies > 0 then
+			self.activeEnemies = self.activeEnemies - 1
+		end
+		if isDead then
+			Ovale:DebugPrintf(OVALE_ENEMIES_DEBUG, "Enemy died (%d total): %s (%s)", self.activeEnemies, guid, name)
+		else
+			Ovale:DebugPrintf(OVALE_ENEMIES_DEBUG, "Enemy removed (%d total): %s (%s), last seen at %f", self.activeEnemies, guid, name, seen)
+		end
+		self:SendMessage("Ovale_InactiveUnit", guid)
+		Ovale.refreshNeeded["player"] = true
+	end
+end
+
 function OvaleEnemies:Debug()
-	for guid, timestamp in pairs(self_enemyLastSeen) do
-		Ovale:FormatPrint("enemy %s (%s) last seen at %f", guid, self_enemyName[guid], timestamp)
+	for guid, timestamp in pairs(self.enemyLastSeen) do
+		Ovale:FormatPrint("enemy %s (%s) last seen at %f", guid, self.enemyName[guid], timestamp)
 	end
 end
 --</public-static-methods>
diff --git a/OvaleEquipement.lua b/OvaleEquipement.lua
index 07e7856..f6f8dcb 100644
--- a/OvaleEquipement.lua
+++ b/OvaleEquipement.lua
@@ -49,17 +49,6 @@ local INVSLOT_TRINKET2 = INVSLOT_TRINKET2
 local INVSLOT_WAIST = INVSLOT_WAIST
 local INVSLOT_WRIST = INVSLOT_WRIST

--- item IDs of equipped items, indexed by slot ID
-local self_equippedItems = {}
--- item levels of equipped items, indexed by slot ID
-local self_equippedItemLevels = {}
--- 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 = {}
-
 -- frame for tooltip-scanning
 local self_tooltip = API_CreateFrame("GameTooltip", "OvaleScanningTooltip", nil, "GameTooltipTemplate")
 do
@@ -1286,6 +1275,17 @@ local OVALE_NORMALIZED_WEAPON_SPEED = {
 --</private-static-properties>

 --<public-static-properties>
+-- Item IDs of equipped items, indexed by slot ID.
+OvaleEquipement.equippedItems = {}
+-- Item levels of equipped items, indexed by slot ID.
+OvaleEquipement.equippedItemLevels = {}
+-- Type of main-hand item equipped.
+OvaleEquipement.mainHandItemType = nil
+-- Type of off-hand item equipped.
+OvaleEquipement.offHandItemType = nil
+-- Count of equipped pieces of an armor set: armorSetCount[armorSetName] = equippedCount
+OvaleEquipement.armorSetCount = {}
+
 -- Normalized weapon speeds for equipped mainhand and offhand weapons.
 OvaleEquipement.mainHandWeaponSpeed = nil
 OvaleEquipement.offHandWeaponSpeed = nil
@@ -1342,22 +1342,22 @@ end

 function OvaleEquipement:PLAYER_EQUIPMENT_CHANGED(event, slotId, hasItem)
 	if hasItem then
-		self_equippedItems[slotId] = API_GetInventoryItemID("player", slotId)
-		self_equippedItemLevels[slotId] = GetItemLevel(slotId)
+		self.equippedItems[slotId] = API_GetInventoryItemID("player", slotId)
+		self.equippedItemLevels[slotId] = GetItemLevel(slotId)
 		if slotId == INVSLOT_MAINHAND then
-			self_mainHandItemType = GetEquippedItemType(slotId)
+			self.mainHandItemType = GetEquippedItemType(slotId)
 			self.mainHandWeaponSpeed = self:HasMainHandWeapon() and GetNormalizedWeaponSpeed(INVSLOT_MAINHAND)
 		elseif slotId == INVSLOT_OFFHAND then
-			self_offHandItemType = GetEquippedItemType(slotId)
+			self.offHandItemType = GetEquippedItemType(slotId)
 			self.offHandWeaponSpeed = self:HasOffHandWeapon() and GetNormalizedWeaponSpeed(INVSLOT_OFFHAND)
 		end
 	else
-		self_equippedItems[slotId] = nil
-		self_equippedItemLevels[slotId] = nil
+		self.equippedItems[slotId] = nil
+		self.equippedItemLevels[slotId] = nil
 		if slotId == INVSLOT_MAINHAND then
-			self_mainHandItemType = nil
+			self.mainHandItemType = nil
 		elseif slotId == INVSLOT_OFFHAND then
-			self_offHandItemType = nil
+			self.offHandItemType = nil
 		end
 	end

@@ -1366,11 +1366,7 @@ function OvaleEquipement:PLAYER_EQUIPMENT_CHANGED(event, slotId, hasItem)
 end

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

 function OvaleEquipement:GetEquippedItem(slotId)
@@ -1379,7 +1375,7 @@ function OvaleEquipement:GetEquippedItem(slotId)
 		slotId = API_GetInventorySlotInfo(slotId)
 		if not slotId then return nil end
 	end
-	return self_equippedItems[slotId]
+	return self.equippedItems[slotId]
 end

 function OvaleEquipement:GetEquippedItemLevel(slotId)
@@ -1388,7 +1384,7 @@ function OvaleEquipement:GetEquippedItemLevel(slotId)
 		slotId = API_GetInventorySlotInfo(slotId)
 		if not slotId then return nil end
 	end
-	return self_equippedItemLevels[slotId]
+	return self.equippedItemLevels[slotId]
 end

 function OvaleEquipement:HasEquippedItem(itemId, slotId)
@@ -1397,11 +1393,11 @@ function OvaleEquipement:HasEquippedItem(itemId, slotId)
 		slotId = API_GetInventorySlotInfo(slotId)
 	end
 	if slotId then
-		if self_equippedItems[slotId] == itemId then
+		if self.equippedItems[slotId] == itemId then
 			return slotId
 		end
 	else
-		for slotId, equippedItemId in pairs(self_equippedItems) do
+		for slotId, equippedItemId in pairs(self.equippedItems) do
 			if equippedItemId == itemId then
 				return slotId
 			end
@@ -1411,18 +1407,18 @@ function OvaleEquipement:HasEquippedItem(itemId, slotId)
 end

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

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

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

 function OvaleEquipement:HasTrinket(itemId)
@@ -1431,25 +1427,25 @@ function OvaleEquipement:HasTrinket(itemId)
 end

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

 function OvaleEquipement:HasOneHandedWeapon()
-	return self_mainHandItemType == "INVTYPE_WEAPON"
-		or self_mainHandItemType == "INVTYPE_WEAPONMAINHAND"
+	return self.mainHandItemType == "INVTYPE_WEAPON"
+		or self.mainHandItemType == "INVTYPE_WEAPONMAINHAND"
 end

 function OvaleEquipement:UpdateArmorSetCount()
-	wipe(self_armorSetCount)
+	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 = OVALE_ARMORSET[itemId]
 			if name then
-				if not self_armorSetCount[name] then
-					self_armorSetCount[name] = 1
+				if not self.armorSetCount[name] then
+					self.armorSetCount[name] = 1
 				else
-					self_armorSetCount[name] = self_armorSetCount[name] + 1
+					self.armorSetCount[name] = self.armorSetCount[name] + 1
 				end
 			end
 		end
@@ -1461,13 +1457,13 @@ function OvaleEquipement:UpdateEquippedItems()
 	local item
 	for slotId = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
 		item = API_GetInventoryItemID("player", slotId)
-		if item ~= self_equippedItems[slotId] then
-			self_equippedItems[slotId] = item
+		if item ~= self.equippedItems[slotId] then
+			self.equippedItems[slotId] = item
 			changed = true
 		end
 	end
-	self_mainHandItemType = GetEquippedItemType(INVSLOT_MAINHAND)
-	self_offHandItemType = GetEquippedItemType(INVSLOT_OFFHAND)
+	self.mainHandItemType = GetEquippedItemType(INVSLOT_MAINHAND)
+	self.offHandItemType = GetEquippedItemType(INVSLOT_OFFHAND)
 	self.mainHandWeaponSpeed = self:HasMainHandWeapon() and GetNormalizedWeaponSpeed(INVSLOT_MAINHAND)
 	self.offHandWeaponSpeed = self:HasOffHandWeapon() and GetNormalizedWeaponSpeed(INVSLOT_OFFHAND)
 	self:UpdateEquippedItemLevels()
@@ -1483,8 +1479,8 @@ function OvaleEquipement:UpdateEquippedItemLevels()
 	local itemLevel
 	for slotId = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
 		itemLevel = GetItemLevel(slotId)
-		if itemLevel ~= self_equippedItemLevels[slotId] then
-			self_equippedItemLevels[slotId] = itemLevel
+		if itemLevel ~= self.equippedItemLevels[slotId] then
+			self.equippedItemLevels[slotId] = itemLevel
 			changed = true
 		end
 	end
@@ -1494,9 +1490,9 @@ function OvaleEquipement:Debug()
 	for slotId = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
 		Ovale:FormatPrint("Slot %d = %s (%d)", slotId, self:GetEquippedItem(slotId), self:GetEquippedItemLevel(slotId))
 	end
-	Ovale:FormatPrint("Main-hand item type: %s", self_mainHandItemType)
-	Ovale:FormatPrint("Off-hand item type: %s", self_offHandItemType)
-	for k, v in pairs(self_armorSetCount) do
+	Ovale:FormatPrint("Main-hand item type: %s", self.mainHandItemType)
+	Ovale:FormatPrint("Off-hand item type: %s", self.offHandItemType)
+	for k, v in pairs(self.armorSetCount) do
 		Ovale:FormatPrint("Player has %d piece(s) of %s armor set.", v, k)
 	end
 end
diff --git a/OvaleGUID.lua b/OvaleGUID.lua
index b708c10..0396bd0 100644
--- a/OvaleGUID.lua
+++ b/OvaleGUID.lua
@@ -23,15 +23,15 @@ local API_UnitExists = UnitExists
 local API_UnitGUID = UnitGUID
 local API_UnitName = UnitName

-local self_unitId = {}
-local self_guid = {}
-local self_nameToGUID = {}
-local self_nameToUnit = {}
-
 local OVALE_GUID_DEBUG = "guid"
 --</private-static-properties>

 --<public-static-properties>
+OvaleGUID.unitId = {}
+OvaleGUID.guid = {}
+OvaleGUID.nameToGUID = {}
+OvaleGUID.nameToUnit = {}
+
 -- Units for which UNIT_AURA is known to fire.
 -- These are unit IDs that correspond to unit frames in the default WoW UI.
 OvaleGUID.UNIT_AURA_UNITS = {}
@@ -88,50 +88,50 @@ end

 function OvaleGUID:Update(unitId)
 	local guid = API_UnitGUID(unitId)
-	local previousGuid = self_guid[unitId]
+	local previousGuid = self.guid[unitId]
 	if previousGuid ~= guid then
-		if previousGuid and self_unitId[previousGuid] then
-			self_unitId[previousGuid][unitId] = nil
-			if not next(self_unitId[previousGuid]) then
-				self_unitId[previousGuid] = nil
+		if previousGuid and self.unitId[previousGuid] then
+			self.unitId[previousGuid][unitId] = nil
+			if not next(self.unitId[previousGuid]) then
+				self.unitId[previousGuid] = nil
 			end
 		end
-		self_guid[unitId] = guid
+		self.guid[unitId] = guid
 		if guid then
-			if not self_unitId[guid] then
-				self_unitId[guid] = {}
+			if not self.unitId[guid] then
+				self.unitId[guid] = {}
 			end
 			Ovale:DebugPrintf(OVALE_GUID_DEBUG, "GUID %s is %s", guid, unitId)
-			self_unitId[guid][unitId] = true
+			self.unitId[guid][unitId] = true
 		end
 	end
 	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
-		self_nameToUnit[name] = unitId
+	if name and (not self.nameToGUID[name] or unitId == "target"
+			or self.nameToUnit[name] == "mouseover") then
+		self.nameToGUID[name] = guid
+		self.nameToUnit[name] = unitId
 	end
 end

 function OvaleGUID:GetGUID(unitId)
 	if not unitId then return nil end
-	local guid = self_guid[unitId]
+	local guid = self.guid[unitId]
 	if not guid or strfind(unitId, "mouseover") == 1 then
-		self_guid[unitId] = API_UnitGUID(unitId)
-		guid = self_guid[unitId]
+		self.guid[unitId] = API_UnitGUID(unitId)
+		guid = self.guid[unitId]
 	end
 	return guid
 end

 function OvaleGUID:GetGUIDForName(name)
-	return self_nameToGUID[name]
+	return self.nameToGUID[name]
 end

 -- Return a unit Id associated with guid.
 -- Prefer to return a unit Id for which the WoW servers fire UNIT_AURA events.
 function OvaleGUID:GetUnitId(guid)
 	local unitIdFound = nil
-	local unitIdTable = self_unitId[guid]
+	local unitIdTable = self.unitId[guid]
 	if unitIdTable then
 		for unitId in pairs(unitIdTable) do
 			if self.UNIT_AURA_UNITS[unitId] then
@@ -142,7 +142,7 @@ function OvaleGUID:GetUnitId(guid)
 						unitIdFound = unitId
 					else
 						unitIdTable[unitId] = nil
-						self_guid[unitId] = nil
+						self.guid[unitId] = nil
 					end
 				else
 					unitIdFound = unitId
@@ -154,12 +154,12 @@ function OvaleGUID:GetUnitId(guid)
 end

 function OvaleGUID:GetUnitIdForName(name)
-	local unitId = self_nameToUnit[name]
+	local unitId = self.nameToUnit[name]
 	if strfind(unitId, "mouseover") == 1 then
 		if API_UnitExists("mouseover") then
 			return unitId
 		else
-			self_nameToUnit[name] = nil
+			self.nameToUnit[name] = nil
 			return nil
 		end
 	end
diff --git a/OvaleLatency.lua b/OvaleLatency.lua
index a6bdfec..f69936e 100644
--- a/OvaleLatency.lua
+++ b/OvaleLatency.lua
@@ -15,14 +15,15 @@ Ovale.OvaleLatency = OvaleLatency
 local select = select
 local API_GetNetStats = GetNetStats
 local API_GetTime = GetTime
+--</private-static-properties>

+--<public-static-properties>
 -- The spell requests that have been sent to the server and are awaiting a reply.
--- self_sentSpellcast[lineId] = GetTime() timestamp
-local self_sentSpellcast = {}
-
-local self_lastUpdateTime = nil
-local self_latency = nil
---</private-static-properties>
+-- spellcast[lineId] = GetTime() timestamp
+OvaleLatency.spellcast = {}
+OvaleLatency.lastUpdateTime = nil
+OvaleLatency.latency = nil
+--</public-static-properties>

 --<public-static-methods>
 function OvaleLatency:OnEnable()
@@ -41,7 +42,7 @@ end

 -- Event handler for UNIT_SPELLCAST_* events that updates the current roundtrip latency.
 function OvaleLatency:UpdateLatency(event, unit, name, rank, lineId, spellId)
-	if unit == "player" and self_sentSpellcast[lineId] then
+	if unit == "player" and self.spellcast[lineId] then
 		--[[
 			Assume an event loop looks like:

@@ -52,19 +53,19 @@ function OvaleLatency:UpdateLatency(event, unit, name, rank, lineId, spellId)
 			network latency.  As a result, this will always over-estimate the true latency.
 		]]--
 		local now = API_GetTime()
-		local latency = now - self_sentSpellcast[lineId]
+		local latency = now - self.spellcast[lineId]
 		if latency > 0 then
-			self_latency = latency
-			self_lastUpdateTime = now
+			self.latency = latency
+			self.lastUpdateTime = now
 		end
-		self_sentSpellcast[lineId] = nil
+		self.spellcast[lineId] = nil
 	end
 end

 function OvaleLatency:UNIT_SPELLCAST_SENT(event, unit, spell, rank, target, lineId)
 	if unit == "player" then
 		-- Note starting time for latency calculation.
-		self_sentSpellcast[lineId] = API_GetTime()
+		self.spellcast[lineId] = API_GetTime()
 	end
 end

@@ -72,9 +73,9 @@ function OvaleLatency:GetLatency()
 	-- If we haven't cast a spell in a while, then get the average world roundtrip latency
 	-- using GetNetStats().
 	local now = API_GetTime()
-	if not self_latency or not self_lastUpdateTime or now - self_lastUpdateTime > 10 then
-		self_latency = select(4, API_GetNetStats()) / 1000
+	if not self.latency or not self.lastUpdateTime or now - self.lastUpdateTime > 10 then
+		self.latency = select(4, API_GetNetStats()) / 1000
 	end
-	return self_latency
+	return self.latency
 end
 --</public-static-methods>
diff --git a/OvaleScore.lua b/OvaleScore.lua
index 8f31f2f..7980e5a 100644
--- a/OvaleScore.lua
+++ b/OvaleScore.lua
@@ -38,27 +38,31 @@ local strsplit = string.split
 local API_RegisterAddonMessagePrefix = RegisterAddonMessagePrefix
 local API_SendAddonMessage = SendAddonMessage
 local API_UnitGUID = UnitGUID
+local API_UnitName = UnitName

 -- Player's GUID.
 local self_guid = nil
+-- Player's name.
+local self_name = nil
+--</private-static-properties>
+
+--<public-static-properties>
 -- self_damageMeter[moduleName] = module
-local self_damageMeter = {}
+OvaleScore.damageMeter = {}
 -- self_damageMeterMethod[moduleName] = methodName or function
-local self_damageMeterMethod = {}
+OvaleScore.damageMeterMethod = {}
 -- Score from current combat session.
-local self_score = 0
+OvaleScore.score = 0
 -- Maximum possible score from current combat session.
-local self_maxScore = 0
+OvaleScore.maxScore = 0
 -- Spells for which a score is computed.
-local self_scoredSpell = {}
---</private-static-properties>
-
---<public-static-properties>
+OvaleScore.scoredSpell = {}
 --</public-static-properties>

 --<public-static-methods>
 function OvaleScore:OnEnable()
 	self_guid = API_UnitGUID("player")
+	self_name = API_UnitName("player")
 	API_RegisterAddonMessagePrefix("Ovale")
 	self:RegisterEvent("CHAT_MSG_ADDON")
 	self:RegisterEvent("PLAYER_REGEN_ENABLED")
@@ -84,15 +88,15 @@ end
 function OvaleScore:PLAYER_REGEN_ENABLED()
 	-- Broadcast the player's own score for damage meters when combat ends.
 	-- Broadcast message is "score;maxScore;playerGUID"
-	if self_maxScore > 0 then
-		local message = self_score .. ";" .. self_maxScore .. ";" .. self_guid
+	if self.maxScore > 0 then
+		local message = self.score .. ";" .. self.maxScore .. ";" .. self_guid
 		API_SendAddonMessage("Ovale", message, "RAID")
 	end
 end

 function OvaleScore:PLAYER_REGEN_DISABLED()
-	self_score = 0
-	self_maxScore = 0
+	self.score = 0
+	self.maxScore = 0
 end

 -- RegisterDamageMeter(moduleName, function) or
@@ -101,35 +105,35 @@ function OvaleScore:RegisterDamageMeter(moduleName, addon, func)
 	if not func then
 		func = addon
 	elseif addon then
-		self_damageMeter[moduleName] = addon
+		self.damageMeter[moduleName] = addon
 	end
-	self_damageMeterMethod[moduleName] = func
+	self.damageMeterMethod[moduleName] = func
 end

 function OvaleScore:UnregisterDamageMeter(moduleName)
-	self_damageMeter[moduleName] = nil
-	self_damageMeterMethod[moduleName] = nil
+	self.damageMeter[moduleName] = nil
+	self.damageMeterMethod[moduleName] = nil
 end

 function OvaleScore:AddSpell(spellId)
-	self_scoredSpell[spellId] = true
+	self.scoredSpell[spellId] = true
 end

 function OvaleScore:ScoreSpell(spellId)
-	if Ovale.enCombat and self_scoredSpell[spellId] then
+	if Ovale.enCombat and self.scoredSpell[spellId] then
 		local scored = Ovale.frame:GetScore(spellId)
 		Ovale:Logf("Scored %s", scored)
 		if scored then
-			self_score = self_score + scored
-			self_maxScore = self_maxScore + 1
-			self:SendScore(self_playerName, self_guid, scored, 1)
+			self.score = self.score + scored
+			self.maxScore = self.maxScore + 1
+			self:SendScore(self_name, self_guid, scored, 1)
 		end
 	end
 end

 function OvaleScore:SendScore(name, guid, scored, scoreMax)
-	for moduleName, method in pairs(self_damageMeterMethods) do
-		local addon = self_damageMeter[moduleName]
+	for moduleName, method in pairs(self.damageMeterMethod) do
+		local addon = self.damageMeter[moduleName]
 		if addon then
 			addon[method](addon, name, guid, scored, scoreMax)
 		elseif type(method) == "function" then
diff --git a/OvaleStance.lua b/OvaleStance.lua
index 3e80173..9627fd2 100644
--- a/OvaleStance.lua
+++ b/OvaleStance.lua
@@ -25,11 +25,6 @@ local API_GetShapeshiftForm = GetShapeshiftForm
 local API_GetShapeshiftFormInfo = GetShapeshiftFormInfo
 local API_GetSpellInfo = GetSpellInfo

--- 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
 	[API_GetSpellInfo(48263)] = "death_knight_blood_presence",
@@ -72,6 +67,13 @@ local OVALE_SPELLID_TO_STANCE = {
 }
 --</private-static-properties>

+--<public-static-properties>
+-- List of available stances, populated by CreateStanceList()
+OvaleStance.stanceList = {}
+-- Player's current stance.
+OvaleStance.stance = nil
+--</public-static-properties>
+
 --<public-static-methods>
 function OvaleStance:OnEnable()
 	self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "UpdateStances")
@@ -101,15 +103,15 @@ function OvaleStance:UPDATE_SHAPESHIFT_FORMS(event)
 	self:ShapeshiftEventHandler()
 end

--- Fill self_stanceList with stance bar index <-> Ovale stance name mappings.
+-- Fill OvaleStance.stanceList with stance bar index <-> Ovale stance name mappings.
 function OvaleStance:CreateStanceList()
-	wipe(self_stanceList)
+	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
-			self_stanceList[i] = stanceName
+			self.stanceList[i] = stanceName
 		end
 	end
 end
@@ -117,8 +119,8 @@ end
 -- Print out the list of stances in alphabetical order.
 function OvaleStance:DebugStances()
 	local array = {}
-	for k, v in pairs(self_stanceList) do
-		if self_stance == k then
+	for k, v in pairs(self.stanceList) do
+		if self.stance == k then
 			tinsert(array, v .. " (active)")
 		else
 			tinsert(array, v)
@@ -131,28 +133,28 @@ function OvaleStance:DebugStances()
 end

 function OvaleStance:Debug()
-	Ovale:FormatPrint("current stance: %s", self_stance)
+	Ovale:FormatPrint("current stance: %s", self.stance)
 end

 -- Return the current stance's name.
 function OvaleStance:GetStance()
-	return self_stanceList[self_stance]
+	return self.stanceList[self.stance]
 end

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

 function OvaleStance:ShapeshiftEventHandler()
 	local newStance = API_GetShapeshiftForm()
-	if self_stance ~= newStance then
-		self_stance = newStance
+	if self.stance ~= newStance then
+		self.stance = newStance
 		self:SendMessage("Ovale_StanceChanged")
 	end
 end
diff --git a/OvaleState.lua b/OvaleState.lua
index a94f2dd..8e1d8ee 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -24,12 +24,13 @@ local OvaleData = nil
 local OvaleFuture = nil

 local pairs = pairs
-
-local self_statePrototype = {}
-local self_stateModules = OvaleQueue:NewQueue("OvaleState_stateModules")
 --</private-static-properties>

 --<public-static-properties>
+-- Registered state prototypes from which mix-in methods are added to state machines.
+OvaleState.statePrototype = {}
+OvaleState.stateAddons = OvaleQueue:NewQueue("OvaleState_stateAddons")
+
 -- The state for the simulator.
 OvaleState.state = {}
 --</public-static-properties>
@@ -50,9 +51,9 @@ function OvaleState:OnDisable()
 end


-function OvaleState:RegisterState(addon, statePrototype)
-	self_stateModules:Insert(addon)
-	self_statePrototype[addon] = statePrototype
+function OvaleState:RegisterState(stateAddon, statePrototype)
+	self.stateAddons:Insert(stateAddon)
+	self.statePrototype[stateAddon] = statePrototype

 	-- Mix-in addon's state prototype into OvaleState.state.
 	for k, v in pairs(statePrototype) do
@@ -60,31 +61,31 @@ function OvaleState:RegisterState(addon, statePrototype)
 	end
 end

-function OvaleState:UnregisterState(addon)
+function OvaleState:UnregisterState(stateAddon)
 	stateModules = OvaleQueue:NewQueue("OvaleState_stateModules")
-	while self_stateModules:Size() > 0 do
-		local stateAddon = self_stateModules:Remove()
+	while self.stateAddons:Size() > 0 do
+		local addon = self.stateAddons:Remove()
 		if stateAddon ~= addon then
 			stateModules:Insert(addon)
 		end
 	end
-	self_stateModules = stateModules
+	self.stateAddons = stateModules

 	-- Release resources used by the state machine managed by the addon.
-	if addon.CleanState then
-		addon:CleanState(self.state)
+	if stateAddon.CleanState then
+		stateAddon:CleanState(self.state)
 	end

 	-- Remove mix-in methods from addon's state prototype.
-	local statePrototype = self_statePrototype[addon]
+	local statePrototype = self.statePrototype[stateAddon]
 	for k in pairs(statePrototype) do
 		self.state[k] = nil
 	end
-	self_stateModules[addon] = nil
+	self.statePrototype[stateAddon] = nil
 end

 function OvaleState:InvokeMethod(methodName, ...)
-	for _, addon in self_stateModules:Iterator() do
+	for _, addon in self.stateAddons:Iterator() do
 		if addon[methodName] then
 			addon[methodName](addon, ...)
 		end