diff --git a/client/BattleInterface/CBattleInterface.cpp b/client/BattleInterface/CBattleInterface.cpp
index 45ef7cada..b886b78d1 100644
--- a/client/BattleInterface/CBattleInterface.cpp
+++ b/client/BattleInterface/CBattleInterface.cpp
@@ -633,13 +633,13 @@ void CBattleInterface::show(SDL_Surface * to)
 					}
 				}
 				//patch by ench0
-				const CStack * const shere = curInt->cb->battleGetStackByPos(b, false);
 
-				// display the movement shadow of the stack at b (i.e. stack under mouse)
-				if(shere && shere->alive())
+				// activeStack == NULL means it is opponent's turn...
+				if(activeStack)
 				{
-					// activeStack == NULL means it is opponent's turn...
-					if (activeStack && shere != activeStack)
+					// display the movement shadow of the stack at b (i.e. stack under mouse)
+					const CStack * const shere = curInt->cb->battleGetStackByPos(b, false);
+					if (shere && shere != activeStack && shere->alive())
 					{
 						std::vector<BattleHex> v = curInt->cb->battleGetAvailableHexes(shere, true );
 						BOOST_FOREACH (BattleHex hex, v)
@@ -892,12 +892,6 @@ void CBattleInterface::show(SDL_Surface * to)
 	bWait->showAll(to);
 	bDefence->showAll(to);
 
-	//showing window with result of battle
-	if(resWindow)
-	{
-		resWindow->show(to);
-	}
-
 	//showing in-game console
 	LOCPLINT->cingconsole->show(to);
 
diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp
index 2b39616a8..b5ee85a59 100644
--- a/client/CAdvmapInterface.cpp
+++ b/client/CAdvmapInterface.cpp
@@ -65,7 +65,7 @@ CMinimap::CMinimap()
 	pos.h=ADVOPT.minimapW;
 	pos.w=ADVOPT.minimapH;
 
-	temps = CSDL_Ext::createSurfaceWithBpp<3>(pos.w,pos.h);
+	temps = CSDL_Ext::createSurfaceWithBpp<4>(pos.w,pos.h);
 	aiShield = new CPicture("AISHIELD.bmp");
 
 	const JsonNode config(GameConstants::DATA_DIR + "/config/minimap.json");
@@ -228,7 +228,7 @@ void CMinimapSurfacesRef::initFoW(int level)
 				int3 pp( ((i*mapSizes.x)/mw), ((j*mapSizes.y)/mh), d );
 				if ( !LOCPLINT->cb->isVisible(pp) )
 				{
-					CSDL_Ext::SDL_PutPixelWithoutRefresh(pt,i,j,0,0,0,0);
+					CSDL_Ext::SDL_PutPixelWithoutRefresh(pt,i,j,0,0,0);
 				}
 			}
 		}
@@ -457,7 +457,7 @@ void CMinimap::hideTile(const int3 &pos)
 		for (int jj=0; jj<ho; jj++)
 		{
 			if ((pos.x*wo+ii<this->pos.w) && (pos.y*ho+jj<this->pos.h))
-				CSDL_Ext::SDL_PutPixelWithoutRefresh(FoW[pos.z],pos.x*wo+ii,pos.y*ho+jj,0,0,0,255);
+				CSDL_Ext::SDL_PutPixelWithoutRefresh(FoW[pos.z],pos.x*wo+ii,pos.y*ho+jj,0,0,0);
 		}
 	}
 }
diff --git a/client/CMT.cpp b/client/CMT.cpp
index 3b2b74711..5d68ab527 100644
--- a/client/CMT.cpp
+++ b/client/CMT.cpp
@@ -70,7 +70,6 @@ SDL_Surface *screen = NULL, //main screen surface
 	*screenBuf = screen; //points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
 static boost::thread *mainGUIThread;
 
-VCMIDirs GVCMIDirs;
 std::queue<SDL_Event*> events;
 boost::mutex eventsM;
 
diff --git a/client/CVideoHandler.cpp b/client/CVideoHandler.cpp
index 69e5cab0b..c80f3a850 100644
--- a/client/CVideoHandler.cpp
+++ b/client/CVideoHandler.cpp
@@ -697,7 +697,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 	else
 		filePath = GameConstants::DATA_DIR + "/Data/video/" + fname;
 
-#if LIBAVFORMAT_VERSION_MAJOR < 53
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 0, 0)
 	int avfopen = av_open_input_file(&format, filePath.c_str(), NULL, 0, NULL);
 #else
 	int avfopen = avformat_open_input(&format, filePath.c_str(), NULL, NULL);
@@ -708,7 +708,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 		return false;
 	}
 	// Retrieve stream information
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 17, 0)
 	if (av_find_stream_info(format) < 0)
 #else
 	if (avformat_find_stream_info(format, NULL) < 0)
@@ -719,7 +719,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 	stream = -1;
 	for(ui32 i=0; i<format->nb_streams; i++)
 	{
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 0, 0)
 		if (format->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO)
 #else
 		if (format->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
@@ -747,7 +747,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 	}
   
 	// Open codec
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 17, 0)
 	if ( avcodec_open(codecContext, codec) < 0 )
 #else
 	if ( avcodec_open2(codecContext, codec, NULL) < 0 )
@@ -846,12 +846,7 @@ bool CVideoPlayer::nextFrame()
 			if (packet.stream_index == stream)
 			{
 				// Decode video frame
-#ifdef WITH_AVCODEC_DECODE_VIDEO2
 				avcodec_decode_video2(codecContext, frame, &frameFinished, &packet);
-#else
-				avcodec_decode_video(codecContext, frame, &frameFinished, 
-									 packet.data, packet.size);
-#endif
 
 				// Did we get a video frame?
 				if (frameFinished)
@@ -975,7 +970,7 @@ void CVideoPlayer::close()
 
 	if (format)
 	{
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 17, 0)
 		av_close_input_file(format);
 		format = NULL;
 #else
diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp
index 38da57837..ce674b5db 100644
--- a/lib/BattleState.cpp
+++ b/lib/BattleState.cpp
@@ -786,9 +786,11 @@ std::set<CStack*> BattleInfo::getAttackedCreatures(const CSpell * s, int skillLe
 		BOOST_FOREACH (auto stack, stacks)
 		{
 			if (stack->isValidTarget())
-			BOOST_FOREACH (auto hex, stack->getHexes())
 			{
-				possibleHexes.insert (hex);
+				BOOST_FOREACH (auto hex, stack->getHexes())
+				{
+					possibleHexes.insert (hex);
+				}
 			}
 		}
 		BattleHex lightningHex =  destinationTile;
diff --git a/lib/CLodHandler.cpp b/lib/CLodHandler.cpp
index 7e8f5d617..c0e46b63b 100644
--- a/lib/CLodHandler.cpp
+++ b/lib/CLodHandler.cpp
@@ -8,7 +8,7 @@
 #undef max
 #endif
 
-VCMIDirs GVCMIDirs;
+extern VCMIDirs GVCMIDirs;
 
 /*
  * CLodHandler.cpp, part of VCMI engine
diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp
index e84dab1e3..17ff09764 100644
--- a/lib/VCMI_Lib.cpp
+++ b/lib/VCMI_Lib.cpp
@@ -14,6 +14,7 @@
 #include "CGeneralTextHandler.h"
 #include "IGameEventsReceiver.h"
 #include "CStopWatch.h"
+#include "VCMIDirs.h"
 
 /*
  * VCMI_Lib.cpp, part of VCMI engine
@@ -31,6 +32,8 @@ DLL_LINKAGE CLodHandler *bitmaph = NULL,
 	*spriteh = NULL,
 	*bitmaph_ab = NULL;
 
+VCMIDirs GVCMIDirs;
+
 
 DLL_LINKAGE void initDLL(CConsoleHandler *Console, std::ostream *Logfile)
 {
diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp
index acf96324b..0b97cecdc 100644
--- a/server/CVCMIServer.cpp
+++ b/server/CVCMIServer.cpp
@@ -33,7 +33,6 @@ using namespace boost::asio::ip;
 namespace intpr = boost::interprocess;
 bool end2 = false;
 int port = 3030;
-VCMIDirs GVCMIDirs;
 
 /*
  * CVCMIServer.cpp, part of VCMI engine