diff --git a/dlls/advapi32/advapi.c b/dlls/advapi32/advapi.c
index 0a934bca73a41bded6685d06d6bf371e23123e2a..646f0f8625017323818c32a72c1fc946d37e7975 100644
--- a/dlls/advapi32/advapi.c
+++ b/dlls/advapi32/advapi.c
@@ -8,10 +8,10 @@
 #include <unistd.h>
 #include <string.h>
 
+#include "winbase.h"
 #include "windef.h"
 #include "winerror.h"
 #include "wine/winestring.h"
-#include "heap.h"
 
 #include "debugtools.h"
 
diff --git a/dlls/advapi32/eventlog.c b/dlls/advapi32/eventlog.c
index f0b21519ebb90633e8d4f170bab09d0809321cf7..cc74f29fa544a015c6ab808fc8483ae0ee46f2bc 100644
--- a/dlls/advapi32/eventlog.c
+++ b/dlls/advapi32/eventlog.c
@@ -4,6 +4,7 @@
  * Copyright 1995 Sven Verdoolaege, 1998 Juergen Schmied
  */
 
+#include "winbase.h"
 #include "windef.h"
 #include "winreg.h"
 #include "winerror.h"
diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c
index 3dbc987e566df3fae102a8ab42ae8b4a15b9b463..63a792ef8453a7a99a310efcb594b7a0646f64a5 100644
--- a/dlls/avifil32/avifile.c
+++ b/dlls/avifil32/avifile.c
@@ -5,8 +5,8 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include "vfw.h"
 #include "winbase.h"
+#include "vfw.h"
 #include "wine/winestring.h"
 #include "driver.h"
 #include "mmsystem.h"
diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c
index ceb20d9db3946b27ebc56665eacd0cf56f848c2d..f7ad3c50c2e53c2e326d232d12db266a80dad525 100644
--- a/dlls/comctl32/propsheet.c
+++ b/dlls/comctl32/propsheet.c
@@ -761,6 +761,7 @@ static void PROPSHEET_Changed(HWND hwndDlg, HWND hwndDirtyPage)
   PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
                                                     PropSheetInfoStr);
 
+  if (!psInfo) return;
   /*
    * Set the dirty flag of this page.
    */
diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c
index 9e98165109034d6987931851471cefb592250974..0b7215b5579ad9c50962a02ad8bf6a8ca3ea288e 100644
--- a/dlls/comctl32/trackbar.c
+++ b/dlls/comctl32/trackbar.c
@@ -167,6 +167,7 @@ TRACKBAR_CalcThumb (HWND hwnd, TRACKBAR_INFO *infoPtr)
 	
     thumb=&infoPtr->rcThumb;
     range=infoPtr->nRangeMax - infoPtr->nRangeMin;
+    if (!range) return; /* FIXME: may this happen? */
     if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) {
     	width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
         thumb->left  = infoPtr->rcChannel.left - 1;
diff --git a/dlls/version/resource.c b/dlls/version/resource.c
index d3c68a03e1ace0bc31cc8e975b270f8094908268..9701ea88ed4acfde2985bf7202ad79b5c511accb 100644
--- a/dlls/version/resource.c
+++ b/dlls/version/resource.c
@@ -9,13 +9,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "peexe.h"
 #include "neexe.h"
 #include "module.h"
 #include "winver.h"
-#include "heap.h"
 #include "lzexpand.h"
-#include "peexe.h"
 #include "debugtools.h"
 
 DEFAULT_DEBUG_CHANNEL(ver)
diff --git a/if1632/relay.c b/if1632/relay.c
index 94f079b18dded744654623d824e5bae44ac74c32..ec8d32bc9fb0885fe4a4f446bd8915017ddc10d5 100644
--- a/if1632/relay.c
+++ b/if1632/relay.c
@@ -13,6 +13,7 @@
 #include "module.h"
 #include "stackframe.h"
 #include "task.h"
+#include "syslevel.h"
 #include "debugstr.h"
 #include "debugtools.h"
 #include "main.h"
diff --git a/include/win.h b/include/win.h
index a3b0a00b70a41d7cb8a743f6b7c204b6994bb1a7..4b0c708218d43f6420392d1dddc230516fc1cd8b 100644
--- a/include/win.h
+++ b/include/win.h
@@ -7,6 +7,7 @@
 #ifndef __WINE_WIN_H
 #define __WINE_WIN_H
 
+#include "winuser.h"
 #include "queue.h"
 #include "class.h"
 
diff --git a/loader/elf.c b/loader/elf.c
index d4ba4e93436a998c8d48dc01a4feefff3ea28a25..d4f9af6aebfafa50187859511e016c6ad7b30813 100644
--- a/loader/elf.c
+++ b/loader/elf.c
@@ -114,8 +114,10 @@ WINE_MODREF *ELF_LoadLibraryExA( LPCSTR libname, DWORD flags, DWORD *err)
 	if (!s)
 		s=strrchr(libname,'\\');
 	if (s) {
-		strncpy(t,libname,s-libname+1);
-		t[s-libname+1]= '\0';
+		s++; /* skip / or \ */
+		/* copy everything up to s-1 */
+		memcpy(t,libname,s-libname);
+		t[s-libname]= '\0';
 	} else
 		s = (LPSTR)libname;
 	modname = s;
diff --git a/loader/pe_image.c b/loader/pe_image.c
index 36d16b4118631c7d625cc9cff09c107ede178d2e..8892f158e8fdaf2f7ab38392249a2ceed3525200 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -422,14 +422,8 @@ static void do_relocations( unsigned int load_addr, IMAGE_BASE_RELOCATION *r )
 				*(short*)(page+offset) += ldelta;
 				break;
 			case IMAGE_REL_BASED_HIGHLOW:
-#if 1
 				*(int*)(page+offset) += delta;
-#else
-				{ int h=*(unsigned short*)(page+offset);
-				  int l=r->TypeOffset[++i];
-				  *(unsigned int*)(page + offset) = (h<<16) + l + delta;
-				}
-#endif
+				/* FIXME: if this is an exported address, fire up enhanced logic */
 				break;
 			case IMAGE_REL_BASED_HIGHADJ:
 				FIXME_(win32)("Don't know what to do with IMAGE_REL_BASED_HIGHADJ\n");
diff --git a/misc/crtdll.c b/misc/crtdll.c
index 98d93f4143623de25ba205d54efe2549ed4793c4..e1ced3e1341cf80700e20325fa308dce6de2632e 100644
--- a/misc/crtdll.c
+++ b/misc/crtdll.c
@@ -247,6 +247,10 @@ DWORD __cdecl CRTDLL__initterm(_INITTERMFUN *start,_INITTERMFUN *end)
 	return 0;
 }
 
+CRTDLL_FILE * __cdecl CRTDLL__fsopen(LPCSTR x, LPCSTR y, INT z) {
+	FIXME("(%s,%s,%d),stub!\n",x,y,z);
+	return NULL;
+}
 /*********************************************************************
  *                  _fdopen     (CRTDLL.91)
  */
diff --git a/misc/shell.c b/misc/shell.c
index e22f21bd41f01382ddccbb582be7dde90fe9c532..6a1765550f499228ca9a78ad030ccc5cacad7f75 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -23,6 +23,7 @@
 #include "shlobj.h"
 #include "debugtools.h"
 #include "winreg.h"
+#include "syslevel.h"
 #include "imagelist.h"
 
 DECLARE_DEBUG_CHANNEL(exec)
diff --git a/multimedia/dsound.c b/multimedia/dsound.c
index 9165664a659c474c6b32659c76c0a8d0ed7d089b..2cd37c5e492f45b123563e023ac8f00e9e160836 100644
--- a/multimedia/dsound.c
+++ b/multimedia/dsound.c
@@ -2277,7 +2277,7 @@ HRESULT WINAPI DirectSoundCreate(REFGUID lpGUID,LPDIRECTSOUND *ppDS,IUnknown *pU
 		} else if (errno == EBUSY) {
 			MSG("Sound device busy, will keep trying.\n");
 		} else {
-			MSG("Unexpected error while checking for sound support.\n");
+			MSG("Unexpected error (%d) while checking for sound support.\n",errno);
 			return DSERR_GENERIC;
 		}
 	} else {
diff --git a/relay32/crtdll.spec b/relay32/crtdll.spec
index 94ce21dc8f78c1341fd345ba362543ad8597ffb4..e851f43057daf4aaf91bd6fc9400e8282f320494 100644
--- a/relay32/crtdll.spec
+++ b/relay32/crtdll.spec
@@ -112,7 +112,7 @@ init    CRTDLL_Init
 107 cdecl _fpreset() CRTDLL__fpreset
 108 stub _fputchar
 109 stub _fputwchar
-110 stub _fsopen
+110 cdecl _fsopen(str str long) CRTDLL__fsopen
 111 cdecl _fstat(long ptr) CRTDLL__fstat
 112 stub _ftime
 113 cdecl _ftol() CRTDLL__ftol
diff --git a/windows/dinput.c b/windows/dinput.c
index 35e2d3f8408c7d5d266f91f0d14e4cea767883f1..b77d203f5b4d1b82543d64fc5e90343cf593e6d7 100644
--- a/windows/dinput.c
+++ b/windows/dinput.c
@@ -517,6 +517,7 @@ static HRESULT WINAPI IDirectInputDevice2AImpl_GetCapabilities(
 	LPDIRECTINPUTDEVICE2A iface,
 	LPDIDEVCAPS lpDIDevCaps)
 {
+	lpDIDevCaps->dwFlags = DIDC_ATTACHED;
 	FIXME(dinput, "stub!\n");
 	return DI_OK;
 }