Index: trunk/src/bindings/scripts/include/sc_creature.cpp
===================================================================
--- trunk/src/bindings/scripts/include/sc_creature.cpp (revision 229)
+++ trunk/src/bindings/scripts/include/sc_creature.cpp (revision 257)
@@ -680,11 +680,9 @@
     }
 
-    InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-    InstanceMap::PlayerList::const_iterator i;
-    for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
-    {
-        if((*i)->isAlive())
-            pUnit->AddThreat(*i, 0.0f);
-    }
+    Map::PlayerList const &PlayerList = map->GetPlayers();
+    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+        if (Player* i_pl = i->getSource())
+            if (!i_pl->isAlive())
+                pUnit->AddThreat(i_pl, 0.0f);
 }
 
@@ -721,4 +719,18 @@
     ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
 }
+
+void ScriptedAI::DoTeleportAll(float x, float y, float z, float o)
+{
+    Map *map = m_creature->GetMap();
+    if (!map->IsDungeon())
+        return;
+
+    Map::PlayerList const &PlayerList = map->GetPlayers();
+    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+        if (Player* i_pl = i->getSource())
+            if (!i_pl->isAlive())
+                i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
+}
+
 
 Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
Index: trunk/src/bindings/scripts/include/sc_creature.h
===================================================================
--- trunk/src/bindings/scripts/include/sc_creature.h (revision 203)
+++ trunk/src/bindings/scripts/include/sc_creature.h (revision 257)
@@ -147,4 +147,5 @@
     //Teleports a player without dropping threat (only teleports to same map)
     void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o);
+    void DoTeleportAll(float x, float y, float z, float o);
 
     //Returns friendly unit with the most amount of hp missing from max hp
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp (revision 141)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp (revision 257)
@@ -119,7 +119,4 @@
     void SetData(uint32 type, uint32 data)
     {
-        Player *player = GetPlayer();
-        if(!player) return;
-
         switch(type)
         {
@@ -130,5 +127,5 @@
             if(data != IN_PROGRESS)
             {
-                if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID))
+                if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
                     Door->SetGoState(0);
             }
@@ -143,5 +140,5 @@
                     for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                     {
-                        if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i))
+                        if(Creature *Channeler = instance->GetCreatureInMap(*i))
                         {
                             if(Channeler->isAlive())
@@ -152,5 +149,5 @@
                     }
                     CageTimer = 0;
-                    if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID))
+                    if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
                         Door->SetGoState(0);
                 }break;
@@ -162,5 +159,5 @@
                     for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                     {
-                        Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i);
+                        Creature *Channeler = instance->GetCreatureInMap(*i);
                         if(Channeler && Channeler->isAlive())
                         {
@@ -171,5 +168,5 @@
                     }
                     // Release Magtheridon after two minutes.
-                    Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID);
+                    Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID);
                     if(Magtheridon && Magtheridon->isAlive())
                     {
@@ -177,5 +174,5 @@
                         CageTimer = 120000;
                     }
-                    if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID))
+                    if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
                         Door->SetGoState(1);
                 }break;
@@ -183,5 +180,5 @@
                 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                 {
-                    Unit *Channeler = Unit::GetUnit(*player, *i);
+                    Creature *Channeler = instance->GetCreatureInMap(*i);
                     if(Channeler && Channeler->isAlive())
                     {
@@ -198,5 +195,5 @@
             for(std::set<uint64>::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i)
             {
-                if(GameObject *Column = GameObject::GetGameObject(*player, *i))
+                if(GameObject *Column = instance->GetGameObjectInMap(*i))
                     Column->SetGoState(!data);
             }
@@ -214,11 +211,4 @@
     }
 
-    Player* GetPlayer()
-    {
-        if(((InstanceMap*)instance)->GetPlayers().size())
-            return ((InstanceMap*)instance)->GetPlayers().front();
-        return NULL;
-    }
-
     void AttackNearestTarget(Creature *creature)
     {
@@ -226,16 +216,19 @@
         float range;
         Player* target = NULL;
-        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)instance)->GetPlayers();
-        InstanceMap::PlayerList::const_iterator i;
+        Map::PlayerList const &PlayerList = instance->GetPlayers();
+        Map::PlayerList::const_iterator i;
         for(i = PlayerList.begin(); i != PlayerList.end(); ++i)
         {
-            if((*i)->isTargetableForAttack())
-            {
-                range = (*i)->GetDistance(creature);
-                if(range < minRange)
-                {
-                    minRange = range;
-                    target = *i;
-                }                
+            if(Player* i_pl = i->getSource())
+            {
+                if(i_pl->isTargetableForAttack())
+                {
+                    range = i_pl->GetDistance(creature);
+                    if(range < minRange)
+                    {
+                        minRange = range;
+                        target = i_pl;
+                    }                
+                }
             }
         }
@@ -249,12 +242,9 @@
             if(CageTimer <= diff)
             {
-                if(Player *player = GetPlayer())
-                {
-                    Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID);
-                    if(Magtheridon && Magtheridon->isAlive())
-                    {
-                        Magtheridon->clearUnitState(UNIT_STAT_STUNNED);
-                        AttackNearestTarget(Magtheridon);
-                    }
+                Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID);
+                if(Magtheridon && Magtheridon->isAlive())
+                {
+                    Magtheridon->clearUnitState(UNIT_STAT_STUNNED);
+                    AttackNearestTarget(Magtheridon);
                 }
                 CageTimer = 0;
@@ -266,15 +256,12 @@
             if(RespawnTimer <= diff)
             {
-                if(Player *player = GetPlayer())
-                {
-                    for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
-                    {
-                        if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i))
-                        {
-                            if(Channeler->isAlive())
-                                Channeler->AI()->EnterEvadeMode();
-                            else
-                                Channeler->Respawn();
-                        }
+                for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
+                {
+                    if(Creature *Channeler = instance->GetCreatureInMap(*i))
+                    {
+                        if(Channeler->isAlive())
+                            Channeler->AI()->EnterEvadeMode();
+                        else
+                            Channeler->Respawn();
                     }
                 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp (revision 206)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp (revision 257)
@@ -578,18 +578,21 @@
                 if(!map->IsDungeon()) return;
 
-                InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-                for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
-                {
-                    //Play random sound to the zone
-                    switch (rand()%8)
+                Map::PlayerList const &PlayerList = map->GetPlayers();
+                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+                {
+                    if (Player* i_pl = i->getSource())
                     {
-                        case 0: (*i)->SendPlaySound(RND_WISPER_1, true); break;
-                        case 1: (*i)->SendPlaySound(RND_WISPER_2, true); break;
-                        case 2: (*i)->SendPlaySound(RND_WISPER_3, true); break;
-                        case 3: (*i)->SendPlaySound(RND_WISPER_4, true); break;
-                        case 4: (*i)->SendPlaySound(RND_WISPER_5, true); break;
-                        case 5: (*i)->SendPlaySound(RND_WISPER_6, true); break;
-                        case 6: (*i)->SendPlaySound(RND_WISPER_7, true); break;
-                        case 7: (*i)->SendPlaySound(RND_WISPER_8, true); break;
+                        //Play random sound to the zone
+                        switch (rand()%8)
+                        {
+                            case 0: i_pl->SendPlaySound(RND_WISPER_1, true); break;
+                            case 1: i_pl->SendPlaySound(RND_WISPER_2, true); break;
+                            case 2: i_pl->SendPlaySound(RND_WISPER_3, true); break;
+                            case 3: i_pl->SendPlaySound(RND_WISPER_4, true); break;
+                            case 4: i_pl->SendPlaySound(RND_WISPER_5, true); break;
+                            case 5: i_pl->SendPlaySound(RND_WISPER_6, true); break;
+                            case 6: i_pl->SendPlaySound(RND_WISPER_7, true); break;
+                            case 7: i_pl->SendPlaySound(RND_WISPER_8, true); break;
+                        }
                     }
                 }
Index: trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp (revision 239)
+++ trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp (revision 257)
@@ -369,11 +369,10 @@
         Map *map = m_creature->GetMap();
         if(!map->IsDungeon()) return;
-        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-        InstanceMap::PlayerList::const_iterator i;
-        for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
-        {
-            if((*i)->HasAura(AURA_SPECTRAL_REALM,0))
-                (*i)->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM);
-        }
+        Map::PlayerList const &PlayerList = map->GetPlayers();
+        Map::PlayerList::const_iterator i;
+        for(i = PlayerList.begin(); i != PlayerList.end(); ++i)
+            if(Player* i_pl = i->getSource())
+                if(i_pl->HasAura(AURA_SPECTRAL_REALM,0))
+                    i_pl->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM);
     }
 
Index: trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp (revision 122)
+++ trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp (revision 257)
@@ -296,5 +296,5 @@
             break;
         case 2:
-            if(Player* target = SelectRandomPlayer(150))
+            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
             {
                 Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
@@ -312,5 +312,5 @@
             DespawnSummons(MOB_VAPOR_TRAIL);
             //m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support
-            if(Player* target = SelectRandomPlayer(150))
+            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
             {
                 //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support
@@ -331,5 +331,5 @@
             break;
         case 5:
-            if(Player* target = SelectRandomPlayer(150))
+            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
             {
                 BreathX = target->GetPositionX();
@@ -434,5 +434,5 @@
                 break;
             case EVENT_ENCAPSULATE:
-                if(Unit* target = SelectRandomPlayer(150))
+                if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
                 {
                     m_creature->CastSpell(target, SPELL_ENCAPSULATE_CHANNEL, false);
@@ -516,24 +516,4 @@
         }
     }
-
-    Player* SelectRandomPlayer(float range = 0.0f)
-    {
-        Map *map = m_creature->GetMap();
-        if (!map->IsDungeon()) return NULL;
-
-        InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers();
-        InstanceMap::PlayerList::iterator i;
-        while(PlayerList.size())
-        {
-            i = PlayerList.begin();
-            advance(i, rand()%PlayerList.size());
-            if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range))
-                && (*i)->isTargetableForAttack())
-                return *i;
-            else
-                PlayerList.erase(i);
-        }
-        return NULL;
-    }
 };
 
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp (revision 257)
@@ -221,16 +221,5 @@
         if ( DrawnShadows_Timer < diff)
         {
-            Map *map = m_creature->GetMap();
-            if(map->IsDungeon())
-            {
-                InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-                for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
-                {
-                    if((*i)->isAlive())
-                    {
-                        (*i)->TeleportTo(555,VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0);
-                    }
-                }
-            }
+            DoTeleportAll(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0);
             m_creature->Relocate(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0);
             DoCast(m_creature,SPELL_DRAWN_SHADOWS,true);
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp (revision 257)
@@ -755,17 +755,20 @@
 		{
 			Map *map = m_creature->GetMap();
-			InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-			for(InstanceMap::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr)
+			Map::PlayerList const &PlayerList = map->GetPlayers();
+			for(Map::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr)
             {
-				bool isCasting = false;
-				for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
-					if((*itr)->m_currentSpells[i])
-						isCasting = true;
-				
-				if(isCasting)
-				{
-					DoCast((*itr), SPELL_EARTHSHOCK);
-					break;
-				}
+                if (Player* i_pl = itr->getSource())
+                {
+				    bool isCasting = false;
+				    for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
+					    if(i_pl->m_currentSpells[i])
+						    isCasting = true;
+    				
+				    if(isCasting)
+				    {
+					    DoCast(i_pl, SPELL_EARTHSHOCK);
+					    break;
+				    }
+                }
 			}
 			Earthshock_Timer = 8000 + rand()%7000;
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp (revision 257)
@@ -251,10 +251,10 @@
 			//remove old tainted cores to prevent cheating in phase 2
 			Map *map = m_creature->GetMap();
-			InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-			for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
-            {
-                if((*i))
+			Map::PlayerList const &PlayerList = map->GetPlayers();
+			for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
+            {
+                if(Player* i_pl = i->getSource())
                 {
-                    (*i)->DestroyItemCount(31088, 1, true);
+                    i_pl->DestroyItemCount(31088, 1, true);
                 }
             }
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp (revision 257)
@@ -286,12 +286,12 @@
                     if(!map->IsDungeon()) return;
 
-                    InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-                    if(PlayerList.empty())
+                    Map::PlayerList const &PlayerList = map->GetPlayers();
+                    if(PlayerList.isEmpty())
                         return;
 
                     RaidWiped = true;
-                    for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
+                    for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
                     {
-                        if((*i)->isAlive() && !(*i)->isGameMaster())
+                        if (i->getSource()->isAlive() && !i->getSource()->isGameMaster())
                         {
                             RaidWiped = false;
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp (revision 257)
@@ -398,9 +398,10 @@
             Map *map = m_creature->GetMap();
             if(!map->IsDungeon()) return;
-            InstanceMap::PlayerList const &PlayerList =((InstanceMap*)map)->GetPlayers();
-            for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
-            {
-                if((*i)->isAlive())
-                    DoTeleportPlayer(*i, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0);
+            Map::PlayerList const &PlayerList = map->GetPlayers();
+            for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+            {
+                if (Player* i_pl = i->getSource())
+                    if(i_pl->isAlive())
+                        DoTeleportPlayer(i_pl, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0);
             }
             //m_creature->CastSpell(Temp, SPELL_SUMMON_PLAYERS, true); // core bug, spell does not work if too far
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp (revision 202)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp (revision 257)
@@ -372,5 +372,5 @@
         if(SiphonSoul_Timer < diff)
         {
-            Player* target = SelectRandomPlayer(50);
+            Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 70, true);
             Unit *trigger = DoSpawnCreature(MOB_TEMP_TRIGGER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
             if(!target || !trigger) EnterEvadeMode();
@@ -436,24 +436,4 @@
         m_creature->CastSpell(target, PlayerAbility[PlayerClass][random].spell, false);
     }
-
-    Player* SelectRandomPlayer(float range = 0.0f, bool alive = true)
-    {
-        Map *map = m_creature->GetMap();
-        if (!map->IsDungeon()) return NULL;
-
-        InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers();
-        InstanceMap::PlayerList::iterator i;
-        while(PlayerList.size())
-        {
-            i = PlayerList.begin();
-            advance(i, rand()%PlayerList.size());
-            if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range))
-                && (!alive || (*i)->isAlive()))
-                return *i;
-            else
-                PlayerList.erase(i);
-        }
-        return NULL;
-    }
 };
 
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp (revision 257)
@@ -140,19 +140,26 @@
     void OpenDoor(uint64 DoorGUID, bool open)
     {
-        if(((InstanceMap*)instance)->GetPlayers().size())
-            if(Player* first = ((InstanceMap*)instance)->GetPlayers().front())
-                if(GameObject *Door = GameObject::GetGameObject(*first, DoorGUID))
-                    Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1);
+        if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
+            Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1);
     }
 
     void SummonHostage(uint8 num)
     {
-        if(QuestMinute && ((InstanceMap*)instance)->GetPlayers().size())
-            if(Player* first = ((InstanceMap*)instance)->GetPlayers().front())
-                if(Unit* Hostage = first->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0))
-                {
-                    Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
-                    Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
-                }
+        if(!QuestMinute)
+            return;
+
+        Map::PlayerList const &PlayerList = instance->GetPlayers();
+        if (PlayerList.isEmpty())
+            return;
+
+        Map::PlayerList::const_iterator i = PlayerList.begin();
+        if(Player* i_pl = i->getSource())
+        {
+            if(Unit* Hostage = i_pl->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0))
+            {
+                Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+                Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+            }
+        }
     }
 
Index: trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp (revision 137)
+++ trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp (revision 257)
@@ -232,15 +232,15 @@
         m_creature->Relocate(KaelLocations[0][0], KaelLocations[0][1], LOCATION_Z, 0);
 		Map *map = m_creature->GetMap();
-        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-		InstanceMap::PlayerList::const_iterator i;
+        Map::PlayerList const &PlayerList = map->GetPlayers();
+		Map::PlayerList::const_iterator i;
 		for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
 		{
-			//if(!(*i)->isGameMaster())
-			if((*i) && (*i)->isAlive())
-			{
-				(*i)->CastSpell((*i), SPELL_TELEPORT_CENTER, true);
-				m_creature->GetNearPoint(m_creature,x,y,z,5,5,0);
-				(*i)->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,(*i)->GetOrientation());
-			}
+			if (Player* i_pl = i->getSource())
+			    if(i_pl->isAlive())
+			    {
+				    i_pl->CastSpell(i_pl, SPELL_TELEPORT_CENTER, true);
+				    m_creature->GetNearPoint(m_creature,x,y,z,5,5,0);
+				    i_pl->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,i_pl->GetOrientation());
+			    }
         }
         DoCast(m_creature, SPELL_TELEPORT_CENTER, true);
@@ -250,11 +250,12 @@
     {
 		Map *map = m_creature->GetMap();
-        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-		InstanceMap::PlayerList::const_iterator i;
+        Map::PlayerList const &PlayerList = map->GetPlayers();
+		Map::PlayerList::const_iterator i;
 		for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
-		{            
-			if((*i) && (*i)->isAlive())
+		{
+            if (Player* i_pl = i->getSource())
+			    if(i_pl->isAlive())
                 // Knockback into the air
-                (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID());
+                    i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID());
         }
     }
@@ -263,39 +264,42 @@
     {
 		Map *map = m_creature->GetMap();
-		InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-		InstanceMap::PlayerList::const_iterator i;
+		Map::PlayerList const &PlayerList = map->GetPlayers();
+		Map::PlayerList::const_iterator i;
+		for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
+		{
+            if (Player* i_pl = i->getSource())
+            {
+			    if(i_pl->isAlive())
+                {
+                    // Also needs an exception in spell system.
+                    i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID());
+                    // Use packet hack
+                    WorldPacket data(12);
+                    data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
+                    data.append(i_pl->GetPackGUID());
+                    data << uint32(0);
+                    i_pl->SendMessageToSet(&data, true);
+				    i_pl->SetSpeed(MOVE_FLY, 2.0f);
+                }
+            }
+        }
+    }
+
+    void RemoveGravityLapse()
+    {
+		Map *map = m_creature->GetMap();
+        Map::PlayerList const &PlayerList = map->GetPlayers();
+		Map::PlayerList::const_iterator i;
 		for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
 		{ 
-			if((*i) && (*i)->isAlive())
+            if(Player* i_pl = i->getSource())
             {
-                // Also needs an exception in spell system.
-                (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID());
-                // Use packet hack
-                WorldPacket data(12);
-                data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
-                data.append((*i)->GetPackGUID());
-                data << uint32(0);
-                (*i)->SendMessageToSet(&data, true);
-				(*i)->SetSpeed(MOVE_FLY, 2.0f);
-            }
-        }
-    }
-
-    void RemoveGravityLapse()
-    {
-		Map *map = m_creature->GetMap();
-        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
-		InstanceMap::PlayerList::const_iterator i;
-		for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
-		{ 
-            if((*i))
-            {
-                (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY);
-                (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT);
+                i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY);
+                i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT);
                 WorldPacket data(12);
                 data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY);
-                data.append((*i)->GetPackGUID());
+                data.append(i_pl->GetPackGUID());
                 data << uint32(0);
-                (*i)->SendMessageToSet(&data, true);
+                i_pl->SendMessageToSet(&data, true);
             }
         }
