diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c
index a614f23d3fbaa85a782fcd220be483069011a88d..8a217c3e96d98496d5b094ba3a1d817ab83e7e1d 100644
--- a/src/conio/bitmap_con.c
+++ b/src/conio/bitmap_con.c
@@ -814,15 +814,16 @@ bitmap_draw_vmem(int sx, int sy, int ex, int ey, struct vmem_cell *fill)
 
 	size_t xoffset = (sx-1) * vstat.charwidth;
 	size_t yoffset = (sy-1) * vstat.charheight;
+	bs.expand = vstat.flags & VIDMODES_FLAG_EXPAND;
+	bs.font_data_width = vstat.charwidth - (bs.expand ? 1 : 0);
+
+	pthread_mutex_lock(&screenlock);
 	assert(xoffset + vstat.charwidth <= screena.screenwidth);
 	assert(xoffset + vstat.charwidth <= screenb.screenwidth);
 	assert(yoffset + vstat.charheight <= screena.screenheight);
 	assert(yoffset + vstat.charheight <= screenb.screenheight);
 	bs.maxpix = screena.screenwidth * screena.screenheight;
-	bs.expand = vstat.flags & VIDMODES_FLAG_EXPAND;
-	bs.font_data_width = vstat.charwidth - (bs.expand ? 1 : 0);
 
-	pthread_mutex_lock(&screenlock);
 	bs.pixeloffset = pixel_offset(&screena, xoffset, yoffset);
 	bs.cheat_colour = fill[0].bg;
 	size_t rsz = screena.screenwidth - vstat.charwidth * vwidth;
@@ -971,6 +972,13 @@ static void blinker_thread(void *data)
 		lfc = force_cursor;
 		force_cursor = 0;
 		blink = vstat.blink;
+		pthread_mutex_lock(&screenlock);
+		if (screena.rect == NULL) {
+			pthread_mutex_unlock(&screenlock);
+			do_rwlock_unlock(&vstatlock);
+			continue;
+		}
+		pthread_mutex_unlock(&screenlock);
 		do_rwlock_unlock(&vstatlock);
 
 		if (check_redraw()) {
diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c
index a44d7c9a2b575e1740a4aa21605faa1686e757ab..50e1de544b92c3b81dd4c023a1ecef80a476250d 100644
--- a/src/conio/sdl_con.c
+++ b/src/conio/sdl_con.c
@@ -756,8 +756,8 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs)
 	if(keyval <= 0xffff) {
 		pthread_mutex_lock(&sdl_keylock);
 		if(sdl_keynext+1==sdl_key) {
-			beep();
 			pthread_mutex_unlock(&sdl_keylock);
+			beep();
 			return;
 		}
 		if((sdl_keynext+2==sdl_key) && keyval > 0xff) {
@@ -990,7 +990,7 @@ void sdl_video_event_thread(void *data)
 							}
 							else {
 								if (bios_key >= 26 ||
-								    (bios_key == 429496729 && ((ev.key.keysym.sym > SDLK_KP_5) || (ev.key.keysym.sym == SDLK_KP_0)))) {
+								    (bios_key == 25 && ((ev.key.keysym.sym > SDLK_KP_5) || (ev.key.keysym.sym == SDLK_KP_0)))) {
 									terminate_bios = true;
 								}
 							}
@@ -1146,8 +1146,10 @@ void sdl_video_event_thread(void *data)
 					case SDL_WINDOWEVENT_SIZE_CHANGED:
 						// SDL2: User resized window
 					case SDL_WINDOWEVENT_RESIZED:
+						pthread_mutex_lock(&win_mutex);
 						fullscreen = !!(sdl.GetWindowFlags(win) & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP));
 						sdl.SetWindowResizable(win, fullscreen ? SDL_FALSE : SDL_TRUE);
+						pthread_mutex_unlock(&win_mutex);
 						cio_api.mode=fullscreen?CIOLIB_MODE_SDL_FULLSCREEN:CIOLIB_MODE_SDL;
 						pthread_mutex_lock(&sdl_mode_mutex);
 						if (sdl_mode) {
@@ -1326,17 +1328,17 @@ void sdl_video_event_thread(void *data)
 					case SDL_USEREVENT_INIT:
 						if(!sdl_init_good) {
 							if(sdl.WasInit(SDL_INIT_VIDEO)==SDL_INIT_VIDEO) {
-								pthread_mutex_lock(&win_mutex);
 								_beginthread(sdl_mouse_thread, 0, NULL);
 								sdl_init_good=1;
-								pthread_mutex_unlock(&win_mutex);
 							}
 						}
 						sdl_ufunc_retval=0;
 						sem_post(&sdl_ufunc_ret);
 						break;
 					case SDL_USEREVENT_GETWINPOS:
+						pthread_mutex_lock(&win_mutex);
 						sdl.GetWindowPosition(win, ev.user.data1, ev.user.data2);
+						pthread_mutex_unlock(&win_mutex);
 						sem_post(&sdl_ufunc_ret);
 						break;
 					case SDL_USEREVENT_MOUSEPOINTER:
@@ -1380,8 +1382,6 @@ void sdl_video_event_thread(void *data)
 				break;
 		}
 	}
-	sdl.QuitSubSystem(SDL_INIT_VIDEO);
-	return;
 }
 
 static int
diff --git a/src/xpdev/Common.gmake b/src/xpdev/Common.gmake
index 1bf8c62a71b3968bfb4c61cb2536feb8bcbac526..283b14578ee57595d4e86f6091a39c69258dc1fb 100644
--- a/src/xpdev/Common.gmake
+++ b/src/xpdev/Common.gmake
@@ -218,6 +218,11 @@ ifndef WITHOUT_ALSA_SOUND
 	ifeq ($(shell if [ -f /usr/include/alsa/asoundlib.h ] ; then echo YES ; fi),YES)
 		XPDEV-MT_CFLAGS	+= -DUSE_ALSA_SOUND
 		XPDEV-MT_LIBS += -ldl
+	else
+		ifeq ($(shell if [ -f /usr/local/include/alsa/asoundlib.h ] ; then echo YES ; fi),YES)
+			XPDEV-MT_CFLAGS	+= -DUSE_ALSA_SOUND
+			XPDEV-MT_LIBS += -ldl
+		endif
 	endif
 endif
 
diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c
index 0937e62c35c75f4ae42bbe3d8cb7e99581dbaf90..af4b60eb125b6b4334694b2fe90b7091122b4e18 100644
--- a/src/xpdev/genwrap.c
+++ b/src/xpdev/genwrap.c
@@ -1147,8 +1147,10 @@ int64_t xp_fast_timer64(void)
 	}
 	cid = CLOCK_MONOTONIC_RAW;
 #endif
+#ifdef CLOCK_MONOTONIC
 	if (cid == CLOCK_REALTIME)
 		cid = CLOCK_MONOTONIC;
+#endif
 
 	if (clock_gettime(cid, &ts) == 0)
 		ret = ts.tv_sec;