Release 980329

Sun Mar 29 15:18:57 1998  Uwe Bonnes <elektron.ikp.physik.tu-darmstadt.de>

	* [msdos/int21.c]
	More verbose Trace messages

Sun Mar 29 15:03:30 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [loader/ne_image.c]
	Terminate relocation chains on 0 offset.

Sun Mar 29 02:35:45 1998  James Juran  <jrj120@psu.edu>

	* [windows/caret.c] [windows/class.c] [windows/clipboard.c]
	Fixed more USER32 ordinal numbers in function documentation.

Sat Mar 28 22:40:23 1997  Andreas Mohr <100.30936@germany.net>

	* [controls/desktop.c]
	Return 1 for WM_NCCREATE in DesktopWndProc.

	* [controls/menu.c]
	Fixed crash when destroying a top popup win that was only created
	but not shown.

	* [ole/typelib.c] [if1632/typelib.spec]
	Implemented OABuildVersion.

	* [windows/win.c]
	Finally fixed ugly bug in GetParent32 that affected window placement:
	Didn't return 0 for windows that have neither WS_POPUP nor
	WS_CHILD set. Now it acts exactly like Windows (at least I hope so ;)

Sat Mar 28 02:26:43 1998  Dimitrie O. Paun  <dimi@mail.cs.toronto.edu>

	* [DEVELOPERS-HINTS] [documentation/debug-msgs]
	Updated documentation on debug messages

	* [include/button.h] [controls/button.c] [include/windows.h]
	[include/combo.h] [controls/combo.c] [controls/commctrl.c]
	[controls/icontitle.c] [controls/listbox.c]	[controls/menu.c]
	[controls/scroll.c] [controls/widgets.c] 
	Changed some 16-bit code to 32-bit code. I am positive this will
	not break anything.

	* [controls/uitools.c] 
	Renamed the prefix of some functions from UITOOLS_ to UITOOLS95_
	to reflect the fact that they implement Win95 look. Maybe we will
	have a UITOOLS31_ in the future. Anyhow, the change is completely
	internal to this file.

	* [*/*.c]
	Changed a lot of [f]printf into appropriate debug messages.

Fri Mar 27 19:56:12 1998  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
	* [documentation/status/]
	Added directdraw and directsound status.

	* [if1632/thunk.c][ole/*.c][win32/kernel32.c]
	Added some documentation.
	Moved FUNC004 to thunk.c since it seems to be a 16->32 thunk
	(calling conventions and the like still unknown).

Fri Mar 27 09:59:32 1998  Morten Eriksen  <mortene@pvv.org>

	* [loader/resource.c][windows/keyboard.c]
	Implemented CopyAcceleratorTable() and CreateAcceleratorTable().
	
	* [include/compobj.h][ole/compobj.c][relay32/ole32.spec]
	Added implementation of StringFromGUID2(). 

Tue Mar 26 23:12:05 1998  Eric Kohl <ekohl@abo.rhein-zeitung.de>

	* [misc/imagelist.c][relay32/comctl32.spec]
	Implemented new debugging interface.
	Added missing functions (some are empty stubs).
	Changed ordinals in comctl32.spec (now dll version 4.72 comatible).

	* [objects/oembitmaps.c][include/windows.h]
	  [include/bitmaps/*]
	Added missing restore bitmaps for Win95 look.
	Added missing Win95 cursors.

Thu Mar 26 10:18:20 1998  Douglas Ridgway  <ridgway@winehq.com>

	* [programs/view/Makefile.in] [programs/view/view.c]
	Fix compilation, Aldus placeable metafile loading.

	* [graphics/metafiledrv/init.c] [relay32/gdi32.spec] 
	  [objects/metafile.c]
	Implemented various 32 bit versions of regular metafile API.

	* [objects/enhmetafile.c]
	Implemented rendering of a couple of dozen records.

Tue Mar 24 20:06:39 1998  Matthew Becker <mbecker@glasscity.net>

	* [memory/*.c]
	Updated documentation for API manpages.

Mon Mar 23 09:09:00 1998  Alex Korobka <alex@pharm.sunysb.edu>

	* [misc/winsock.c]
	Fixed 32-bit DNS lookup.

Mon Mar 23 23:54:47 1998  Luiz Otavio L. Zorzella  <zorzella@nr.conexware.com>

	* [multimedia/init.c]
	New code for the initialization and gathering of information about
	the MIDI devices, for future use.

Thu Mar 19 00:59:29 1998  Jim Peterson <jspeter@nospam.birch.ee.vt.edu>

	* [windows/win.c]
	Eliminated inaccurate setting of cs->hMenu in
	WIN_CreateWindowEx, along with superfluous SetMenu32 call.

Mon Mar 16 17:40:53 1998  Petter Reinholdtsen <pere@td.org.uit.no>

	* [debugger/dbg.y] [debugger/Makefile.in] [Makefile.in]
	Install wine.sym in $(exec_prefix)/lib and make sure the debugger
	finds it.

Sun Mar 15 22:36:35 1998  Michael Veksler <mveksler@tx.technion.ac.il>

	* [dummy.c] [if1632/gdi.spec]
	Fixed stub declaration of GDI_532, so Hebrew-Word2 kind of works.
diff --git a/ANNOUNCE b/ANNOUNCE
index 3eb02e4..002be69 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,14 +1,14 @@
-This is release 980315 of Wine, the MS Windows emulator.  This is still a
+This is release 980329 of Wine, the MS Windows emulator.  This is still a
 developer's only release.  There are many bugs and many unimplemented API
 features.  Most applications still do not work correctly.
 
 Patches should be submitted to "julliard@lrc.epfl.ch".  Please don't
 forget to include a ChangeLog entry.
 
-WHAT'S NEW with Wine-980315: (see ChangeLog for details)
-	- Preliminary ImageLists support.
-	- Beginnings of enhanced metafiles.
-	- More debugging macros changes.
+WHAT'S NEW with Wine-980329: (see ChangeLog for details)
+	- More ImageLists support.
+	- More Win32 metafile support.
+	- Still some debugging output changes.
 	- Lots of bug fixes.
 
 See the README file in the distribution for installation instructions.
@@ -17,10 +17,10 @@
 the release is available at the ftp sites.  The sources will be available
 from the following locations:
 
-  ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-980315.tar.gz
-  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-980315.tar.gz
-  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-980315.tar.gz
-  ftp://ftp.progsoc.uts.edu.au/pub/Wine/development/Wine-980315.tar.gz
+  ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-980329.tar.gz
+  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-980329.tar.gz
+  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-980329.tar.gz
+  ftp://ftp.progsoc.uts.edu.au/pub/Wine/development/Wine-980329.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/ChangeLog b/ChangeLog
index 71d6ec2..dc618c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,132 @@
 ----------------------------------------------------------------------
+Sun Mar 29 15:18:57 1998  Uwe Bonnes <elektron.ikp.physik.tu-darmstadt.de>
+
+	* [msdos/int21.c]
+	More verbose Trace messages
+
+Sun Mar 29 15:03:30 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>
+
+	* [loader/ne_image.c]
+	Terminate relocation chains on 0 offset.
+
+Sun Mar 29 02:35:45 1998  James Juran  <jrj120@psu.edu>
+
+	* [windows/caret.c] [windows/class.c] [windows/clipboard.c]
+	Fixed more USER32 ordinal numbers in function documentation.
+
+Sat Mar 28 22:40:23 1997  Andreas Mohr <100.30936@germany.net>
+
+	* [controls/desktop.c]
+	Return 1 for WM_NCCREATE in DesktopWndProc.
+
+	* [controls/menu.c]
+	Fixed crash when destroying a top popup win that was only created
+	but not shown.
+
+	* [ole/typelib.c] [if1632/typelib.spec]
+	Implemented OABuildVersion.
+
+	* [windows/win.c]
+	Finally fixed ugly bug in GetParent32 that affected window placement:
+	Didn't return 0 for windows that have neither WS_POPUP nor
+	WS_CHILD set. Now it acts exactly like Windows (at least I hope so ;)
+
+Sat Mar 28 02:26:43 1998  Dimitrie O. Paun  <dimi@mail.cs.toronto.edu>
+
+	* [DEVELOPERS-HINTS] [documentation/debug-msgs]
+	Updated documentation on debug messages
+
+	* [include/button.h] [controls/button.c] [include/windows.h]
+	[include/combo.h] [controls/combo.c] [controls/commctrl.c]
+	[controls/icontitle.c] [controls/listbox.c]	[controls/menu.c]
+	[controls/scroll.c] [controls/widgets.c] 
+	Changed some 16-bit code to 32-bit code. I am positive this will
+	not break anything.
+
+	* [controls/uitools.c] 
+	Renamed the prefix of some functions from UITOOLS_ to UITOOLS95_
+	to reflect the fact that they implement Win95 look. Maybe we will
+	have a UITOOLS31_ in the future. Anyhow, the change is completely
+	internal to this file.
+
+	* [*/*.c]
+	Changed a lot of [f]printf into appropriate debug messages.
+
+Fri Mar 27 19:56:12 1998  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
+	* [documentation/status/]
+	Added directdraw and directsound status.
+
+	* [if1632/thunk.c][ole/*.c][win32/kernel32.c]
+	Added some documentation.
+	Moved FUNC004 to thunk.c since it seems to be a 16->32 thunk
+	(calling conventions and the like still unknown).
+
+Fri Mar 27 09:59:32 1998  Morten Eriksen  <mortene@pvv.org>
+
+	* [loader/resource.c][windows/keyboard.c]
+	Implemented CopyAcceleratorTable() and CreateAcceleratorTable().
+	
+	* [include/compobj.h][ole/compobj.c][relay32/ole32.spec]
+	Added implementation of StringFromGUID2(). 
+
+Tue Mar 26 23:12:05 1998  Eric Kohl <ekohl@abo.rhein-zeitung.de>
+
+	* [misc/imagelist.c][relay32/comctl32.spec]
+	Implemented new debugging interface.
+	Added missing functions (some are empty stubs).
+	Changed ordinals in comctl32.spec (now dll version 4.72 comatible).
+
+	* [objects/oembitmaps.c][include/windows.h]
+	  [include/bitmaps/*]
+	Added missing restore bitmaps for Win95 look.
+	Added missing Win95 cursors.
+
+Thu Mar 26 10:18:20 1998  Douglas Ridgway  <ridgway@winehq.com>
+
+	* [programs/view/Makefile.in] [programs/view/view.c]
+	Fix compilation, Aldus placeable metafile loading.
+
+	* [graphics/metafiledrv/init.c] [relay32/gdi32.spec] 
+	  [objects/metafile.c]
+	Implemented various 32 bit versions of regular metafile API.
+
+	* [objects/enhmetafile.c]
+	Implemented rendering of a couple of dozen records.
+
+Tue Mar 24 20:06:39 1998  Matthew Becker <mbecker@glasscity.net>
+
+	* [memory/*.c]
+	Updated documentation for API manpages.
+
+Mon Mar 23 09:09:00 1998  Alex Korobka <alex@pharm.sunysb.edu>
+
+	* [misc/winsock.c]
+	Fixed 32-bit DNS lookup.
+
+Mon Mar 23 23:54:47 1998  Luiz Otavio L. Zorzella  <zorzella@nr.conexware.com>
+
+	* [multimedia/init.c]
+	New code for the initialization and gathering of information about
+	the MIDI devices, for future use.
+
+Thu Mar 19 00:59:29 1998  Jim Peterson <jspeter@nospam.birch.ee.vt.edu>
+
+	* [windows/win.c]
+	Eliminated inaccurate setting of cs->hMenu in
+	WIN_CreateWindowEx, along with superfluous SetMenu32 call.
+
+Mon Mar 16 17:40:53 1998  Petter Reinholdtsen <pere@td.org.uit.no>
+
+	* [debugger/dbg.y] [debugger/Makefile.in] [Makefile.in]
+	Install wine.sym in $(exec_prefix)/lib and make sure the debugger
+	finds it.
+
+Sun Mar 15 22:36:35 1998  Michael Veksler <mveksler@tx.technion.ac.il>
+
+	* [dummy.c] [if1632/gdi.spec]
+	Fixed stub declaration of GDI_532, so Hebrew-Word2 kind of works.
+
+----------------------------------------------------------------------
 Sun Mar 15 03:46:50 1998  Dimitrie O. Paun  <dimi@mail.cs.toronto.edu>
 
 	* [*/*]
diff --git a/DEVELOPERS-HINTS b/DEVELOPERS-HINTS
index 7f68ba4..40ccb6a 100644
--- a/DEVELOPERS-HINTS
+++ b/DEVELOPERS-HINTS
@@ -198,47 +198,41 @@
 To display a message only during debugging, you normally write something
 like this:
 
-#ifdef DEBUG_WIN
-	printf("abc...");
-#endif
+        TRACE(win,"abc...");  or
+        FIXME(win,"abc...");  or
+        WARN(win,"abc...");   or
+        ERR(win,"abc...");
 
-You can write this shorter (and better) in this way:
+depending on the seriousness of the problem. (documentation/degug-msgs
+explains when it is appropriate to use each of them)
 
-	dprintf_win(stddeb,"abc...");
+These macros are defined in include/debug.h. The macro-definitions are
+generated by the shell-script tools/make_debug. It scans the source
+code for symbols of this forms and puts the necessary macro
+definitions in include/debug.h and include/debugdefs.h. These macros
+test whether the debugging "channel" associated with the first
+argument of these macros (win in the above example) is enabled and
+thus decide whether to actually display the text.  In addition you can
+change the types of displayed messages by supplying the "-debugmsg"
+option to Wine.  If your debugging code is more complex than just
+printf, you can use the symbols TRACE_ON(xxx), WARN_ON(xxx),
+ERR_ON(xxx) and FIXME_ON(xxx) as well. These are true when channel xxx
+is enabled, either permanent or in the command line. Thus, you can
+write:
 
-All symbols of the form dprintf_xxxx are macros defined in include/debug.h .
-The macro-definitions are generated by the shell-script tools/make_debug. It
-scans the source code for symbols of this forms and puts the necessary
-macro definitions in include/debug.h and include/stddebug.h . These macros
-test for the symbol DEBUG_XXXX (e.g. dprintf_win refers to DEBUG_WIN) being 
-defined and thus decided whether to actually display the text. If you want
-to enable specific types of messages, simply put the corresponding
-#define DEBUG_XXXX in include/stddebug.h . If you want to enable or disable
-a specific type of message in just one c-source-file, put the corresponding 
-#define DEBUG_XXXX or #undefine DEBUG_XXXX between #include<stddebug.h> and
-#include <debug.h> in that specific file. In addition you can change the 
-types of displayed messages by supplying the "-debugmsg" option to Wine. 
-If your debugging code is more complex than just printf, you can use the
-symbols debugging_XXX as well. These are true when XXX is enabled, either
-permanent or in the command line. So instead of writing
+	if(TRACE_ON(win))DumpSomeStructure(&str);
 
-#ifdef DEBUG_WIN
-	DumpSomeStructure(&str);
-#endif
-
-write
-	if(debugging_win)DumpSomeStructure(&str);
 Don't worry about the inefficiency of the test. If it is permanently 
-disabled (thus debugging_win is 0 at compile time), the compiler will 
+disabled (that is TRACE_ON(win) is 0 at compile time), the compiler will 
 eliminate the dead code.
 
-The file handle "stddeb" is intended for displaying standard informational
-messages, whereas "stdnimp" is intended for displaying messages concerning
-not yet implemented functions.
-
 You have to start tools/make_debug only if you introduced a new macro,
-e.g.  dprintf_win32s - not if you just changed one of the #define
-DEBUG_XXX's in include/stddebug.h or in a specific file.
+e.g.  TRACE(win32).
+
+For more info about debugging messages, read:
+
+documentation/debug-msgs
+
 
 MORE INFO
 =========
diff --git a/Makefile.in b/Makefile.in
index 342073f..2b65fae 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -121,6 +121,7 @@
 
 install_emu: install_lib
 	$(INSTALL_PROGRAM) wine $(bindir)/wine
+	$(INSTALL_DATA) wine.sym $(libdir)/wine.sym
 
 install_lib: install_includes
 	$(INSTALL_DATA) $(LIB_TARGET) $(libdir)
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
deleted file mode 100644
index 7959da3..0000000
--- a/RELEASE-NOTES
+++ /dev/null
@@ -1,11 +0,0 @@
-This file contains information about the current release of Wine.
-If you are new to Wine, read the files ANNOUNCE and README and the FAQ 
-list first.
-If you want to contribute code to Wine, read the DEVELOPER-HINTS. The
-primary source of information to developers is the ChangeLog (next to
-the source, of course).
-
-1. BAR.EXE used to work, but does not work anymore
-Look at the ChangeLog to see what files have been changed. Try to undo
-the particular patch and go partially back to the previous version. If
-you have any suspicions, report them to the author or to the newsgroup.
diff --git a/controls/button.c b/controls/button.c
index 9b74f1f..16e6e97 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -64,7 +64,7 @@
     SendMessage32A( GetParent32((wndPtr)->hwndSelf), WM_CTLCOLORBTN, \
                     (hdc), (wndPtr)->hwndSelf )
 
-static HBITMAP16 hbitmapCheckBoxes = 0;
+static HBITMAP32 hbitmapCheckBoxes = 0;
 static WORD checkBoxWidth = 0, checkBoxHeight = 0;
 
 
@@ -74,7 +74,8 @@
 LRESULT WINAPI ButtonWndProc( HWND32 hWnd, UINT32 uMsg,
                               WPARAM32 wParam, LPARAM lParam )
 {
-    RECT16 rect;
+    RECT32 rect;
+    POINT32 pt = { LOWORD(lParam), HIWORD(lParam) };
     WND *wndPtr = WIN_FindWndPtr(hWnd);
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
     LONG style = wndPtr->dwStyle & 0x0f;
@@ -98,9 +99,9 @@
     case WM_CREATE:
         if (!hbitmapCheckBoxes)
         {
-            BITMAP16 bmp;
-            hbitmapCheckBoxes = LoadBitmap16(0, MAKEINTRESOURCE(OBM_CHECKBOXES));
-            GetObject16( hbitmapCheckBoxes, sizeof(bmp), &bmp );
+            BITMAP32 bmp;
+            hbitmapCheckBoxes = LoadBitmap32A(0, MAKEINTRESOURCE(OBM_CHECKBOXES));
+            GetObject32A( hbitmapCheckBoxes, sizeof(bmp), &bmp );
             checkBoxWidth  = bmp.bmWidth / 4;
             checkBoxHeight = bmp.bmHeight / 3;
         }
@@ -133,8 +134,8 @@
         ReleaseCapture();
         if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
         SendMessage32A( hWnd, BM_SETSTATE32, FALSE, 0 );
-        GetClientRect16( hWnd, &rect );
-        if (PtInRect16( &rect, MAKEPOINT16(lParam) ))
+        GetClientRect32( hWnd, &rect );
+        if (PtInRect32( &rect, pt ))
         {
             switch(style)
             {
@@ -159,9 +160,8 @@
     case WM_MOUSEMOVE:
         if (GetCapture32() == hWnd)
         {
-            GetClientRect16( hWnd, &rect );
-            SendMessage32A( hWnd, BM_SETSTATE32,
-                            PtInRect16( &rect,MAKEPOINT16(lParam) ), 0 );
+            GetClientRect32( hWnd, &rect );
+            SendMessage32A( hWnd, BM_SETSTATE32, PtInRect32(&rect, pt), 0 );
         }
         break;
 
@@ -170,7 +170,7 @@
         return DefWindowProc32A( hWnd, uMsg, wParam, lParam );
 
     case WM_SETTEXT:
-        DEFWND_SetText( wndPtr, (LPSTR)lParam );
+        DEFWND_SetText( wndPtr, (LPCSTR)lParam );
 	if( wndPtr->dwStyle & WS_VISIBLE )
             PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
         return 0;
@@ -192,7 +192,7 @@
     case WM_KILLFOCUS:
         infoPtr->state &= ~BUTTON_HASFOCUS;
 	PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
-	InvalidateRect16( hWnd, NULL, TRUE );
+	InvalidateRect32( hWnd, NULL, TRUE );
         break;
 
     case WM_SYSCOLORCHANGE:
@@ -299,8 +299,8 @@
     /* draw button label, if any: */
     if (wndPtr->text && wndPtr->text[0])
     {
-        LOGBRUSH16 lb;
-        GetObject16( GetSysColorBrush32(COLOR_BTNFACE), sizeof(lb), &lb );
+        LOGBRUSH32 lb;
+        GetObject32A( GetSysColorBrush32(COLOR_BTNFACE), sizeof(lb), &lb );
         if (wndPtr->dwStyle & WS_DISABLED &&
             GetSysColor32(COLOR_GRAYTEXT)==lb.lbColor)
             /* don't write gray text on gray bkg */
@@ -346,7 +346,7 @@
     HBITMAP32 hbm  = CreateBitmap32( 8, 8, 1, 1, Pattern );
     HDC32 hdcMem = CreateCompatibleDC32(hDC);
     HBITMAP32 hbmMem;
-    HBRUSH16 hBr;
+    HBRUSH32 hBr;
     RECT32 rect,rc2;
 
     rect=*rc;
@@ -375,13 +375,13 @@
 
 static void CB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
 {
-    RECT16 rbox, rtext, client;
-    HBRUSH16 hBrush;
+    RECT32 rbox, rtext, client;
+    HBRUSH32 hBrush;
     int textlen, delta;
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
     textlen = 0;
-    GetClientRect16(wndPtr->hwndSelf, &client);
+    GetClientRect32(wndPtr->hwndSelf, &client);
     rbox = rtext = client;
 
     if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
@@ -415,8 +415,8 @@
         int x = 0, y = 0;
         delta = (rbox.bottom - rbox.top - checkBoxHeight) >> 1;
 
-        if (action == ODA_SELECT) FillRect16( hDC, &rbox, hBrush );
-        else FillRect16( hDC, &client, hBrush );
+        if (action == ODA_SELECT) FillRect32( hDC, &rbox, hBrush );
+        else FillRect32( hDC, &client, hBrush );
 
         if (infoPtr->state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth;
         if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth;
@@ -430,8 +430,8 @@
         {
             if (wndPtr->dwStyle & WS_DISABLED)
                 SetTextColor32( hDC, GetSysColor32(COLOR_GRAYTEXT) );
-            DrawText16( hDC, wndPtr->text, textlen, &rtext,
-                        DT_SINGLELINE | DT_VCENTER );
+            DrawText32A( hDC, wndPtr->text, textlen, &rtext,
+			 DT_SINGLELINE | DT_VCENTER );
 	    textlen = 0; /* skip DrawText() below */
         }
     }
@@ -441,17 +441,17 @@
     {
 	/* again, this is what CTL3D expects */
 
-        SetRectEmpty16(&rbox);
+        SetRectEmpty32(&rbox);
         if( textlen )
-            DrawText16( hDC, wndPtr->text, textlen, &rbox,
-                        DT_SINGLELINE | DT_CALCRECT );
+            DrawText32A( hDC, wndPtr->text, textlen, &rbox,
+			 DT_SINGLELINE | DT_CALCRECT );
         textlen = rbox.bottom - rbox.top;
         delta = ((rtext.bottom - rtext.top) - textlen)/2;
         rbox.bottom = (rbox.top = rtext.top + delta - 1) + textlen + 2;
         textlen = rbox.right - rbox.left;
         rbox.right = (rbox.left += --rtext.left) + textlen + 2;
-        IntersectRect16(&rbox, &rbox, &rtext);
-        DrawFocusRect16( hDC, &rbox );
+        IntersectRect32(&rbox, &rbox, &rtext);
+        DrawFocusRect32( hDC, &rbox );
     }
 }
 
@@ -485,14 +485,14 @@
 
 static void GB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
 {
-    RECT16 rc;
+    RECT32 rc;
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
     if (action != ODA_DRAWENTIRE) return;
 
     BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
 
-    GetClientRect16( wndPtr->hwndSelf, &rc);
+    GetClientRect32( wndPtr->hwndSelf, &rc);
     GRAPH_DrawRectangle( hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1,
 			 GetSysColorPen32(COLOR_WINDOWFRAME) );
     if (wndPtr->text)
@@ -501,7 +501,7 @@
         if (wndPtr->dwStyle & WS_DISABLED)
             SetTextColor32( hDC, GetSysColor32(COLOR_GRAYTEXT) );
         rc.left += 10;
-        DrawText16( hDC, wndPtr->text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
+        DrawText32A( hDC, wndPtr->text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
     }
 }
 
@@ -512,21 +512,21 @@
 
 static void UB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
 {
-    RECT16 rc;
-    HBRUSH16 hBrush;
+    RECT32 rc;
+    HBRUSH32 hBrush;
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
     if (action == ODA_SELECT) return;
 
-    GetClientRect16( wndPtr->hwndSelf, &rc);
+    GetClientRect32( wndPtr->hwndSelf, &rc);
 
     if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
     hBrush = GetControlBrush( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
 
-    FillRect16( hDC, &rc, hBrush );
+    FillRect32( hDC, &rc, hBrush );
     if ((action == ODA_FOCUS) ||
         ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
-        DrawFocusRect16( hDC, &rc );
+        DrawFocusRect32( hDC, &rc );
 }
 
 
diff --git a/controls/combo.c b/controls/combo.c
index 8c84ea6..3001b5b 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -35,9 +35,9 @@
 #define CB_GETEDITTEXTLENGTH( lphc ) \
 	(SendMessage32A( (lphc)->hWndEdit, WM_GETTEXTLENGTH, 0, 0 ))
 
-static HBITMAP16 	hComboBmp = 0;
-static UINT16		CBitHeight, CBitWidth;
-static UINT16		CBitOffset = 8;
+static HBITMAP32 	hComboBmp = 0;
+static UINT32		CBitHeight, CBitWidth;
+static UINT32		CBitOffset = 8;
 
 /***********************************************************************
  *           COMBO_Init
@@ -46,31 +46,31 @@
  */
 static BOOL32 COMBO_Init()
 {
-  HDC16		hDC;
+  HDC32		hDC;
   
   if( hComboBmp ) return TRUE;
-  if( (hDC = CreateCompatibleDC16(0)) )
+  if( (hDC = CreateCompatibleDC32(0)) )
   {
     BOOL32	bRet = FALSE;
-    if( (hComboBmp = LoadBitmap16(0, MAKEINTRESOURCE(OBM_COMBO))) )
+    if( (hComboBmp = LoadBitmap32A(0, MAKEINTRESOURCE(OBM_COMBO))) )
     {
-      BITMAP16      bm;
-      HBITMAP16     hPrevB;
-      RECT16        r;
+      BITMAP32      bm;
+      HBITMAP32     hPrevB;
+      RECT32        r;
 
-      GetObject16( hComboBmp, sizeof(bm), &bm );
+      GetObject32A( hComboBmp, sizeof(bm), &bm );
       CBitHeight = bm.bmHeight;
       CBitWidth  = bm.bmWidth;
 
       TRACE(combo, "combo bitmap [%i,%i]\n", CBitWidth, CBitHeight );
 
       hPrevB = SelectObject16( hDC, hComboBmp);
-      SetRect16( &r, 0, 0, CBitWidth, CBitHeight );
-      InvertRect16( hDC, &r );
-      SelectObject16( hDC, hPrevB );
+      SetRect32( &r, 0, 0, CBitWidth, CBitHeight );
+      InvertRect32( hDC, &r );
+      SelectObject32( hDC, hPrevB );
       bRet = TRUE;
     }
-    DeleteDC16( hDC );
+    DeleteDC32( hDC );
     return bRet;
   }
   return FALSE;
@@ -135,35 +135,35 @@
  *
  * Set up component coordinates given valid lphc->RectCombo.
  */
-static void CBCalcPlacement( LPHEADCOMBO lphc, 
-			     LPRECT16 lprEdit, LPRECT16 lprButton, LPRECT16 lprLB )
+static void CBCalcPlacement( LPHEADCOMBO lphc, LPRECT32 lprEdit, 
+			     LPRECT32 lprButton, LPRECT32 lprLB )
 {
-   RECT16	rect = lphc->RectCombo;
-   SIZE16	size;
+   RECT32	rect = lphc->RectCombo;
+   SIZE32	size;
 
    /* get combo height and width */
 
    if( lphc->editHeight )
-       size.cy = (INT16)lphc->editHeight;
+       size.cy = lphc->editHeight;
    else
    {
-       HDC16	hDC = GetDC16( lphc->self->hwndSelf );
-       HFONT16	hPrevFont = (HFONT16)0;
+       HDC32	hDC = GetDC32( lphc->self->hwndSelf );
+       HFONT32	hPrevFont = 0;
 
-       if( lphc->hFont ) hPrevFont = SelectObject16( hDC, lphc->hFont );
+       if( lphc->hFont ) hPrevFont = SelectObject32( hDC, lphc->hFont );
    
-       GetTextExtentPoint16( hDC, "0", 1, &size);
+       GetTextExtentPoint32A( hDC, "0", 1, &size);
 
        size.cy += size.cy / 4 + 4 * SYSMETRICS_CYBORDER;
 
-       if( hPrevFont ) SelectObject16( hDC, hPrevFont );
-       ReleaseDC16( lphc->self->hwndSelf, hDC );
+       if( hPrevFont ) SelectObject32( hDC, hPrevFont );
+       ReleaseDC32( lphc->self->hwndSelf, hDC );
    }
    size.cx = rect.right - rect.left;
 
    if( CB_OWNERDRAWN(lphc) )
    {
-       UINT16	u = lphc->RectEdit.bottom - lphc->RectEdit.top;
+       UINT32	u = lphc->RectEdit.bottom - lphc->RectEdit.top;
 
        if( lphc->wState & CBF_MEASUREITEM ) /* first initialization */
        {
@@ -197,7 +197,7 @@
        lprButton->bottom = lprButton->top + size.cy;
 
        if( i < 0 ) size.cx = 0;
-       else size.cx = (INT16)i;
+       else size.cx = i;
    }
 
    if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
@@ -216,7 +216,7 @@
    lprLB->bottom = rect.bottom - rect.top;
 
    if( lphc->droppedWidth > (lprLB->right - lprLB->left) )
-       lprLB->right = lprLB->left + (INT16)lphc->droppedWidth;
+       lprLB->right = lprLB->left + lphc->droppedWidth;
 
    TRACE(combo,"[%04x]: (%i,%i-%i,%i) placement\n",
 		CB_HWND(lphc), lphc->RectCombo.left, lphc->RectCombo.top, 
@@ -266,9 +266,9 @@
   if( lphc->owner || !(lpcs->style & WS_VISIBLE) )
   {
       UINT32	lbeStyle;
-      RECT16	editRect, btnRect, lbRect;
+      RECT32	editRect, btnRect, lbRect;
 
-      GetWindowRect16( wnd->hwndSelf, &lphc->RectCombo );
+      GetWindowRect32( wnd->hwndSelf, &lphc->RectCombo );
 
       lphc->wState |= CBF_MEASUREITEM;
       CBCalcPlacement( lphc, &editRect, &btnRect, &lbRect );
@@ -294,7 +294,7 @@
       else					/* popup listbox */
       {
 	lbeStyle |= WS_POPUP;
-	OffsetRect16( &lbRect, lphc->RectCombo.left, lphc->RectCombo.top );
+	OffsetRect32( &lbRect, lphc->RectCombo.left, lphc->RectCombo.top );
       }
 
      /* Dropdown ComboLBox is not a child window and we cannot pass 
@@ -359,7 +359,7 @@
  *
  * Paint combo button (normal, pressed, and disabled states).
  */
-static void CBPaintButton(LPHEADCOMBO lphc, HDC16 hdc)
+static void CBPaintButton(LPHEADCOMBO lphc, HDC32 hdc)
 {
     RECT32 	r;
     HBRUSH32 	hPrevBrush;
@@ -401,7 +401,7 @@
  *
  * Paint CBS_DROPDOWNLIST text field / update edit control contents.
  */
-static void CBPaintText(LPHEADCOMBO lphc, HDC16 hdc)
+static void CBPaintText(LPHEADCOMBO lphc, HDC32 hdc)
 {
    INT32	id, size = 0;
    LPSTR	pText = NULL;
@@ -446,7 +446,7 @@
 	if( hDC )
 	{
 	    RECT32	rect;
-	    UINT16	itemState;
+	    UINT32	itemState;
 	    HFONT32	hPrevFont = (lphc->hFont) ? SelectObject32(hDC, lphc->hFont) : 0;
 
 	    PatBlt32( hDC, (rect.left = lphc->RectEdit.left + SYSMETRICS_CXBORDER),
@@ -508,13 +508,13 @@
 /***********************************************************************
  *           COMBO_Paint
  */
-static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC16 hParamDC)
+static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC32 hParamDC)
 {
-  PAINTSTRUCT16 ps;
-  HDC16 	hDC;
+  PAINTSTRUCT32 ps;
+  HDC32 	hDC;
   
   hDC = (hParamDC) ? hParamDC
-		   : BeginPaint16( lphc->self->hwndSelf, &ps);
+		   : BeginPaint32( lphc->self->hwndSelf, &ps);
   if( hDC && !(lphc->wState & CBF_NOREDRAW) )
   {
       HBRUSH32	hPrevBrush, hBkgBrush;
@@ -524,7 +524,7 @@
       if( !hBkgBrush ) hBkgBrush = GetStockObject32(WHITE_BRUSH);
 
       hPrevBrush = SelectObject32( hDC, hBkgBrush );
-      if( !IsRectEmpty16(&lphc->RectButton) )
+      if( !IsRectEmpty32(&lphc->RectButton) )
       {
 	  /* paint everything to the right of the text field */
 
@@ -546,7 +546,7 @@
       }
       if( hPrevBrush ) SelectObject32( hDC, hPrevBrush );
   }
-  if( !hParamDC ) EndPaint16(lphc->self->hwndSelf, &ps);
+  if( !hParamDC ) EndPaint32(lphc->self->hwndSelf, &ps);
   return 0;
 }
 
@@ -644,8 +644,8 @@
 static void CBDropDown( LPHEADCOMBO lphc )
 {
    INT32	index;
-   RECT16	rect;
-   LPRECT16	pRect = NULL;
+   RECT32	rect;
+   LPRECT32	pRect = NULL;
 
    TRACE(combo,"[%04x]: drop down\n", CB_HWND(lphc));
 
@@ -670,7 +670,7 @@
 
    /* now set popup position */
 
-   GetWindowRect16( lphc->self->hwndSelf, &rect );
+   GetWindowRect32( lphc->self->hwndSelf, &rect );
    
    rect.top += lphc->RectEdit.bottom - lphc->RectEdit.top - SYSMETRICS_CYBORDER;
    rect.bottom = rect.top + lphc->RectCombo.bottom - 
@@ -684,7 +684,7 @@
 
    if( !(lphc->wState & CBF_NOREDRAW) )
        if( pRect )
-           RedrawWindow16( lphc->self->hwndSelf, pRect, 0, RDW_INVALIDATE | 
+           RedrawWindow32( lphc->self->hwndSelf, pRect, 0, RDW_INVALIDATE | 
 			   RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
    ShowWindow32( lphc->hWndLBox, SW_SHOWNA );
 }
@@ -710,7 +710,7 @@
 
        if( lphc->wState & CBF_DROPPED ) 
        {
-	   RECT16	rect;
+	   RECT32	rect;
 
 	   lphc->wState &= ~CBF_DROPPED;
 	   ShowWindow32( lphc->hWndLBox, SW_HIDE );
@@ -724,7 +724,7 @@
 	   else 
            {
 	       if( bButton )
-	           UnionRect16( &rect, &lphc->RectButton,
+	           UnionRect32( &rect, &lphc->RectButton,
 				       &lphc->RectEdit );
 	       else
 		   rect = lphc->RectEdit;
@@ -732,7 +732,7 @@
 	   }
 
 	   if( bButton && !(lphc->wState & CBF_NOREDRAW) )
-	       RedrawWindow16( hWnd, &rect, 0, RDW_INVALIDATE | 
+	       RedrawWindow32( hWnd, &rect, 0, RDW_INVALIDATE | 
 			       RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
 	   CB_NOTIFY( lphc, CBN_CLOSEUP );
        }
@@ -778,7 +778,7 @@
 
    if( hDC )
    {
-       CBPaintButton( lphc, (HDC16)hDC );
+       CBPaintButton( lphc, hDC );
        ReleaseDC32( lphc->self->hwndSelf, hDC );
    }
 }
@@ -845,7 +845,7 @@
 	   case (EN_SETFOCUS >> 8):
 
 		TRACE(combo,"[%04x]: edit [%04x] got focus\n", 
-			     CB_HWND(lphc), (HWND16)lphc->hWndEdit );
+			     CB_HWND(lphc), lphc->hWndEdit );
 
 		if( !(lphc->wState & CBF_FOCUSED) ) COMBO_SetFocus( lphc );
 	        break;
@@ -853,7 +853,7 @@
 	   case (EN_KILLFOCUS >> 8):
 
 		TRACE(combo,"[%04x]: edit [%04x] lost focus\n",
-			     CB_HWND(lphc), (HWND16)lphc->hWndEdit );
+			     CB_HWND(lphc), lphc->hWndEdit );
 
 		/* NOTE: it seems that Windows' edit control sends an
 		 * undocumented message WM_USER + 0x1B instead of this
@@ -927,8 +927,7 @@
 {
    HWND32	hWnd = lphc->self->hwndSelf;
 
-   TRACE(combo,"[%04x]: ownerdraw op %04x\n", 
-		CB_HWND(lphc), (UINT16)msg );
+   TRACE(combo,"[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg );
 
 #define lpIS    ((LPDELETEITEMSTRUCT32)lParam)
 
@@ -1010,7 +1009,7 @@
  * This function sets window positions according to the updated 
  * component placement struct.
  */
-static void CBResetPos( LPHEADCOMBO lphc, LPRECT16 lbRect, BOOL32 bRedraw )
+static void CBResetPos( LPHEADCOMBO lphc, LPRECT32 lbRect, BOOL32 bRedraw )
 {
    BOOL32	bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE);
 
@@ -1024,7 +1023,7 @@
                        SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) );
 
    if( bDrop )
-       OffsetRect16( lbRect, lphc->RectCombo.left, lphc->RectCombo.top );
+       OffsetRect32( lbRect, lphc->RectCombo.left, lphc->RectCombo.top );
 
    lbRect->right -= lbRect->left;	/* convert to width */
    lbRect->bottom -= lbRect->top;
@@ -1059,10 +1058,10 @@
  */
 static void COMBO_Size( LPHEADCOMBO lphc )
 {
-  RECT16	rect;
-  INT16		w, h;
+  RECT32	rect;
+  INT32		w, h;
 
-  GetWindowRect16( lphc->self->hwndSelf, &rect );
+  GetWindowRect32( lphc->self->hwndSelf, &rect );
   w = rect.right - rect.left; h = rect.bottom - rect.top;
 
   TRACE(combo,"w = %i, h = %i\n", w, h );
@@ -1086,9 +1085,9 @@
 /***********************************************************************
  *           COMBO_Font
  */
-static void COMBO_Font( LPHEADCOMBO lphc, HFONT16 hFont, BOOL32 bRedraw )
+static void COMBO_Font( LPHEADCOMBO lphc, HFONT32 hFont, BOOL32 bRedraw )
 {
-  RECT16        rect;
+  RECT32        rect;
 
   lphc->hFont = hFont;
 
@@ -1096,8 +1095,8 @@
       SendMessage32A( lphc->hWndEdit, WM_SETFONT, (WPARAM32)hFont, bRedraw );
   SendMessage32A( lphc->hWndLBox, WM_SETFONT, (WPARAM32)hFont, bRedraw );
 
-  GetWindowRect16( lphc->self->hwndSelf, &rect );
-  OffsetRect16( &lphc->RectCombo, rect.left - lphc->RectCombo.left,
+  GetWindowRect32( lphc->self->hwndSelf, &rect );
+  OffsetRect32( &lphc->RectCombo, rect.left - lphc->RectCombo.left,
                                   rect.top - lphc->RectCombo.top );
   CBCalcPlacement( lphc, &lphc->RectEdit,
                          &lphc->RectButton, &rect );
@@ -1116,11 +1115,11 @@
    {
        if( height < 32768 )
        {
-           RECT16	rect;
+           RECT32	rect;
 
            lphc->editHeight = height;
-           GetWindowRect16( lphc->self->hwndSelf, &rect );
-           OffsetRect16( &lphc->RectCombo, rect.left - lphc->RectCombo.left,
+           GetWindowRect32( lphc->self->hwndSelf, &rect );
+           OffsetRect32( &lphc->RectCombo, rect.left - lphc->RectCombo.left,
 				           rect.top - lphc->RectCombo.top );
            CBCalcPlacement( lphc, &lphc->RectEdit,
 			          &lphc->RectButton, &rect );
@@ -1154,7 +1153,8 @@
  */
 static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam )
 {
-   BOOL32      bButton = PtInRect16(&lphc->RectButton, MAKEPOINT16(lParam));
+   POINT32     pt = { LOWORD(lParam), HIWORD(lParam) };
+   BOOL32      bButton = PtInRect32(&lphc->RectButton, pt);
    HWND32      hWnd = lphc->self->hwndSelf;
 
    if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
@@ -1220,11 +1220,12 @@
  */
 static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM32 wParam, LPARAM lParam )
 {
-   RECT16	lbRect;
+   POINT32  pt = { LOWORD(lParam), HIWORD(lParam) };
+   RECT32   lbRect;
 
    if( lphc->wState & CBF_BUTTONDOWN )
    {
-       BOOL32	bButton = PtInRect16(&lphc->RectButton, MAKEPOINT16(lParam));
+       BOOL32	bButton = PtInRect32(&lphc->RectButton, pt);
 
        if( !bButton )
        {
@@ -1233,10 +1234,9 @@
        }
    }
 
-   GetClientRect16( lphc->hWndLBox, &lbRect );
-   MapWindowPoints16( lphc->self->hwndSelf, 
-		      lphc->hWndLBox, (LPPOINT16)&lParam, 1 );
-   if( PtInRect16(&lbRect, MAKEPOINT16(lParam)) )
+   GetClientRect32( lphc->hWndLBox, &lbRect );
+   MapWindowPoints32( lphc->self->hwndSelf, lphc->hWndLBox, &pt, 1 );
+   if( PtInRect32(&lbRect, pt) )
    {
        lphc->wState &= ~CBF_CAPTURE;
        ReleaseCapture();
@@ -1283,7 +1283,7 @@
 
      	case WM_PAINT:
 		/* wParam may contain a valid HDC! */
-		return COMBO_Paint(lphc, (HDC16)wParam);
+		return COMBO_Paint(lphc, wParam);
 
 	case WM_ERASEBKGND:
 		return TRUE;
@@ -1564,7 +1564,7 @@
 		return (lphc->wState & CBF_EUI) ? TRUE : FALSE;
 
 	case (WM_USER + 0x1B):
-	        WARN(combo, "[%04x]: undocumented msg!\n", (HWND16)hwnd );
+	        WARN(combo, "[%04x]: undocumented msg!\n", hwnd );
     }
     return DefWindowProc32A(hwnd, message, wParam, lParam);
   }
diff --git a/controls/commctrl.c b/controls/commctrl.c
index 0ce4e00..f9400fd 100644
--- a/controls/commctrl.c
+++ b/controls/commctrl.c
@@ -156,7 +156,7 @@
         old_name = class32->lpszClassName;
         strcpy( name, (char *)class32->lpszClassName );
         class32->lpszClassName = name;
-        class32->hCursor = LoadCursor16( 0, IDC_ARROW );
+        class32->hCursor = LoadCursor32A( 0, (LPCSTR)IDC_ARROW );
         RegisterClass32A( class32 );
         class32->lpszClassName = old_name;	
     }
diff --git a/controls/desktop.c b/controls/desktop.c
index fd2963c..1535b9a 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -149,7 +149,7 @@
 	infoPtr->hbitmapWallPaper = 0;
 	SetDeskPattern();
 	SetDeskWallPaper32( (LPSTR)-1 );
-	break;
+	return 1;
 	
     case WM_ERASEBKGND:
 	if (rootWindow == DefaultRootWindow(display)) return 1;
diff --git a/controls/icontitle.c b/controls/icontitle.c
index 8c4a473..ae337af 100644
--- a/controls/icontitle.c
+++ b/controls/icontitle.c
@@ -24,11 +24,11 @@
  */
 BOOL32 ICONTITLE_Init(void)
 {
-    LOGFONT16 logFont;
+    LOGFONT32A logFont;
 
-    SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
-    SystemParametersInfo16( SPI_GETICONTITLEWRAP, 0, &bMultiLineTitle, 0 );
-    hIconTitleFont = CreateFontIndirect16( &logFont );
+    SystemParametersInfo32A( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
+    SystemParametersInfo32A( SPI_GETICONTITLEWRAP, 0, &bMultiLineTitle, 0 );
+    hIconTitleFont = CreateFontIndirect32A( &logFont );
     return (hIconTitleFont) ? TRUE : FALSE;
 }
 
@@ -161,7 +161,7 @@
     hPrevFont = SelectObject32( hDC, hIconTitleFont );
     if( hPrevFont )
     {
-        RECT16  rect;
+        RECT32  rect;
 	INT32	length;
 	char	buffer[80];
 
@@ -173,8 +173,8 @@
         SetTextColor32( hDC, textColor );
         SetBkMode32( hDC, TRANSPARENT );
 	
-	DrawText16( hDC, buffer, length, &rect, DT_CENTER | DT_NOPREFIX |
-		    DT_WORDBREAK | ((bMultiLineTitle) ? 0 : DT_SINGLELINE) ); 
+	DrawText32A( hDC, buffer, length, &rect, DT_CENTER | DT_NOPREFIX |
+		     DT_WORDBREAK | ((bMultiLineTitle) ? 0 : DT_SINGLELINE) ); 
 
 	SelectObject32( hDC, hPrevFont );
     }
diff --git a/controls/listbox.c b/controls/listbox.c
index a985520..58b650e 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -100,14 +100,14 @@
     LB_ITEMDATA *item;
     LB_DESCR *descr = *(LB_DESCR **)wnd->wExtra;
 
-    printf( "Listbox:\n" );
-    printf( "hwnd=%04x descr=%08x heap=%08x items=%d top=%d\n",
-            wnd->hwndSelf, (UINT32)descr, descr->heap, descr->nb_items,
-            descr->top_item );
+    DUMP( "Listbox:\n" );
+    DUMP( "hwnd=%04x descr=%08x heap=%08x items=%d top=%d\n",
+	  wnd->hwndSelf, (UINT32)descr, descr->heap, descr->nb_items,
+	  descr->top_item );
     for (i = 0, item = descr->items; i < descr->nb_items; i++, item++)
     {
-        printf( "%4d: %-40s %d %08lx %3d\n",
-                i, item->str, item->selected, item->data, item->height );
+        DUMP( "%4d: %-40s %d %08lx %3d\n",
+	      i, item->str, item->selected, item->data, item->height );
     }
 }
 
diff --git a/controls/menu.c b/controls/menu.c
index 12de09b..3508d4d 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -2607,15 +2607,18 @@
 	/* zero out global pointer in case resident popup window
 	 * was somehow destroyed. */
 
-	if( hwnd == pTopPopupWnd->hwndSelf )
-	{	
-	    ERR(menu, "resident popup destroyed!\n");
+	if( pTopPopupWnd )
+	{
+	    if( hwnd == pTopPopupWnd->hwndSelf )
+	    {
+		ERR(menu, "resident popup destroyed!\n");
 
-	    pTopPopupWnd = NULL; 
-	    uSubPWndLevel = 0; 
+		pTopPopupWnd = NULL;
+		uSubPWndLevel = 0;
+	    }
+	    else
+		uSubPWndLevel--;
 	}
-	else
-	    uSubPWndLevel--;
 	break;
 
     case WM_SHOWWINDOW:
diff --git a/controls/scroll.c b/controls/scroll.c
index a3a533b..8e5a366 100644
--- a/controls/scroll.c
+++ b/controls/scroll.c
@@ -81,18 +81,18 @@
  */
 static void SCROLL_LoadBitmaps(void)
 {
-    hUpArrow  = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_UPARROW) );
-    hDnArrow  = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_DNARROW) );
-    hLfArrow  = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_LFARROW) );
-    hRgArrow  = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RGARROW) );
-    hUpArrowD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_UPARROWD) );
-    hDnArrowD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_DNARROWD) );
-    hLfArrowD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_LFARROWD) );
-    hRgArrowD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RGARROWD) );
-    hUpArrowI = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_UPARROWI) );
-    hDnArrowI = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_DNARROWI) );
-    hLfArrowI = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_LFARROWI) );
-    hRgArrowI = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RGARROWI) );
+    hUpArrow  = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_UPARROW) );
+    hDnArrow  = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_DNARROW) );
+    hLfArrow  = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_LFARROW) );
+    hRgArrow  = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_RGARROW) );
+    hUpArrowD = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_UPARROWD) );
+    hDnArrowD = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_DNARROWD) );
+    hLfArrowD = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_LFARROWD) );
+    hRgArrowD = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_RGARROWD) );
+    hUpArrowI = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_UPARROWI) );
+    hDnArrowI = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_DNARROWI) );
+    hLfArrowI = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_LFARROWI) );
+    hRgArrowI = LoadBitmap32A( 0, MAKEINTRESOURCE(OBM_RGARROWI) );
 }
 
 
diff --git a/controls/uitools.c b/controls/uitools.c
index d3f814e..4354426 100644
--- a/controls/uitools.c
+++ b/controls/uitools.c
@@ -92,20 +92,14 @@
 /***********************************************************************
  *           UITOOLS_DrawDiagEdge
  *
- * Same as DrawEdge, but with BF_DIAGONAL
- * I tested it extensively and as far as I can tell it is identical to the
- * implementaion in Win95.
- * I do not like that I create and
- * use the 3 Pens to draw the diagonals. It would be better to draw them
- * using the brushes returned by GetSysColorBrush func, but I did not have
- * the patience to implement that yet.
- */
-/*********************************************************************
+ * Same as DrawEdge invoked with BF_DIAGONAL
+ *
  * 03-Dec-1997: Changed by Bertho Stultiens
  *
  * See also comments with UITOOLS_DrawRectEdge()
  */
-static BOOL32 UITOOLS_DrawDiagEdge(HDC32 hdc, LPRECT32 rc, UINT32 uType, UINT32 uFlags)
+static BOOL32 UITOOLS95_DrawDiagEdge(HDC32 hdc, LPRECT32 rc, 
+				     UINT32 uType, UINT32 uFlags)
 {
     POINT32 Points[4];
     char InnerI, OuterI;
@@ -346,15 +340,8 @@
 /***********************************************************************
  *           UITOOLS_DrawRectEdge
  *
- * Same as DrawEdge, but without BF_DIAGONAL
- * I tested this function and it works very well. You should not change it
- * unless you find a bug. If you don't like the colors, it it not its 
- * fault - the system colors are not OK.
- * Again, I tested this function on Win95 and I compared the output with the
- * one generated by the native DrawEdge and it is identical on all cases that
- * I tried, and I tried quite a few.
- */
-/*********************************************************************
+ * Same as DrawEdge invoked without BF_DIAGONAL
+ *
  * 23-Nov-1997: Changed by Bertho Stultiens
  *
  * Well, I started testing this and found out that there are a few things
@@ -424,7 +411,8 @@
  */
 
 
-static BOOL32 UITOOLS_DrawRectEdge(HDC32 hdc, LPRECT32 rc, UINT32 uType, UINT32 uFlags)
+static BOOL32 UITOOLS95_DrawRectEdge(HDC32 hdc, LPRECT32 rc, 
+				     UINT32 uType, UINT32 uFlags)
 {
     char LTInnerI, LTOuterI;
     char RBInnerI, RBOuterI;
@@ -575,13 +563,12 @@
 BOOL32 WINAPI DrawEdge32( HDC32 hdc, LPRECT32 rc, UINT32 edge, UINT32 flags )
 {
     TRACE(graphics, "%04x %d,%d-%d,%d %04x %04x\n",
-                      hdc, rc->left, rc->top, rc->right, rc->bottom,
-                      edge, flags );
+	  hdc, rc->left, rc->top, rc->right, rc->bottom, edge, flags );
 
     if(flags & BF_DIAGONAL)
-      return UITOOLS_DrawDiagEdge(hdc, rc, edge, flags);
+      return UITOOLS95_DrawDiagEdge(hdc, rc, edge, flags);
     else
-      return UITOOLS_DrawRectEdge(hdc, rc, edge, flags);
+      return UITOOLS95_DrawRectEdge(hdc, rc, edge, flags);
 }
 
 
@@ -623,7 +610,7 @@
  * however there because MS uses a TrueType font (Marlett) to draw
  * the buttons.
  */
-static BOOL32 UITOOLS_DFC_ButtonPush(HDC32 dc, LPRECT32 r, UINT32 uFlags)
+static BOOL32 UITOOLS95_DFC_ButtonPush(HDC32 dc, LPRECT32 r, UINT32 uFlags)
 {
     UINT32 edge;
     RECT32 myr = *r;
@@ -636,9 +623,9 @@
     if(uFlags & DFCS_CHECKED)
     {
         if(uFlags & DFCS_MONO)
-            UITOOLS_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
+            UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
         else
-            UITOOLS_DrawRectEdge(dc, &myr, edge, (uFlags&DFCS_FLAT)|BF_RECT|BF_SOFT|BF_ADJUST);
+            UITOOLS95_DrawRectEdge(dc, &myr, edge, (uFlags&DFCS_FLAT)|BF_RECT|BF_SOFT|BF_ADJUST);
 
         if(GetSysColor32(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
         {
@@ -662,12 +649,12 @@
     {
         if(uFlags & DFCS_MONO)
         {
-            UITOOLS_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
+            UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
             FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNFACE));
         }
         else
         {
-            UITOOLS_DrawRectEdge(dc, r, edge, (uFlags&DFCS_FLAT) | BF_MIDDLE |BF_SOFT| BF_RECT);
+            UITOOLS95_DrawRectEdge(dc, r, edge, (uFlags&DFCS_FLAT) | BF_MIDDLE |BF_SOFT| BF_RECT);
         }
     }
 
@@ -695,7 +682,7 @@
  */
 #define DFC_CHECKPOINTSMAX      6
 
-static BOOL32 UITOOLS_DFC_ButtonCheck(HDC32 dc, LPRECT32 r, UINT32 uFlags)
+static BOOL32 UITOOLS95_DFC_ButtonCheck(HDC32 dc, LPRECT32 r, UINT32 uFlags)
 {
     RECT32 myr;
     int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
@@ -803,7 +790,7 @@
  * however there because MS uses a TrueType font (Marlett) to draw
  * the buttons.
  */
-static BOOL32 UITOOLS_DFC_ButtonRadio(HDC32 dc, LPRECT32 r, UINT32 uFlags)
+static BOOL32 UITOOLS95_DFC_ButtonRadio(HDC32 dc, LPRECT32 r, UINT32 uFlags)
 {
     RECT32 myr;
     int i;
@@ -924,24 +911,24 @@
 /***********************************************************************
  *           UITOOLS_DrawFrameButton
  */
-static BOOL32 UITOOLS_DrawFrameButton(HDC32 hdc, LPRECT32 rc, UINT32 uState)
+static BOOL32 UITOOLS95_DrawFrameButton(HDC32 hdc, LPRECT32 rc, UINT32 uState)
 {
     switch(uState & 0xff)
     {
     case DFCS_BUTTONPUSH:
-        return UITOOLS_DFC_ButtonPush(hdc, rc, uState);
+        return UITOOLS95_DFC_ButtonPush(hdc, rc, uState);
 
     case DFCS_BUTTONCHECK:
     case DFCS_BUTTON3STATE:
-        return UITOOLS_DFC_ButtonCheck(hdc, rc, uState);
+        return UITOOLS95_DFC_ButtonCheck(hdc, rc, uState);
 
     case DFCS_BUTTONRADIOIMAGE:
     case DFCS_BUTTONRADIOMASK:
     case DFCS_BUTTONRADIO:
-        return UITOOLS_DFC_ButtonRadio(hdc, rc, uState);
+        return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState);
 
     default:
-        WARN(uitools, "Invalid button state: 0x%04x\n", uState);
+        WARN(uitools, "Invalid button state=0x%04x\n", uState);
     }
 
     return FALSE;
@@ -953,7 +940,7 @@
  * Draw caption buttons (win95), coming from DrawFrameControl()
  */
 
-static BOOL32 UITOOLS_DrawFrameCaption(HDC32 dc, LPRECT32 r, UINT32 uFlags)
+static BOOL32 UITOOLS95_DrawFrameCaption(HDC32 dc, LPRECT32 r, UINT32 uFlags)
 {
     POINT32 Line1[10];
     POINT32 Line2[10];
@@ -974,7 +961,7 @@
     COLORREF clrsave;
     SIZE32 size;
 
-    UITOOLS_DFC_ButtonPush(dc, r, uFlags & 0xff00);
+    UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
 
     switch(uFlags & 0xff)
     {
@@ -1077,7 +1064,7 @@
         break;
 
     default:
-        WARN(uitools, "Invalid caption; flags: 0x%04x\n", uFlags);
+        WARN(uitools, "Invalid caption; flags=0x%04x\n", uFlags);
         return FALSE;
     }
 
@@ -1126,7 +1113,7 @@
  *
  * Draw a scroll-bar control coming from DrawFrameControl()
  */
-static BOOL32 UITOOLS_DrawFrameScroll(HDC32 dc, LPRECT32 r, UINT32 uFlags)
+static BOOL32 UITOOLS95_DrawFrameScroll(HDC32 dc, LPRECT32 r, UINT32 uFlags)
 {
     POINT32 Line[4];
     RECT32 myr;
@@ -1174,7 +1161,7 @@
 
     case DFCS_SCROLLSIZEGRIP:
         /* This one breaks the flow... */
-        UITOOLS_DrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0));
+        UITOOLS95_DrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0));
         hpsave = (HPEN32)SelectObject32(dc, GetStockObject32(NULL_PEN));
         hbsave = (HBRUSH32)SelectObject32(dc, GetStockObject32(NULL_BRUSH));
         if(uFlags & (DFCS_MONO|DFCS_FLAT))
@@ -1247,12 +1234,12 @@
         return TRUE;
 
     default:
-        WARN(uitools, "Invalid scroll; flags: 0x%04x\n", uFlags);
+        WARN(uitools, "Invalid scroll; flags=0x%04x\n", uFlags);
         return FALSE;
     }
 
     /* Here do the real scroll-bar controls end up */
-    UITOOLS_DFC_ButtonPush(dc, r, uFlags & 0xff00);
+    UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
 
     if(uFlags & DFCS_INACTIVE)
     {
@@ -1284,7 +1271,7 @@
  *
  * Draw a menu control coming from DrawFrameControl()
  */
-static BOOL32 UITOOLS_DrawFrameMenu(HDC32 dc, LPRECT32 r, UINT32 uFlags)
+static BOOL32 UITOOLS95_DrawFrameMenu(HDC32 dc, LPRECT32 r, UINT32 uFlags)
 {
     POINT32 Points[6];
     RECT32 myr;
@@ -1349,7 +1336,7 @@
         break;
 
     default:
-        WARN(uitools, "Invalid menu; flags: 0x%04x\n", uFlags);
+        WARN(uitools, "Invalid menu; flags=0x%04x\n", uFlags);
         retval = FALSE;
         break;
     }
@@ -1389,16 +1376,17 @@
     switch(uType)
     {
     case DFC_BUTTON:
-      return UITOOLS_DrawFrameButton(hdc, rc, uState);
+      return UITOOLS95_DrawFrameButton(hdc, rc, uState);
     case DFC_CAPTION:
-      return UITOOLS_DrawFrameCaption(hdc, rc, uState);
+      return UITOOLS95_DrawFrameCaption(hdc, rc, uState);
     case DFC_MENU:
-      return UITOOLS_DrawFrameMenu(hdc, rc, uState);
+      return UITOOLS95_DrawFrameMenu(hdc, rc, uState);
     case DFC_SCROLL:
-      return UITOOLS_DrawFrameScroll(hdc, rc, uState);
+      return UITOOLS95_DrawFrameScroll(hdc, rc, uState);
     default:
       WARN(uitools, "(%x,%p,%d,%x), bad type!\n",
-		  hdc,rc,uType,uState );
+	   hdc,rc,uType,uState );
     }
     return FALSE;
 }
+
diff --git a/controls/widgets.c b/controls/widgets.c
index acb9560..b8fcfc4 100644
--- a/controls/widgets.c
+++ b/controls/widgets.c
@@ -94,7 +94,7 @@
         /* Just to make sure the string is > 0x10000 */
         strcpy( name, (char *)cls->lpszClassName );
         cls->lpszClassName = name;
-        cls->hCursor = LoadCursor16( 0, cls->hCursor );
+        cls->hCursor = LoadCursor32A( 0, (LPCSTR)cls->hCursor );
         if (!(bicAtomTable[i] = RegisterClass32A( cls ))) return FALSE;
     }
 
diff --git a/debugger/Makefile.in b/debugger/Makefile.in
index 9b01414..350c219 100644
--- a/debugger/Makefile.in
+++ b/debugger/Makefile.in
@@ -1,4 +1,4 @@
-DEFS      = -D__WINE__
+DEFS      = -D__WINE__ -DLIBDIR=\"$(libdir)\"
 TOPSRCDIR = @top_srcdir@
 TOPOBJDIR = ..
 SRCDIR    = @srcdir@
diff --git a/debugger/break.c b/debugger/break.c
index b332ade..f584ba9 100644
--- a/debugger/break.c
+++ b/debugger/break.c
@@ -348,15 +348,24 @@
         if (pModule->flags & NE_FFLAGS_WIN32)  /* PE module */
         {
             PE_MODREF *pem = PROCESS_Current()->modref_list;
-            while (pem)
+            if (!pem)
             {
-		if (pem->module == pModule->module32) break;
-		pem = pem->next;
+                addr.seg = 0;
+                addr.off = (DWORD)RVA_PTR( pModule->module32,
+                                           OptionalHeader.AddressOfEntryPoint);
             }
-            if (!pem) continue;
-            addr.seg = 0;
-            addr.off = (DWORD)RVA_PTR( pem->module,
-                                       OptionalHeader.AddressOfEntryPoint );
+            else
+            {
+                while (pem)
+                {
+                   if (pem->module == pModule->module32) break;
+                   pem = pem->next;
+                }
+                if (!pem) continue;
+                addr.seg = 0;
+                addr.off = (DWORD)RVA_PTR( pem->module,
+                                           OptionalHeader.AddressOfEntryPoint);
+            }
             fprintf( stderr, "Win32 task '%s': ", entry.szModule );
             DEBUG_AddBreakpoint( &addr );
         }
diff --git a/debugger/dbg.y b/debugger/dbg.y
index 5fa4b5b..7a54e7d 100644
--- a/debugger/dbg.y
+++ b/debugger/dbg.y
@@ -8,6 +8,7 @@
 
 #include <stdio.h>
 #include <signal.h>
+#include <sys/stat.h>
 #include <unistd.h>
 #include "class.h"
 #include "module.h"
@@ -436,7 +437,12 @@
 	fprintf(stderr,"Loading symbols: ");
 	if( DEBUG_ReadExecutableDbgInfo() == FALSE )
         {
-	    PROFILE_GetWineIniString( "wine", "SymbolTableFile", "wine.sym",
+	    char *symfilename = "wine.sym";
+	    struct stat statbuf;
+	    if (-1 == stat(symfilename, &statbuf) )
+                symfilename = LIBDIR "wine.sym";
+
+	    PROFILE_GetWineIniString( "wine", "SymbolTableFile", symfilename,
                                      SymbolTableFile, sizeof(SymbolTableFile));
 	    DEBUG_ReadSymbolTable( SymbolTableFile );
         }
diff --git a/debugger/stack.c b/debugger/stack.c
index fe9f5cb..37f6d5a 100644
--- a/debugger/stack.c
+++ b/debugger/stack.c
@@ -119,6 +119,7 @@
 							frame->bp, TRUE );
 	    frameno++;
             fprintf( stderr, "\n" );
+            if (addr.off == frame->bp) break;
             addr.off = frame->bp;
         }
     }
diff --git a/documentation/debug-msgs b/documentation/debug-msgs
index 0813465..da00b7f 100644
--- a/documentation/debug-msgs
+++ b/documentation/debug-msgs
@@ -1,5 +1,4 @@
-Note: The new debugging interface is starting to take shape.
-      In general, I think it can be considered to be stable,
+Note: The new debugging interface can be considered to be stable,
       with the exception of the in-memory message construction functions.
       However, there is still a lot of work to be done to polish
       things up and to convert the remaining fprintf. To make my life 
@@ -8,9 +7,13 @@
       Read this document before writing new code.
       Also, DO NOT USE fprintf (or printf) to output things. All these
       will have to be translated to the new interface and there are already
-      about 3000 of them! Also, instead of writing FIXMEs in the source,
-      output a FIXME message if you can. But read on...
-14 Mar 1998, Dimitrie O. Paun <dimi@cs.toronto.edu>
+      about 1000 of them! Also, instead of writing FIXMEs in the source,
+      output a FIXME message if you can. 
+
+      IMPORTANT: at the end of the document, there is a "Style Guide"
+      for debugging messages. Please read it.
+
+28 Mar 1998, Dimitrie O. Paun <dimi@cs.toronto.edu>
 
 
 Debugging classes
@@ -25,8 +28,9 @@
 
 ERR   -- Messages in this class relate to serious errors in Wine.
          This sort of messages are close to asserts -- that is,
-         you should output a error message when the code detects a
-         condition which should not happen.
+         you should output an error message when the code detects a
+         condition which should not happen. In other words, important
+         things that are not warnings (see below), are errors.
 	 Examples: unexpected change in internal state, etc.
 
 WARN  -- These are warning messages. You should report a warning when
@@ -67,8 +71,8 @@
 Debugging channels
 ------------------
 
-Also, we divide the debugging messages per component. Each component
-is assigned a debugging channel. The identifier of the
+Also, we divide the debugging messages on a component basis. Each
+component is assigned a debugging channel. The identifier of the
 channel must be a valid C identifier but note that it may also be a
 reserve word like int or static.
 
@@ -80,7 +84,7 @@
 Note: for those who know the old interface, the channel/type is
       what followed the _ in the dprintf_xxx statements.
       For example, to output a message on the debugging channel
-      reg in the old interface you would have to write:
+      reg in the old interface you would had to write:
 
       dprintf_reg(stddeb, "Could not access key!\n");
 
@@ -88,15 +92,12 @@
       However, we add an orthogonal piece of information to the
       message: its class. This is very important as it will allow
       us to selectively turn on or off certain messages based on the
-      type of information they report. For this reason it is VERY
-      important to choose the right class for the message. 
+      type of information they report. For this reason it is essential
+      to choose the right class for the message. 
       Anyhow, suppose we figured that this message should belong
       in the WARN class, so in the new interface, you write:
 
-      WARN(reg, "Could not access key!");
-
-      Notice the \n is no longer required.
-
+      WARN(reg, "Could not access key!\n");
 ---
 
 How to use it
@@ -117,8 +118,7 @@
 
 ...
 
-  TRACE(crtdll, "CRTDLL_setbuf(file %p buf %p)",
-	       file, buf);
+  TRACE(crtdll, "CRTDLL_setbuf(file %p buf %p)", file, buf);
 
   WARN(aspi, "Error opening device errno=%d", save_error);
 
@@ -142,10 +142,9 @@
       he will most likely miss those because usually the TRACE class
       is turned off. A similar argument can be made if you mix any
       other two classes.
-   2. All lines end by default with a newline. So you should not
-      add one more.  If you can NOT output everything that you want in 
-      the line with only one statement, then you need to build the string
-      in memory.
+   2. All lines should end with a newline.If you can NOT output 
+      everything that you want in the line with only one statement, 
+      then you need to build the string in memory.
       Please read the section below "In-memory messages" on the
       preferred way to do it. PLEASE USE THAT INTERFACE TO BUILD
       MESSAGES IN MEMORY. The reason is that we are not sure that
@@ -160,19 +159,19 @@
 To test whether the debugging output of class yyy on channel xxx is
 enabled, use:
 
-TRACING  to test if TRACE is enabled
-WARNING  to test if WARN is enabled
-FIXMING  to test if FIXME is enabled
-ERRING   to test if ERR is enabled
+TRACE_ON  to test if TRACE is enabled
+WARN_ON   to test if WARN is enabled
+FIXME_ON  to test if FIXME is enabled
+ERR_ON    to test if ERR is enabled
 
 Examples:
 
-if(TRACING(atom)){
+if(TRACE_ON(atom)){
   ...blah...
 }
 
-Note that you should normaly need to test only if TRACING. At present,
-none of the other 3 tests (except for ERRING which is used only once!)
+Note that you should normally need to test only if TRACE_ON. At present,
+none of the other 3 tests (except for ERR_ON which is used only once!)
 are used in Wine.
 
 In-memory messages
@@ -299,7 +298,7 @@
 
 Thus, to use it, do something on the following lines:
 
-#include "debugstr.h"
+#include "debug.h"
 
 ...
 
@@ -351,6 +350,108 @@
    - the fixme and err classes are enabled by default
    - the trace and warn  classes are disabled by default
    - there is no way to compile out the messages. All are 
-     runtime configurable. This will come next release.
+     runtime configurable. This will (hopefully) come next 
+     release.
 
 
+A Few Notes on Style
+--------------------
+
+This new scheme makes certain things more consistent but there is still
+room for improvement by using a common style of debug messages. Before
+I continue, let me note that the output format is the following:
+
+yyy:xxx:fff <message>
+
+where: 
+  yyy = the class (fixme, err, warn, trace)
+  xxx = the channel (atom, win, font, etc)
+  fff = the function name
+these fields are output automatically. All you have to provide is
+the <message> part.
+
+So here are some ideas:
+
+* do NOT include the name of the function: it is included automatically
+
+* if you want to output the parameters of the function, do it as the first
+thing and include them in parenthesis, like this:
+
+   YYY(xxx, "(%d,%p,etc)...\n", par1, par2, ...);
+
+* for stubs, you should output a FIXME message. I suggest this style:
+
+   FIXME(xxx, "(%x,%d...): stub\n", par1, par2, ...);
+
+  That is, you output the parameters, then a : and then a string
+containing the word "stub". I've seen "empty stub", and others, but I
+think that just "stub" suffices.
+
+* output 1 and ONLY 1 line per message. That is, the format string should
+contain only 1 \n and it should always appear at the end of the string.
+(there are many reasons  for this requirement, one of them is that each
+debug macro adds things to the beginning of the line)
+
+* if you want to name a value, use = and NOT :. That is, instead of
+saying:
+  FIXME(xxx, "(fd: %d, file: %s): stub\n", fd, name);
+say:
+  FIXME(xxx, "(fd=%d, file=%s): stub\n", fd, name);
+
+use : to separate categories.
+
+* try to avoid the style:
+
+   FIXME(xxx,
+         "(fd: %d, file: %s): stub\n", fd, name);
+but use:
+
+  FIXME(xxx, "(fd: %d, file: %s): stub\n", fd, name);
+
+The reason is that if you want to grep for things, you would search for
+FIXME but in the first case there is no additional information available,
+where in the second one, there is (e.g. the word stub)
+
+* if you output a string s that might contain control characters,
+  or if s may be null, use debugstr_a (for ASCII strings, or
+  debugstr_w for Unicode strings) to convert s to a C string, like 
+  this:
+
+   HANDLE32 WINAPI YourFunc(LPCSTR s)
+{
+   FIXME(xxx, "(%s): stub\n", debugstr_a(s));
+}
+
+* if you want to output a resource identifier, use debugres to
+  convert it to a string first, like this:
+
+   HANDLE32 WINAPI YourFunc(LPCSTR res)
+{
+   FIXME(xxx, "(res=%s): stub\n", debugres(s));
+}
+
+if the resource identifier is a SEGPTR, use PTR_SEG_TO_LIN to get a
+liner pointer first:
+
+HRSRC16 WINAPI FindResource16( HMODULE16 hModule, SEGPTR name, SEGPTR type )
+{
+[...]
+    TRACE(resource, "module=%04x name=%s type=%s\n", 
+		 hModule, debugres(PTR_SEG_TO_LIN(name)), 
+		 debugres(PTR_SEG_TO_LIN(type)) );
+[...]
+}
+
+* for messages intended for the user (specifically those that report
+  errors in wine.conf), use the MSG macro. Use it like a printf:
+
+           MSG( "Definition of drive %d is incorrect!\n", drive ); 
+
+  However, note that there are _very_ few valid uses of this macro.
+  Most messages are debugging messages, so chances are you will not
+  need to use this macro. Grep the source to get an idea where it
+  is appropriate to use it.
+
+* for structure dumps, use the DUMP macro. Use it like a printf,
+  just like the MSG macro. Similarly, there are only a few valid
+  uses of this macro. Grep the source to see when to use it.
diff --git a/documentation/status/directdraw b/documentation/status/directdraw
new file mode 100644
index 0000000..04b0e1a
--- /dev/null
+++ b/documentation/status/directdraw
@@ -0,0 +1,74 @@
+This file contains information on the current implementation of the DirectDraw
+API.
+
+The DirectDraw API is being used in a lot of current computergames. Its API
+layer is represented by the functions in the Win32 DLL ddraw.dll and the
+IDirectDraw* interfaces (that can be created using the API functions). 
+
+WINE currently implements a very basic set of the DirectDraw functionality
+in graphics/ddraw.c. This implementation uses the XFree86-DGA extension 
+to get very fast access to the graphics card framebuffer and doublebuffering
+features. It is as fast as the MS equivalent for the stuff that is implemented.
+Several applications already work, see below.
+Problems of the implementation using XFree86-DGA:
+
+	- XFree86 cannot switch resolution nor depth on the fly.
+	  This is a problem with X and unavoidable.
+	  Current solution is to pop up a MessageBox with an error for 
+	  mismatched parameters and advice the user to restart the X server
+	  with the specified depth and/or screensize.
+	- The rest of the functionality that has to be implemented will have
+	  to be done in software and will be very slow.
+	- This requires WINE to be run as root user so XF86DGA can mmap the
+	  framebuffer into the addressspace of the process.
+	- Blocks all other X windowed applications.
+
+TODO:
+	- Add more implementations of the DirectDraw API.
+	  Primary candidate is a raw Xlib implementation (one with/one without
+	  XShm extension).
+	  An additional layer (basically a HAL) will be required to decide on 
+	  case-by-case basis which implementation to use.
+
+Status:
+   - Diablo [640x480x8]:
+     The movies play with speed comparable to the MS DDRAW one.
+     The game doesn't work, it somehow tries to write into 2 lines _BEFORE_
+     the start of the surface. I have tried to investigate this, but it is
+     in code that is automatically generated.
+  
+   - WingCommander 4 / Win95 Patch [640x480x8]:
+     The intromovie plays, in 8 bit mode (to reconfigure wc4, run wine
+     "wc4w.exe -I"). The 16bit mode looks broken on Mystique, but I think
+     this is due to the unusual colorweight (565 rgb) of the Mystique in 16bit
+     mode. [Specifying it in DDPIXELFORMAT didn't help.]
+
+     Requires to be run in 640x480xdepth mode (doesn't seem to heed
+     DDSURFACEDESC.lPitch).
+     You can even fly the first mission with Maniac (ignore the weird sounds),
+     but it crashes as soon as you arrive at Blue Point Station...
+  
+   - Monkey Island 3 [640x480x8]:
+     Goes to the easy/hard selection screen, then hangs due to multithreaded
+     windows-messagehandling problems.
+   
+   - DiscWorld 2 [640x480x8]:
+     [Crashes with 'cli' in WINE released version. Yes. Privileged instructions
+      in 32bit code. Will they ever learn...]
+     Plays through nearly all intro movies. Sound and animation skip a lot of
+     stuff (possible DirectSound asynchronization problem).
+   
+   - XvT [640x480x16]:
+     Shows the splash screen, then fails with missing Joystick. I have
+     investigated but failed to find a reason for this.
+  
+   - Tomb Raider 2 Demo (using 8 bit renderer) [640x480x8]:
+     I have played nearly all of the DEMO level using Keyboard Controls.
+     Sound is a bit weird. Keyboard/Mouse handling too due to incomplete
+     DirectInput.
+  
+   - WingCommander Prophecy Demo (using software renderer) [640x480x16]:
+     [Crashes with an invalid opcode (outb, probably to test for 3dFX) in the
+      WINE release version.]
+     Plays trailer, hangs in selection screen (no keyboard input, DirectInput
+     problem).
diff --git a/documentation/status/directsound b/documentation/status/directsound
new file mode 100644
index 0000000..64a72bf
--- /dev/null
+++ b/documentation/status/directsound
@@ -0,0 +1,37 @@
+This file contains information on the current implementation of the DirectSound
+API.
+
+The DirectSound API can be found in the Win32 DLL dsound.dll and in the
+IDirectSound* interfaces. It is implemented in multimedia/dsound.c.
+
+The current implementation uses the Linux/FreeBSD OpenSoundSystem. Some
+applications already work. There is only the basic part of the interfaces 
+implemented, but it is the stuff used by 90% of the applications.
+It also uses multithreading, so it will only work on systems with working
+CreateThread.
+
+Tested with SoundBlaster(16) clone and Gravis UltraSound Classic.
+
+TODO:
+	- Add support for other audiosystems.
+		+ Sun Audio. (Solaris and probably the *BSDs except FreeBSD.)
+		+ remote audio support (No clue as to what systems there are.
+		  Use some audio xextensions?)
+	- Add support for mixing of different frequency and panning.
+	- Fix all the multithread pending race conditions and the like.
+	- Share filedescriptors and other stuff with mciwave/waveoutdevice code.
+
+
+Gamestatus:
+	- Wing Commander 4/W95:
+	  The intromovie plays without problems. Nearly lipsynchron.
+	- DiscWorld 2
+	  The sound works, but noticeable chunks are left out (from the sound
+	  and the animation). Don't know why yet.
+	- Diablo:
+	  Sound works, but slows down the movieplayer. In the (hacked version)
+	  game the sound is positively weird.
+	- Monkey Island 3:
+	  The background sound of the startscreen works.
+	- WingCommander Prophecy Demo:
+	  Sound works for the intromovie.
diff --git a/files/directory.c b/files/directory.c
index 8ab2720..12c2902 100644
--- a/files/directory.c
+++ b/files/directory.c
@@ -351,6 +351,7 @@
     if (!DOSFS_GetFullName( path, FALSE, &full_name )) return 0;
     if ((mkdir( full_name.long_name, 0777 ) == -1) && (errno != EEXIST))
     {
+      WARN (file, "Errno %i trying to create directory %s.\n", errno, full_name.long_name);
         FILE_SetDosError();
         return FALSE;
     }
diff --git a/graphics/metafiledrv/init.c b/graphics/metafiledrv/init.c
index a02d7ff..c26b066 100644
--- a/graphics/metafiledrv/init.c
+++ b/graphics/metafiledrv/init.c
@@ -11,6 +11,8 @@
 #include "metafile.h"
 #include "debug.h"
 
+#include <string.h>
+
 static const DC_FUNCTIONS MFDRV_Funcs =
 {
     MFDRV_Arc,                       /* pArc */
@@ -179,22 +181,19 @@
     return dc->hSelf;
 }
 
-
-/******************************************************************
- *	     CloseMetaFile16   (GDI.126)
- *
- *  Stop recording graphics operations in metafile associated with
- *  hdc and retrieve metafile.
- *
- * RETURNS
- *  Handle of newly created metafile on success, NULL on failure.
+/**********************************************************************
+ *	     CreateMetaFile32A   (GDI32.51)
  */
-HMETAFILE16 WINAPI CloseMetaFile16( 
-				   HDC16 hdc /* Metafile DC to close */
+HDC32 WINAPI CreateMetaFile32A( 
+			      LPCSTR filename /* Filename of disk metafile */
 )
 {
+  return CreateMetaFile16( filename );
+}
+
+static DC *METAFILE_CloseMetaFile( HDC32 hdc ) 
+{
     DC *dc;
-    HMETAFILE16 hmf;
     HFILE32 hFile;
     METAFILEDRV_PDEVICE *physDev;
     
@@ -231,6 +230,22 @@
         _lclose32(hFile);
     }
 
+    return dc;
+}
+
+/******************************************************************
+ *	     CloseMetaFile16   (GDI.126)
+ */
+HMETAFILE16 WINAPI CloseMetaFile16( 
+				   HDC16 hdc /* Metafile DC to close */
+)
+{
+    HMETAFILE16 hmf;
+    METAFILEDRV_PDEVICE *physDev;
+    DC *dc = METAFILE_CloseMetaFile(hdc);
+    if (!dc) return 0;
+    physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
+
     /* Now allocate a global handle for the metafile */
 
     hmf = GLOBAL_CreateBlock( GMEM_MOVEABLE, physDev->mh,
@@ -241,12 +256,25 @@
     return hmf;
 }
 
+/******************************************************************
+ *	     CloseMetaFile32   (GDI32.17)
+ *
+ *  Stop recording graphics operations in metafile associated with
+ *  hdc and retrieve metafile.
+ *
+ * RETURNS
+ *  Handle of newly created metafile on success, NULL on failure.
+ */
+HMETAFILE32 WINAPI CloseMetaFile32( 
+				   HDC32 hdc /* Metafile DC to close */
+)
+{
+  return CloseMetaFile32(hdc);
+}
+
 
 /******************************************************************
  *	     DeleteMetaFile16   (GDI.127)
- *
- *  Delete a memory-based metafile.
- *
  */
 BOOL16 WINAPI DeleteMetaFile16( 
 			       HMETAFILE16 hmf 
@@ -256,3 +284,77 @@
     return !GlobalFree16( hmf );
 }
 
+/******************************************************************
+ *          DeleteMetaFile32  (GDI32.69)
+ *
+ *  Delete a memory-based metafile.
+ */
+
+BOOL32 WINAPI DeleteMetaFile32(
+	      HMETAFILE32 hmf
+) {
+  return !GlobalFree16( hmf );
+}
+
+/********************************************************************
+
+       Enhanced Metafile driver initializations
+
+       This possibly  should be moved to their own file/directory
+       at some point.
+
+**********************************************************************/
+
+/*
+  need wide version as well
+*/
+HDC32 CreateEnhMetaFile32A( 
+    HDC32 hdc, /* optional reference DC */
+    LPCSTR filename, /* optional filename for disk metafiles */
+    const RECT32 *rect, /* optional bounding rectangle */
+    LPCSTR description /* optional description */ 
+    )
+{
+#if 0
+    DC *dc;
+    METAFILEDRV_PDEVICE *physDev;
+    HFILE32 hFile;
+
+    if (!(dc = MFDRV_AllocMetaFile())) return 0;
+    physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
+    
+    if (filename)  /* disk based metafile */
+    {
+        physDev->mh->mtType = METAFILE_DISK;
+        if ((hFile = _lcreat32( filename, 0 )) == HFILE_ERROR32)
+        {
+            MFDRV_DeleteDC( dc );
+            return 0;
+        }
+        if (_lwrite32( hFile, (LPSTR)physDev->mh,
+                       sizeof(*physDev->mh)) == HFILE_ERROR32)
+	{
+            MFDRV_DeleteDC( dc );
+            return 0;
+	}
+	physDev->mh->mtNoParameters = hFile; /* store file descriptor here */
+	                            /* windows probably uses this too*/
+    }
+    else  /* memory based metafile */
+	physDev->mh->mtType = METAFILE_MEMORY;
+
+    TRACE(metafile, "returning %04x\n", dc->hSelf);
+    return dc->hSelf;
+#endif
+    return 0;
+}
+
+HENHMETAFILE32 CloseEnhMetaFile32( 
+               HDC32 hdc  /* metafile DC */
+	       )
+{
+  /* write EMR_EOF(0x0, 0x10, 0x14) */
+  return 0;
+}
+
+
diff --git a/graphics/painting.c b/graphics/painting.c
index 2511ec4..b6ac7d8 100644
--- a/graphics/painting.c
+++ b/graphics/painting.c
@@ -695,8 +695,8 @@
                                    const LPRECT32 lprcFrom,
                                    const LPRECT32 lprcTo )
 {
-    fprintf( stdnimp,"DrawAnimatedRects32(%x,%d,%p,%p), empty stub!\n",
-             hwnd, idAni, lprcFrom, lprcTo );
+    FIXME(gdi,"(%x,%d,%p,%p): empty stub!\n",
+	  hwnd, idAni, lprcFrom, lprcTo );
     return TRUE;
 }
 
diff --git a/graphics/win16drv/init.c b/graphics/win16drv/init.c
index 8b1a896..4440d81 100644
--- a/graphics/win16drv/init.c
+++ b/graphics/win16drv/init.c
@@ -173,11 +173,12 @@
                              printerEnabled, sizeof(printerEnabled) );
     if (lstrcmpi32A(printerEnabled,"on"))
     {
-        printf("WIN16DRV_CreateDC disabled in wine.conf file\n");
+        MSG("WIN16DRV_CreateDC disabled in wine.conf file\n");
         return FALSE;
     }
 
-    TRACE(win16drv, "In creatdc for (%s,%s,%s) initData 0x%p\n",driver, device, output, initData);
+    TRACE(win16drv, "In creatdc for (%s,%s,%s) initData 0x%p\n",
+	  driver, device, output, initData);
 
     physDev = (WIN16DRV_PDEVICE *)HeapAlloc( SystemHeap, 0, sizeof(*physDev) );
     if (!physDev) return FALSE;
@@ -205,11 +206,9 @@
     dc->w.hVisRgn = CreateRectRgn32(0, 0, dc->w.devCaps->horzRes, dc->w.devCaps->vertRes);
     dc->w.bitsPerPixel = dc->w.devCaps->bitsPixel;
     
-    printf("Got devcaps width %d height %d bits %d planes %d\n",
-           dc->w.devCaps->horzRes,
-           dc->w.devCaps->vertRes, 
-           dc->w.devCaps->bitsPixel,
-           dc->w.devCaps->planes);
+    TRACE(win16drv, "Got devcaps width %d height %d bits %d planes %d\n",
+	  dc->w.devCaps->horzRes, dc->w.devCaps->vertRes, 
+	  dc->w.devCaps->bitsPixel, dc->w.devCaps->planes);
 
     /* Now we allocate enough memory for the PDEVICE structure */
     /* The size of this varies between printer drivers */
@@ -276,15 +275,15 @@
 	switch(nEscape)
           {
 	  case ENABLEPAIRKERNING:
-	    fprintf(stderr,"Escape: ENABLEPAIRKERNING ignored.\n");
+	    FIXME(win16drv,"Escape: ENABLEPAIRKERNING ignored.\n");
             nRet = 1;
 	    break;
 	  case GETPAIRKERNTABLE:
-	    fprintf(stderr,"Escape: GETPAIRKERNTABLE ignored.\n");
+	    FIXME(win16drv,"Escape: GETPAIRKERNTABLE ignored.\n");
             nRet = 0;
 	    break;
           case SETABORTPROC:
-	    printf("Escape: SetAbortProc ignored should be stored in dc somewhere\n");
+	    FIXME(win16drv,"Escape: SetAbortProc ignored should be stored in dc somewhere\n");
             /* Make calling application believe this worked */
             nRet = 1;
 	    break;
@@ -335,7 +334,7 @@
 	}
     }
     else
-	fprintf(stderr, "Escape(nEscape = %04x)\n", nEscape);      
+	WARN(win16drv, "Escape(nEscape = %04x) - ???\n", nEscape);      
     return nRet;
 }
 
@@ -361,12 +360,12 @@
 
 HPQ WINAPI CreatePQ(int size) 
 {
-    printf("CreatePQ: %d\n",size);
+    FIXME(win16drv, "(%d): stub\n",size);
     return 1;
 }
 int WINAPI DeletePQ(HPQ hPQ) 
 {
-    printf("DeletePQ: %x\n", hPQ);
+    FIXME(win16drv, "(%x): stub\n", hPQ);
     return 0;
 }
 int WINAPI ExtractPQ(HPQ hPQ) 
@@ -402,7 +401,7 @@
         free(queue);
     }
     
-    printf("ExtractPQ: %x got tag %d key %d\n", hPQ, tag, key); 
+    TRACE(win16drv, "%x got tag %d key %d\n", hPQ, tag, key); 
 
     return tag;
 }
@@ -415,17 +414,17 @@
     queueItem->key = key;
     queueItem->tag = tag;
     
-    printf("InsertPQ: %x %d %d\n", hPQ, tag, key);
+    FIXME(win16drv, "(%x %d %d): stub???\n", hPQ, tag, key);
     return TRUE;
 }
 int WINAPI MinPQ(HPQ hPQ) 
 {
-    printf("MinPQ: %x\n", hPQ); 
+    FIXME(win16drv, "(%x): stub\n", hPQ); 
     return 0;
 }
 int WINAPI SizePQ(HPQ hPQ, int sizechange) 
 {  
-    printf("SizePQ: %x %d\n", hPQ, sizechange); 
+    FIXME(win16drv, "(%x %d): stub\n", hPQ, sizechange); 
     return -1; 
 }
 
@@ -468,9 +467,9 @@
     if (pszOutput == NULL || *pszOutput == '\0')
       return -1;
 
-    PROFILE_GetWineIniString( "spooler", pszOutput, "",
-                              psCmd, sizeof(psCmd) );
-    printf("Got printerSpoolCommand \"%s\" for output device \"%s\"\n",psCmd, pszOutput);
+    PROFILE_GetWineIniString( "spooler", pszOutput, "", psCmd, sizeof(psCmd) );
+    TRACE(win16drv, "Got printerSpoolCommand '%s' for output device '%s'\n",
+	  psCmd, pszOutput);
     if (!*psCmd)
         psCmdP = pszOutput;
     else
@@ -491,7 +490,7 @@
         {
             psCmdP++;
 
-            printf("In child need to exec %s\n",psCmdP);
+            TRACE(win16drv, "In child need to exec %s\n",psCmdP);
             close(0);
             dup2(fds[0],0);
             close (fds[1]);
@@ -501,15 +500,16 @@
         }
         close (fds[0]);
         fd = fds[1];
-        printf("Need to execute a command and pipe the output to it\n");
+        TRACE(win16drv,"Need to execute a cmnd and pipe the output to it\n");
     }
     else
     {
-        printf("Just assume its a file\n");
+        TRACE(win16drv, "Just assume its a file\n");
 
         if ((fd = open(psCmdP, O_CREAT | O_TRUNC | O_WRONLY , 0600)) < 0)
         {
-            printf("Failed to create spool file %s, errno = %d\n", psCmdP, errno);
+            ERR(win16drv, "Failed to create spool file %s, errno = %d\n", 
+		psCmdP, errno);
         }
     }
     return fd;
@@ -538,7 +538,7 @@
     HANDLE16 hHandle = (HANDLE16)SP_ERROR;
     PPRINTJOB pPrintJob;
 
-    TRACE(win16drv, "\"%s\" \"%s\" %04x\n", lpOutput, lpTitle, hDC);
+    TRACE(win16drv, "'%s' '%s' %04x\n", lpOutput, lpTitle, hDC);
 
     pPrintJob = gPrintJobsTable[0];
     if (pPrintJob == NULL)
diff --git a/graphics/win16drv/prtdrv.c b/graphics/win16drv/prtdrv.c
index 6968f09..b7fe5ff 100644
--- a/graphics/win16drv/prtdrv.c
+++ b/graphics/win16drv/prtdrv.c
@@ -573,7 +573,7 @@
                                                 lP11, lP12, lP13,
                                                 SEGPTR_GET(lP14));
         SEGPTR_FREE(lP14);
-        printf("Called StretchBlt ret %d\n",wRet);
+        TRACE(win16drv, "Called StretchBlt ret %d\n",wRet);
     }
     return wRet;
 }
diff --git a/graphics/wing.c b/graphics/wing.c
index f167633..da9c315 100644
--- a/graphics/wing.c
+++ b/graphics/wing.c
@@ -57,7 +57,7 @@
 	return;
       }
     } 
-    fprintf(stdnimp,"WinG: no joy.\n");
+    FIXME(wing,"WinG: no joy.\n");
     __WinGOK = False;
   }
 }
@@ -79,7 +79,7 @@
  */
 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *fmt)
 {
-  fprintf(stdnimp,"WinGRecommendDIBFormat()\n");
+  FIXME(wing,"(%p): stub\n", fmt);
 
   if( __WinGOK > 0 && fmt )
   {
@@ -95,14 +95,16 @@
 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 winDC, BITMAPINFO *header,
                                     void **bits)
 {
-  fprintf(stdnimp,"WinGCreateBitmap: empty stub! (expect failure)\n");
+  FIXME(wing,"(%x,%p,%p): empty stub! (expect failure)\n", 
+	winDC, header, bits);
   if( __WinGOK > 0 && header )
   {
     BITMAPINFOHEADER* bmpi = &header->bmiHeader;
 
-    fprintf(stdnimp,"bytes\t=%i\nplanes\t=%i\nbpp\t=%i\nx\t=%i\ny\t=%i\nrle\t=0x%08x\nsize\t=%i\n",
-     (int)bmpi->biSize, bmpi->biPlanes, bmpi->biBitCount,
-     (int)bmpi->biWidth, (int)bmpi->biHeight, (unsigned)bmpi->biCompression, (int)bmpi->biSizeImage);
+     FIXME(wing,"bytes=%i,planes=%i,bpp=%i,x=%i,y=%i,rle=0x%08x,size=%i\n",
+	   (int)bmpi->biSize, bmpi->biPlanes, bmpi->biBitCount,
+	   (int)bmpi->biWidth, (int)bmpi->biHeight, 
+	   (unsigned)bmpi->biCompression, (int)bmpi->biSizeImage);
 
 #ifdef PRELIMINARY_WING16_SUPPORT
     if( bmpi->biPlanes == __bmpiWinG.biPlanes && bmpi->biBitCount == __bmpiWinG.biBitCount &&
@@ -207,7 +209,7 @@
 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hWinGDC, UINT16 start, UINT16 num,
                                      RGBQUAD* pColor)
 {
-        fprintf(stdnimp,"WinGSetDIBColorTable: empty stub!\n");
+        FIXME(wing,"(%x,%d,%d,%p): empty stub!\n",hWinGDC,start,num,pColor);
         return num;
 }
 
@@ -215,9 +217,9 @@
  *  WinGGetDIBColorTable16   (WING.1005)
  */
 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 winDC, UINT16 start,
-                                     UINT16 numentry, RGBQUAD* colors)
+                                     UINT16 num, RGBQUAD* colors)
 {
-	fprintf(stdnimp,"WinGGetDIBColorTable: empty stub!\n");
+        FIXME(wing,"(%x,%d,%d,%p): empty stub!\n",winDC,start,num,colors);
 	return 0;
 }
 
@@ -226,7 +228,7 @@
  */
 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
 {
-        fprintf(stdnimp,"WinGCreateHalfTonePalette: empty stub!\n");
+        FIXME(wing,"(void): empty stub!\n");
 	return 0;
 }
 
@@ -236,7 +238,7 @@
 HPALETTE16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
                                             WING_DITHER_TYPE type)
 {
-        fprintf(stdnimp,"WinGCreateHalfToneBrush: empty stub!\n");
+        FIXME(wing,"(...): empty stub!\n");
 	return 0;
 }
 
@@ -250,8 +252,6 @@
 {
 
         return StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC, xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
-/*        fprintf(stdnimp,"WinGStretchBlt16: empty stub!\n");*/
-/*      return 0; */
 }
 
 /***********************************************************************
diff --git a/graphics/x11drv/init.c b/graphics/x11drv/init.c
index 600c980..2193fb9 100644
--- a/graphics/x11drv/init.c
+++ b/graphics/x11drv/init.c
@@ -116,9 +116,9 @@
     /* Finish up device caps */
 
 #if 0
-    printf("Display:\nHeight = %-4i pxl, %-4i mm\nWidth  = %-4i pxl, %-4i mm\n",
-	    HeightOfScreen(screen), HeightMMOfScreen(screen),
-	    WidthOfScreen(screen), WidthMMOfScreen(screen) );
+    TRACE(x11drv, "Height = %-4i pxl, %-4i mm, Width  = %-4i pxl, %-4i mm\n",
+	  HeightOfScreen(screen), HeightMMOfScreen(screen),
+	  WidthOfScreen(screen), WidthMMOfScreen(screen) );
 #endif
 
     X11DRV_DevCaps.version = 0x300;
diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c
index 561fc9e..01c547d 100644
--- a/graphics/x11drv/xfont.c
+++ b/graphics/x11drv/xfont.c
@@ -24,8 +24,6 @@
 #include "font.h"
 #include "debug.h"
 
-#define DEBUG_FONT_INIT		1
-
 #define X_PFONT_MAGIC		(0xFADE0000)
 #define X_FMC_MAGIC		(0x0000CAFE)
 
@@ -824,9 +822,8 @@
 		fi->df.dfPitchAndFamily |= bFamilyStyle;
 	}
 
-#ifdef DEBUG_FONT_INIT
 	TRACE(font,"typeface \'%s\'\n", fr->lfFaceName);
-#endif
+
 	fr->fr_flags |= FR_NAMESET;
     }
 
@@ -865,9 +862,8 @@
 	/* check if we already got one */
 	if( !lstrcmpi32A( pfa->faTypeFace, lpAlias ) )
 	{
-#ifdef DEBUG_FONT_INIT
-	    TRACE(font,"\tredundant alias '%s' -> '%s'\n", lpAlias, lpTypeFace );
-#endif
+	    TRACE(font,"\tredundant alias '%s' -> '%s'\n", 
+		  lpAlias, lpTypeFace );
 	    return NULL;
 	} 
 	if( pfa->next ) pfa = pfa->next;
@@ -885,9 +881,8 @@
         pfa->faAlias = pfa->faTypeFace + j;
         lstrcpy32A( pfa->faAlias, lpAlias );
 
-#ifdef DEBUG_FONT_INIT
         TRACE(font, "\tadded alias '%s' for %s\n", lpAlias, lpTypeFace );
-#endif
+
 	return pfa;
     }
     return NULL;
@@ -987,10 +982,9 @@
 			    prev = pfa;
 			}
 						
-#ifdef DEBUG_FONT_INIT
                         TRACE(font, "\tsubstituted '%s' with %s\n",
 						frMatch->lfFaceName, lpAlias );
-#endif
+
 			lstrcpyn32A( frMatch->lfFaceName, lpAlias, LF_FACESIZE );
 			frMatch->fr_flags |= FR_NAMESET;
 		    }
@@ -1001,7 +995,7 @@
 		    }
 		}
 	    }
-	    else fprintf(stderr, "XFONT_Init: malformed font alias '%s'\n", *buffer );
+	    else ERR(font, " malformed font alias '%s'\n", *buffer );
 	}
 	else break;
     } while(TRUE);
@@ -1395,9 +1389,7 @@
 	   fr->resource = (char*) HeapAlloc(SystemHeap, 0, j + 1 );
 	   lstrcpyn32A( fr->resource, typeface, j + 1 );
 
-#ifdef DEBUG_FONT_INIT
 	   TRACE(font,"    family: %s\n", fr->resource );
-#endif
 
 	   if( pfr ) pfr->next = fr;
 	   else fontList = fr;
@@ -1439,15 +1431,14 @@
 	   XFONT_SetFontMetric( fi, fr, x_fs );
            TSXFreeFont( display, x_fs );
 
-#ifdef DEBUG_FONT_INIT
 	   TRACE(font,"\t[% 2ipt] '%s'\n", fi->df.dfPoints, typeface );
-#endif
+
 	   XFONT_CheckFIList( fr, fi, REMOVE_SUBSETS );
 	   fi = NULL;	/* preventing reuse */
         }
         else
         {
-           fprintf(stderr, "FONT_Init: failed to load %s\n", lpstr );
+           ERR(font, "failed to load %s\n", lpstr );
 
            XFONT_CheckFIList( fr, fi, UNMARK_SUBSETS );
         }
@@ -1484,9 +1475,7 @@
   fontCache = (fontObject*) HeapAlloc(SystemHeap, 0, fontCacheSize * sizeof(fontObject));
   XFONT_GrowFreeList(0, fontCacheSize - 1);
 
-#ifdef DEBUG_FONT_INIT
-        TRACE(font,"done!\n");
-#endif
+  TRACE(font,"done!\n");
 
   /* update text caps parameter */
 
@@ -1716,9 +1705,7 @@
     fr->count++;
   }
 
-#ifdef DEBUG_FONT_INIT
   if( i ) TRACE(font,"\t    purged %i subsets [%i]\n", i , fr->count);
-#endif
 }
 
 /***********************************************************************
@@ -2226,10 +2213,7 @@
  */
 INT32 WINAPI AddFontResource32A( LPCSTR str )
 {
-    if (HIWORD(str))	/* font file */
-        fprintf( stdnimp, "STUB: AddFontResource('%s')\n", str );
-    else		/* font resource handle */
-        fprintf( stdnimp, "STUB: AddFontResource(%04x)\n", LOWORD(str) );
+    FIXME(font, "(%s): stub\n", debugres(str));
     return 1;
 }
 
@@ -2239,7 +2223,7 @@
  */
 INT32 WINAPI AddFontResource32W( LPCWSTR str )
 {
-    fprintf( stdnimp, "STUB: AddFontResource32W(%p)\n", str );
+    FIXME(font, "(%p): stub\n", str );
     return 1;
 }
 
@@ -2248,11 +2232,7 @@
  */
 BOOL16 WINAPI RemoveFontResource16( SEGPTR str )
 {
-    if (HIWORD(str))
-        fprintf( stdnimp, "STUB: RemoveFontResource('%s')\n",
-		(char *)PTR_SEG_TO_LIN( str) );
-    else
-        fprintf( stdnimp, "STUB: RemoveFontResource(%04x)\n", LOWORD(str) );
+    FIXME(font, "(%s): stub\n",	debugres(PTR_SEG_TO_LIN(str)));
     return TRUE;
 }
 
@@ -2262,10 +2242,7 @@
  */
 BOOL32 WINAPI RemoveFontResource32A( LPCSTR str )
 {
-    if (HIWORD(str))
-        fprintf( stdnimp, "STUB: RemoveFontResource('%s')\n", str );
-    else
-        fprintf( stdnimp, "STUB: RemoveFontResource(%04x)\n", LOWORD(str) );
+    FIXME(font, "(%s): stub\n", debugres(str));
     return TRUE;
 }
 
@@ -2275,7 +2252,7 @@
  */
 BOOL32 WINAPI RemoveFontResource32W( LPCWSTR str )
 {
-    fprintf( stdnimp, "STUB: RemoveFontResource32W(%p)\n", str );
+    FIXME(font, "(%p): stub\n", str );
     return TRUE;
 }
 
diff --git a/if1632/builtin.c b/if1632/builtin.c
index 905c982..a0f2d2f 100644
--- a/if1632/builtin.c
+++ b/if1632/builtin.c
@@ -109,7 +109,7 @@
     { &STORAGE_Descriptor,  DLL_FLAG_NOT_USED },
     { &STRESS_Descriptor,   0 },
     { &TOOLHELP_Descriptor, 0 },
-    { &TYPELIB_Descriptor,  0 },
+    { &TYPELIB_Descriptor,  DLL_FLAG_NOT_USED },
     { &VER_Descriptor,      0 },
     { &W32SYS_Descriptor,   0 },
     { &WIN32S16_Descriptor, 0 },
diff --git a/if1632/dummy.c b/if1632/dummy.c
index 65c0da8..7babcac 100644
--- a/if1632/dummy.c
+++ b/if1632/dummy.c
@@ -6,7 +6,10 @@
 long WINAPI stub_GDI_382(void) { fprintf(stderr, "Warning: GDI_382:ABORTPROC unimplemented stub\n"); return 1; }
 long WINAPI stub_GDI_530(void) { fprintf(stderr, "Warning: GDI_530: unimplemented stub\n"); return 0; }
 long WINAPI stub_GDI_531(void) { fprintf(stderr, "Warning: GDI_531: unimplemented stub\n"); return 0; }
-long WINAPI stub_GDI_532(void) { fprintf(stderr, "Warning: GDI_532: unimplemented stub\n"); return 0; }
+long WINAPI stub_GDI_532(LPINT16 buffer, INT16 xx) { 
+      fprintf(stderr, "STUB GDI_532(%p, %hd)\n",buffer,xx); 
+      return 0; 
+}
 long WINAPI stub_GDI_536(void) { fprintf(stderr, "Warning: GDI_536: unimplemented stub\n"); return 0; }
 long WINAPI stub_GDI_538(void) { fprintf(stderr, "Warning: GDI_538: unimplemented stub\n"); return 0; }
 long WINAPI stub_GDI_540(void) { fprintf(stderr, "Warning: GDI_540: unimplemented stub\n"); return 0; }
diff --git a/if1632/gdi.spec b/if1632/gdi.spec
index bf7fd6f..2b6c962 100644
--- a/if1632/gdi.spec
+++ b/if1632/gdi.spec
@@ -354,7 +354,7 @@
 # Stubs for Hebrew version
 530 pascal16 GDI_530() stub_GDI_530
 531 pascal16 GDI_531() stub_GDI_531
-532 pascal16 GDI_532() stub_GDI_532
+532 pascal16 GDI_532(ptr word) stub_GDI_532
 536 pascal16 GDI_536() stub_GDI_536
 538 pascal16 GDI_538() stub_GDI_538
 540 pascal16 GDI_540() stub_GDI_540
diff --git a/if1632/kernel.spec b/if1632/kernel.spec
index 876397f..ab0ebdd 100644
--- a/if1632/kernel.spec
+++ b/if1632/kernel.spec
@@ -299,7 +299,7 @@
 420 pascal   GetFileAttributes(ptr) GetFileAttributes16
 421 pascal16 SetFileAttributes(ptr long) SetFileAttributes16
 422 pascal16 GetDiskFreeSpace(ptr ptr ptr ptr ptr) GetDiskFreeSpace16 
-431 pascal16 KERNEL_431(str word) KERNEL_431
+431 pascal16 IsPeFormat(str word) IsPeFormat
 432 stub FileTimeToLocalFileTime
 434 stub KERNEL_434
 435 stub KERNEL_435
@@ -356,6 +356,6 @@
 621 stub KERNEL_621
 627 stub IsBadFlatReadWritePtr
 630 stub KERNEL_630
-631 pascal FUNC004(word word word) FUNC004	#C16ThkSl01?
+631 register FUNC004(word word word) FUNC004	#C16ThkSl01?
 651 stub KERNEL_651				#ThunkConnect16?
 700 pascal KERNEL_700() stub_KERNEL_700
diff --git a/if1632/thunk.c b/if1632/thunk.c
index 57ad7ce..68a511b 100644
--- a/if1632/thunk.c
+++ b/if1632/thunk.c
@@ -618,9 +618,17 @@
 
 /***********************************************************************
  *           THUNK_WOWCallback16Ex	(WOW32.3)(KERNEL32.55)
+ * Generic thunking routine to call 16 bit functions from 32bit code.
+ * 
+ * RETURNS
+ * 	TRUE if the call was done
  */
 static BOOL32 WINAPI THUNK_WOWCallback16Ex(
-	FARPROC16 proc,DWORD dwFlags,DWORD cbArgs,LPVOID xargs,LPDWORD pdwret
+	FARPROC16 proc,		/* [in] 16bit function to call */
+	DWORD dwFlags,		/* [in] flags (WCB_*) */
+	DWORD cbArgs,		/* [in] number of arguments */
+	LPVOID xargs,		/* [in/out] arguments */
+	LPDWORD pdwret		/* [out] return value of the 16bit call */
 ) {
     LPDWORD     args = (LPDWORD)xargs;
     DWORD       ret,i;
diff --git a/if1632/typelib.spec b/if1632/typelib.spec
index b7876e8..7d2bccf 100644
--- a/if1632/typelib.spec
+++ b/if1632/typelib.spec
@@ -12,4 +12,4 @@
 10 stub REGISTERTYPELIB              
 11 stub LOADREGTYPELIB               
 14 pascal QueryPathOfRegTypeLib(ptr word word word ptr) QueryPathOfRegTypeLib
-15 stub OABUILDVERSION               
+15 pascal OABuildVersion() OABuildVersion               
diff --git a/if1632/user.spec b/if1632/user.spec
index 41bb045..2335bdb 100644
--- a/if1632/user.spec
+++ b/if1632/user.spec
@@ -399,8 +399,8 @@
 434 pascal16 IsCharAlphaNumeric(word) IsCharAlphaNumeric16
 435 pascal16 IsCharUpper(word) IsCharUpper16
 436 pascal16 IsCharLower(word) IsCharLower16
-437 pascal16 AnsiUpperBuff(ptr word) AnsiUpperBuff16
-438 pascal16 AnsiLowerBuff(ptr word) AnsiLowerBuff16
+437 pascal16 AnsiUpperBuff(str word) AnsiUpperBuff16
+438 pascal16 AnsiLowerBuff(str word) AnsiLowerBuff16
 441 pascal16 InsertMenuItem(word word word ptr) InsertMenuItem16
 443 stub GetMenuItemInfo
 445 pascal   DefFrameProc(word word word word long) DefFrameProc16
diff --git a/if1632/w32sys.spec b/if1632/w32sys.spec
index 378c482..98dd63d 100644
--- a/if1632/w32sys.spec
+++ b/if1632/w32sys.spec
@@ -2,12 +2,12 @@
 type	win16
 
 #1 WEP
-2 stub ISPEFORMAT
+2 pascal16 IsPeFormat(str word) IsPeFormat
 3 stub EXECPE
 4 stub GETPEEXEINFO
 5 return GETW32SYSVERSION 0 0x100
 6 stub LOADPERESOURCE
-7 stub GETPERESOURCETABLE
+7 pascal16 GetPEResourceTable(word) GetPEResourceTable
 8 stub EXECPEEX
 9 stub ITSME
 10 stub W32SERROR
diff --git a/include/bitmaps/obm_restore_95 b/include/bitmaps/obm_restore_95
new file mode 100644
index 0000000..886f675
--- /dev/null
+++ b/include/bitmaps/obm_restore_95
@@ -0,0 +1,23 @@
+/* XPM */
+static char * obm_restore_95[] = {
+"16 14 6 1",
+" 	s button_highlight	c white",
+"+	s button_edge	c grey85",
+"X	s button_face	c grey75",
+"o	s button_shadow	c grey50",
+".	s button_text	c black",
+"O	s window_frame	c black",
+"               O",
+" +++++++++++++oO",
+" +XXX......XXXoO",
+" +XXX......XXXoO",
+" +XXX.XXXX.XXXoO",
+" +X......X.XXXoO",
+" +X......X.XXXoO",
+" +X.XXXX...XXXoO",
+" +X.XXXX.XXXXXoO",
+" +X.XXXX.XXXXXoO",
+" +X......XXXXXoO",
+" +XXXXXXXXXXXXoO",
+" ooooooooooooooO",
+"OOOOOOOOOOOOOOOO"};
diff --git a/include/bitmaps/obm_restored_95 b/include/bitmaps/obm_restored_95
new file mode 100644
index 0000000..4886e06
--- /dev/null
+++ b/include/bitmaps/obm_restored_95
@@ -0,0 +1,23 @@
+/* XPM */
+static char * obm_restored_95[] = {
+"16 14 6 1",
+" 	s button_highlight	c white",
+"+	s button_edge	c grey85",
+"X	s button_face	c grey75",
+"o	s button_shadow	c grey50",
+".	s button_text	c black",
+"O	s window_frame	c black",
+"OOOOOOOOOOOOOOO ",
+"Oooooooooooooo+ ",
+"OoXXXXXXXXXXXX+ ",
+"OoXXXX......XX+ ",
+"OoXXXX......XX+ ",
+"OoXXXX.XXXX.XX+ ",
+"OoXX......X.XX+ ",
+"OoXX......X.XX+ ",
+"OoXX.XXXX...XX+ ",
+"OoXX.XXXX.XXXX+ ",
+"OoXX.XXXX.XXXX+ ",
+"OoXX......XXXX+ ",
+"O++++++++++++++ ",
+"                "};
diff --git a/include/bitmaps/ocr_appstarting b/include/bitmaps/ocr_appstarting
new file mode 100644
index 0000000..2e4793c
--- /dev/null
+++ b/include/bitmaps/ocr_appstarting
@@ -0,0 +1,40 @@
+/* XPM */
+static char *ocr_appstarting[] = {
+" 32 32 3 1 0 0",
+" 	s None c None",
+".	s black c black",
+"X	s white c white",
+".                                ",
+"..          ..........           ",
+".X.         ..XXXXXX..           ",
+".XX.        ..........           ",
+".XXX.        .XXXXXX.            ",
+".XXXX.       .XXXXXX.            ",
+".XXXXX.      .XXX.XX.            ",
+".XXXXXX.     ..X.XX..            ",
+".XXXXXXX.     ..XX..             ",
+".XXXXXXXX.     ..X.              ",
+".XXXXX.....   ..XX..             ",
+".XX.XX.      ..XXXX..            ",
+".X. .XX.     .XX.XXX.            ",
+"..  .XX.     .X.X.XX.            ",
+".    .XX.    ..X.X.X.            ",
+"     .XX.   ..........           ",
+"      .XX.  ..XXXXXX..           ",
+"      .XX.  ..........           ",
+"       ..                        ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 ",
+"                                 "
+};
+
diff --git a/include/bitmaps/ocr_help b/include/bitmaps/ocr_help
new file mode 100644
index 0000000..2fbbabd
--- /dev/null
+++ b/include/bitmaps/ocr_help
@@ -0,0 +1,40 @@
+/* XPM */
+static char *ocr_help[] = {
+" 32 32 3 1 0 0",
+" 	s None  c None",
+".	s black c black",
+"X	s white c white",
+".                               ",
+"..          XXXXXXX             ",
+".X.        X.......X            ",
+".XX.      X...XX....X           ",
+".XXX.    X...X  X....X          ",
+".XXXX.   X...X  X....X          ",
+".XXXXX.  X...X  X....X          ",
+".XXXXXX. X...X  X...X           ",
+".XXXXXXX.XXXXX X...X            ",
+".XXXXXXXX.    X...X             ",
+".XXXXX.....  X...X              ",
+".XX.XX.      X...X              ",
+".X. .XX.     X...X              ",
+"..  .XX.      XXX               ",
+".    .XX.    X...X              ",
+"     .XX.   X.....X             ",
+"      .XX.   X...X              ",
+"      .XX.    XXX               ",
+"       ..                       ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                "
+};
+
diff --git a/include/bitmaps/ocr_no b/include/bitmaps/ocr_no
new file mode 100644
index 0000000..1fe072f
--- /dev/null
+++ b/include/bitmaps/ocr_no
@@ -0,0 +1,38 @@
+/* XPM */
+static char *ocr_no[] = {
+"32 32 3 1 16 16",
+" 	s None c None",
+".	s white c white",
+"X	s black c black",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"             ......             ",
+"           ..XXXXXX..           ",
+"          .XXXXXXXXXX.          ",
+"         .XXXX....XXXX.         ",
+"        .XXX..    ..XXX.        ",
+"       .XXXXX.      .XXX.       ",
+"       .XX.XXX.      .XX.       ",
+"      .XXX..XXX.     .XXX.      ",
+"      .XX.  .XXX.     .XX.      ",
+"      .XX.   .XXX.    .XX.      ",
+"      .XX.    .XXX.   .XX.      ",
+"      .XX.     .XXX.  .XX.      ",
+"      .XXX.     .XXX..XXX.      ",
+"       .XX.      .XXX.XX.       ",
+"       .XXX.      .XXXXX.       ",
+"        .XXX..    ..XXX.        ",
+"         .XXXX....XXXX.         ",
+"          .XXXXXXXXXX.          ",
+"           ..XXXXXX..           ",
+"             ......             ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                ",
+"                                "};
diff --git a/include/combo.h b/include/combo.h
index aa808dc..3b2e8e2 100644
--- a/include/combo.h
+++ b/include/combo.h
@@ -31,11 +31,11 @@
    UINT32  	dwStyle;
    HWND32  	hWndEdit;
    HWND32  	hWndLBox;
-   UINT16  	wState;
-   HFONT16 	hFont;
-   RECT16  	RectCombo;
-   RECT16  	RectEdit;
-   RECT16  	RectButton;
+   UINT32  	wState;
+   HFONT32 	hFont;
+   RECT32  	RectCombo;
+   RECT32  	RectEdit;
+   RECT32  	RectButton;
    INT32   	droppedWidth;		/* last two are not used unless set */
    INT32   	editHeight;		/* explicitly */
 } HEADCOMBO,*LPHEADCOMBO;
diff --git a/include/commctrl.h b/include/commctrl.h
index 38ea959..33404f5 100644
--- a/include/commctrl.h
+++ b/include/commctrl.h
@@ -9,6 +9,21 @@
 
 void WINAPI InitCommonControls(void);
 
+/* common control styles */
+
+#define CCS_TOP             0x00000001L
+#define CCS_NOMOVEY         0x00000002L
+#define CCS_BOTTOM          0x00000003L
+#define CCS_NORESIZE        0x00000004L
+#define CCS_NOPARENTALIGN   0x00000008L
+#define CCS_ADJUSTABLE      0x00000020L
+#define CCS_NODIVIDER       0x00000040L
+#define CCS_VERT            0x00000080L
+#define CCS_LEFT            (CCS_VERT|CCS_TOP)
+#define CCS_RIGHT           (CCS_VERT|CCS_BOTTOM)
+#define CCS_NOMOVEX         (CCS_VERT|CCS_NOMOVEY)
+
+
 /* StatusWindow */
 
 #define STATUSCLASSNAME16     "msctls_statusbar"
@@ -38,7 +53,6 @@
 #define SBT_RTLREADING        0x0400
 #define SBT_OWNERDRAW         0x1000
 
-#define CCS_BOTTOM            0x0003
 #define SBARS_SIZEGRIP        0x0100
 
 /* UpDown */
@@ -117,19 +131,19 @@
 typedef struct _IMAGELIST *HIMAGELIST;
 #endif  /* __WINE__ */
 
-#define CLR_NONE      0xFFFFFFFF
-#define CLR_DEFAULT   0x00000000
-#define CLR_HILIGHT   CLR_DEFAULT
+#define CLR_NONE         0xFFFFFFFF
+#define CLR_DEFAULT      0xFF000000
+#define CLR_HILIGHT      CLR_DEFAULT
 
-#define ILC_MASK       0x0001
-#define ILC_COLOR      0x0000
-#define ILC_COLORDDB   0x00FE
-#define ILC_COLOR4     0x0004
-#define ILC_COLOR8     0x0008
-#define ILC_COLOR16    0x0010
-#define ILC_COLOR24    0x0018
-#define ILC_COLOR32    0x0020
-#define ILC_PALETTE    0x0800
+#define ILC_MASK         0x0001
+#define ILC_COLOR        0x0000
+#define ILC_COLORDDB     0x00FE
+#define ILC_COLOR4       0x0004
+#define ILC_COLOR8       0x0008
+#define ILC_COLOR16      0x0010
+#define ILC_COLOR24      0x0018
+#define ILC_COLOR32      0x0020
+#define ILC_PALETTE      0x0800  /* no longer supported by M$ */
 
 #define ILD_NORMAL       0x0000
 #define ILD_TRANSPARENT  0x0001
@@ -146,6 +160,10 @@
 
 #define INDEXTOOVERLAYMASK(i)  ((i)<<8)
 
+#define ILCF_MOVE        (0x00000000)
+#define ILCF_SWAP        (0x00000001)
+
+
 typedef struct _IMAGEINFO
 {
     HBITMAP32 hbmImage;
@@ -156,20 +174,48 @@
 } IMAGEINFO;
 
 
+typedef struct _IMAGELISTDRAWPARAMS
+{ 
+    DWORD       cbSize; 
+    HIMAGELIST  himl; 
+    INT32       i; 
+    HDC32       hdcDst; 
+    INT32       x; 
+    INT32       y; 
+    INT32       cx; 
+    INT32       cy; 
+    INT32       xBitmap;        // x offest from the upperleft of bitmap 
+    INT32       yBitmap;        // y offset from the upperleft of bitmap 
+    COLORREF    rgbBk; 
+    COLORREF    rgbFg; 
+    UINT32      fStyle; 
+    DWORD       dwRop; 
+} IMAGELISTDRAWPARAMS, *LPIMAGELISTDRAWPARAMS; 
+
+ 
 INT32      WINAPI ImageList_Add(HIMAGELIST,HBITMAP32,HBITMAP32);
 INT32      WINAPI ImageList_AddMasked(HIMAGELIST,HBITMAP32,COLORREF);
-
+BOOL32     WINAPI ImageList_BeginDrag(HIMAGELIST,INT32,INT32,INT32);
+BOOL32     WINAPI ImageList_Copy(HIMAGELIST,INT32,HIMAGELIST,INT32,INT32);
 HIMAGELIST WINAPI ImageList_Create(INT32,INT32,UINT32,INT32,INT32);
 BOOL32     WINAPI ImageList_Destroy(HIMAGELIST);
-
+BOOL32     WINAPI ImageList_DragEnter(HWND32,INT32,INT32);
+BOOL32     WINAPI ImageList_DragLeave(HWND32); 
+BOOL32     WINAPI ImageList_DragMove(INT32,INT32);
+BOOL32     WINAPI ImageList_DragShowNolock (BOOL32 bShow);
 BOOL32     WINAPI ImageList_Draw(HIMAGELIST,INT32,HDC32,INT32,INT32,UINT32);
-
+BOOL32     WINAPI ImageList_DrawEx(HIMAGELIST,INT32,HDC32,INT32,INT32,INT32,
+                                   INT32,COLORREF,COLORREF,UINT32);
+BOOL32     WINAPI ImageList_DrawIndirect(IMAGELISTDRAWPARAMS*); 
+HIMAGELIST WINAPI ImageList_Duplicate(HIMAGELIST);
+BOOL32     WINAPI ImageList_EndDrag (VOID);
 COLORREF   WINAPI ImageList_GetBkColor(HIMAGELIST);
-
+HIMAGELIST WINAPI ImageList_GetDragImage(POINT32*,POINT32*);
+HICON32    WINAPI ImageList_GetIcon(HIMAGELIST,INT32,UINT32);
 BOOL32     WINAPI ImageList_GetIconSize(HIMAGELIST,INT32*,INT32*);
 INT32      WINAPI ImageList_GetImageCount(HIMAGELIST);
 BOOL32     WINAPI ImageList_GetImageInfo(HIMAGELIST,INT32,IMAGEINFO*);
-
+BOOL32     WINAPI ImageList_GetImageRect (HIMAGELIST,INT32,LPRECT32);
 HIMAGELIST WINAPI ImageList_LoadImage32A(HINSTANCE32,LPCSTR,INT32,INT32,
                                          COLORREF,UINT32,UINT32);
 HIMAGELIST WINAPI ImageList_LoadImage32W(HINSTANCE32,LPCWSTR,INT32,INT32,
@@ -177,15 +223,21 @@
 #define    ImageList_LoadImage WINELIB_NAME_AW(ImageList_LoadImage)
 HIMAGELIST WINAPI ImageList_Merge(HIMAGELIST,INT32,HIMAGELIST,INT32,INT32,INT32);
 
+BOOL32     WINAPI ImageList_Remove(HIMAGELIST,INT32);
 BOOL32     WINAPI ImageList_Replace(HIMAGELIST,INT32,HBITMAP32,HBITMAP32);
 INT32      WINAPI ImageList_ReplaceIcon(HIMAGELIST,INT32,HICON32);
 
 COLORREF   WINAPI ImageList_SetBkColor(HIMAGELIST,COLORREF);
-
+BOOL32     WINAPI ImageList_SetDragCursorImage(HIMAGELIST,INT32,INT32,INT32);
+BOOL32     WINAPI ImageList_SetIconSize (HIMAGELIST,INT32,INT32);
+BOOL32     WINAPI ImageList_SetImageCount (HIMAGELIST,INT32);
 BOOL32     WINAPI ImageList_SetOverlayImage(HIMAGELIST,INT32,INT32);
 
 #define ImageList_AddIcon(himl,hicon) ImageList_ReplaceIcon(himl,-1,hicon)
+#define ImageList_ExtractIcon(hi,himl,i) ImageList_GetIcon(himl,i,0)
 #define ImageList_LoadBitmap(hi,lpbmp,cx,cGrow,crMask) \
   ImageList_LoadImage(hi,lpbmp,cx,cGrow,crMask,IMAGE_BITMAP,0)
+#define ImageList_RemoveAll(himl) ImageList_Remove(himl,-1)
+
 
 #endif  /* __WINE_COMMCTRL_H */
diff --git a/include/commdlg.h b/include/commdlg.h
index f33a3ad..e5ca4f6 100644
--- a/include/commdlg.h
+++ b/include/commdlg.h
@@ -174,7 +174,8 @@
 
 #pragma pack(1)
 
-typedef struct {
+typedef struct 
+{
 	DWORD			lStructSize;
 	HWND16			hwndOwner;          /* caller's window handle   */
 	HDC16          	        hDC;                /* printer DC/IC or NULL    */
@@ -195,8 +196,27 @@
 	short			nSizeMin WINE_PACKED;   /* minimum pt size allowed & */
 	short			nSizeMax WINE_PACKED;   /* max pt size allowed if    */
 							/* CF_LIMITSIZE is used      */
-	} CHOOSEFONT;
-typedef CHOOSEFONT *LPCHOOSEFONT;
+} CHOOSEFONT, *LPCHOOSEFONT;
+
+typedef struct
+{
+	UINT32  	lStructSize; 
+	HWND32 		hwndOwner; 
+	HDC32  		hDC; 
+	LPLOGFONT32A    lpLogFont; 
+	INT32		iPointSize; 
+	UINT32		Flags; 
+	COLORREF	rgbColors; 
+	LPARAM		lCustData; 
+	WNDPROC32 	lpfnHook; 
+	LPCSTR		lpTemplateName; 
+	HINSTANCE32	hInstance; 
+	LPSTR		lpszStyle; 
+	UINT16		nFontType; 
+	UINT16	___MISSING_ALIGNMENT__; 
+	INT32   	nSizeMin; 
+	INT32		nSizeMax; 
+} CHOOSEFONT32A, *PCHOOSEFONT32A;
 
 #pragma pack(4)
 
diff --git a/include/compobj.h b/include/compobj.h
index d5f833a..6925b1e 100644
--- a/include/compobj.h
+++ b/include/compobj.h
@@ -24,6 +24,10 @@
 
 OLESTATUS WINAPI WINE_StringFromCLSID(const CLSID *id, LPSTR);
 
+OLESTATUS WINAPI StringFromGUID2(const REFGUID *id, LPOLESTR32 *str, INT32 cmax);
+// #define StringFromGUID2 WINELIB_NAME(StringFromGUID2)
+
+
 #ifdef INITGUID
 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
         const GUID name =\
diff --git a/include/debug.h b/include/debug.h
index cde1891..d601ff4 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -6,97 +6,112 @@
 
 /* Definitions for channels identifiers */
 #define dbch_accel 0
-#define dbch_aspi 1
-#define dbch_atom 2
-#define dbch_bitblt 3
-#define dbch_bitmap 4
-#define dbch_caret 5
-#define dbch_cdaudio 6
-#define dbch_class 7
-#define dbch_clipboard 8
-#define dbch_clipping 9
-#define dbch_combo 10
-#define dbch_comm 11
-#define dbch_commdlg 12
-#define dbch_console 13
-#define dbch_crtdll 14
-#define dbch_cursor 15
-#define dbch_dc 16
-#define dbch_dde 17
-#define dbch_ddeml 18
-#define dbch_ddraw 19
-#define dbch_dialog 20
-#define dbch_dll 21
-#define dbch_dosfs 22
-#define dbch_driver 23
-#define dbch_dsound 24
-#define dbch_edit 25
-#define dbch_event 26
-#define dbch_exec 27
-#define dbch_file 28
-#define dbch_fixup 29
-#define dbch_font 30
-#define dbch_gdi 31
-#define dbch_global 32
-#define dbch_graphics 33
-#define dbch_heap 34
-#define dbch_hook 35
-#define dbch_icon 36
-#define dbch_int 37
-#define dbch_int21 38
-#define dbch_key 39
-#define dbch_keyboard 40
-#define dbch_ldt 41
-#define dbch_listbox 42
-#define dbch_local 43
-#define dbch_mci 44
-#define dbch_mcianim 45
-#define dbch_mciwave 46
-#define dbch_mdi 47
-#define dbch_menu 48
-#define dbch_message 49
-#define dbch_metafile 50
-#define dbch_midi 51
-#define dbch_mmaux 52
-#define dbch_mmio 53
-#define dbch_mmsys 54
-#define dbch_mmtime 55
-#define dbch_module 56
-#define dbch_msg 57
-#define dbch_nonclient 58
-#define dbch_ole 59
-#define dbch_palette 60
-#define dbch_profile 61
-#define dbch_progress 62
-#define dbch_prop 63
-#define dbch_reg 64
-#define dbch_region 65
-#define dbch_relay 66
-#define dbch_resource 67
-#define dbch_scroll 68
-#define dbch_selector 69
-#define dbch_sem 70
-#define dbch_sendmsg 71
-#define dbch_shm 72
-#define dbch_static 73
-#define dbch_stress 74
-#define dbch_string 75
-#define dbch_task 76
-#define dbch_text 77
-#define dbch_thunk 78
-#define dbch_timer 79
-#define dbch_toolhelp 80
-#define dbch_tweak 81
-#define dbch_uitools 82
-#define dbch_updown 83
-#define dbch_ver 84
-#define dbch_virtual 85
-#define dbch_vxd 86
-#define dbch_win 87
-#define dbch_win16drv 88
-#define dbch_win32 89
-#define dbch_winsock 90
-#define dbch_x11 91
+#define dbch_advapi 1
+#define dbch_aspi 2
+#define dbch_atom 3
+#define dbch_bitblt 4
+#define dbch_bitmap 5
+#define dbch_caret 6
+#define dbch_cd 7
+#define dbch_cdaudio 8
+#define dbch_class 9
+#define dbch_clipboard 10
+#define dbch_clipping 11
+#define dbch_combo 12
+#define dbch_comm 13
+#define dbch_commdlg 14
+#define dbch_console 15
+#define dbch_crtdll 16
+#define dbch_cursor 17
+#define dbch_dc 18
+#define dbch_dde 19
+#define dbch_ddeml 20
+#define dbch_ddraw 21
+#define dbch_debug 22
+#define dbch_dialog 23
+#define dbch_dll 24
+#define dbch_dosfs 25
+#define dbch_driver 26
+#define dbch_dsound 27
+#define dbch_edit 28
+#define dbch_event 29
+#define dbch_exec 30
+#define dbch_file 31
+#define dbch_fixup 32
+#define dbch_font 33
+#define dbch_gdi 34
+#define dbch_global 35
+#define dbch_graphics 36
+#define dbch_heap 37
+#define dbch_hook 38
+#define dbch_icon 39
+#define dbch_imagelist 40
+#define dbch_int 41
+#define dbch_int21 42
+#define dbch_int31 43
+#define dbch_key 44
+#define dbch_keyboard 45
+#define dbch_ldt 46
+#define dbch_listbox 47
+#define dbch_local 48
+#define dbch_mci 49
+#define dbch_mcianim 50
+#define dbch_mciwave 51
+#define dbch_mdi 52
+#define dbch_menu 53
+#define dbch_message 54
+#define dbch_metafile 55
+#define dbch_midi 56
+#define dbch_mmaux 57
+#define dbch_mmio 58
+#define dbch_mmsys 59
+#define dbch_mmtime 60
+#define dbch_module 61
+#define dbch_mpr 62
+#define dbch_msg 63
+#define dbch_nonclient 64
+#define dbch_ntdll 65
+#define dbch_ole 66
+#define dbch_palette 67
+#define dbch_print 68
+#define dbch_profile 69
+#define dbch_progress 70
+#define dbch_prop 71
+#define dbch_reg 72
+#define dbch_region 73
+#define dbch_relay 74
+#define dbch_resource 75
+#define dbch_scroll 76
+#define dbch_security 77
+#define dbch_selector 78
+#define dbch_sem 79
+#define dbch_sendmsg 80
+#define dbch_shell 81
+#define dbch_shm 82
+#define dbch_sound 83
+#define dbch_static 84
+#define dbch_stress 85
+#define dbch_string 86
+#define dbch_task 87
+#define dbch_text 88
+#define dbch_thread 89
+#define dbch_thunk 90
+#define dbch_timer 91
+#define dbch_toolhelp 92
+#define dbch_tweak 93
+#define dbch_uitools 94
+#define dbch_updown 95
+#define dbch_ver 96
+#define dbch_virtual 97
+#define dbch_vxd 98
+#define dbch_win 99
+#define dbch_win16drv 100
+#define dbch_win32 101
+#define dbch_wing 102
+#define dbch_winsock 103
+#define dbch_wnet 104
+#define dbch_x11 105
+#define dbch_x11drv 106
 /* Definitions for classes identifiers */
 #define dbcl_fixme 0
 #define dbcl_err 1
diff --git a/include/debugdefs.h b/include/debugdefs.h
index 93f5096..6189cf5 100644
--- a/include/debugdefs.h
+++ b/include/debugdefs.h
@@ -4,7 +4,7 @@
 #include "debugtools.h"
 #endif
 
-#define DEBUG_CHANNEL_COUNT 92
+#define DEBUG_CHANNEL_COUNT 107
 #ifdef DEBUG_RUNTIME
 short debug_msg_enabled[][DEBUG_CLASS_COUNT] = {
 {1, 1, 0, 0},
@@ -99,14 +99,31 @@
 {1, 1, 0, 0},
 {1, 1, 0, 0},
 {1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
+{1, 1, 0, 0},
 };
 const char* debug_ch_name[] = {
 "accel",
+"advapi",
 "aspi",
 "atom",
 "bitblt",
 "bitmap",
 "caret",
+"cd",
 "cdaudio",
 "class",
 "clipboard",
@@ -121,6 +138,7 @@
 "dde",
 "ddeml",
 "ddraw",
+"debug",
 "dialog",
 "dll",
 "dosfs",
@@ -138,8 +156,10 @@
 "heap",
 "hook",
 "icon",
+"imagelist",
 "int",
 "int21",
+"int31",
 "key",
 "keyboard",
 "ldt",
@@ -158,10 +178,13 @@
 "mmsys",
 "mmtime",
 "module",
+"mpr",
 "msg",
 "nonclient",
+"ntdll",
 "ole",
 "palette",
+"print",
 "profile",
 "progress",
 "prop",
@@ -170,15 +193,19 @@
 "relay",
 "resource",
 "scroll",
+"security",
 "selector",
 "sem",
 "sendmsg",
+"shell",
 "shm",
+"sound",
 "static",
 "stress",
 "string",
 "task",
 "text",
+"thread",
 "thunk",
 "timer",
 "toolhelp",
@@ -191,8 +218,11 @@
 "win",
 "win16drv",
 "win32",
+"wing",
 "winsock",
+"wnet",
 "x11",
+"x11drv",
 };
 const char* debug_cl_name[] = {
 "fixme",
diff --git a/include/debugtools.h b/include/debugtools.h
index b133809..8dec4ac 100644
--- a/include/debugtools.h
+++ b/include/debugtools.h
@@ -3,10 +3,10 @@
 #define __WINE_DEBUGTOOLS_H
 
 #include <stdio.h>
+#include "debugstr.h"
 
 #define DEBUG_RUNTIME
-#define stddeb  stdout
-#define stdnimp stdout
+#define stddeb  stderr
 
 #define DEBUG_CLASS_COUNT 4
 
@@ -31,8 +31,7 @@
   (dbg_ch_index(ch) >=0 && dbg_cl_index(cl) >= 0 && \
    debug_msg_enabled[dbg_ch_index(ch)][dbg_cl_index(cl)])
 
-#define DPRINTF(format, args...) \
-  fprintf(stddeb, format, ## args)
+#define DPRINTF(format, args...) fprintf(stddeb, format, ## args)
 
 #define DPRINTF_(cl, ch, format, args...) \
   if(!DEBUGGING(cl, ch)) ; \
@@ -43,6 +42,9 @@
 #define FIXME(ch, fmt, args...) DPRINTF_(fixme, ch, fmt, ## args)
 #define ERR(ch, fmt, args...)   DPRINTF_(err, ch, fmt, ## args)
 
+#define DUMP(format, args...)   DPRINTF(format, ## args)
+#define MSG(format, args...)    fprintf(stderr, format, ## args)
+
 #define FIXME_ON(ch)  DEBUGGING(fixme, ch)
 #define ERR_ON(ch)    DEBUGGING(err, ch)
 #define WARN_ON(ch)   DEBUGGING(warn, ch)
diff --git a/include/heap.h b/include/heap.h
index 82f26e2..2ad3098 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -44,4 +44,26 @@
 /* Use this one only when you own the lock! */
 #define SYSTEM_LOCK_COUNT() (HEAP_SystemLock->RecursionCount)
 
+
+typedef struct
+{
+    LPVOID lpData;
+    DWORD cbData;
+    BYTE cbOverhead;
+    BYTE iRegionIndex;
+    WORD wFlags;
+    union {
+        struct {
+            HANDLE32 hMem;
+            DWORD dwReserved[3];
+        } Block;
+        struct {
+            DWORD dwCommittedSize;
+            DWORD dwUnCommittedSize;
+            LPVOID lpFirstBlock;
+            LPVOID lpLastBlock;
+        } Region;
+    } Foo;
+} PROCESS_HEAP_ENTRY, *LPPROCESS_HEAP_ENTRY;
+
 #endif  /* __WINE_HEAP_H */
diff --git a/include/imagelist.h b/include/imagelist.h
index 891322b..362ce4b 100644
--- a/include/imagelist.h
+++ b/include/imagelist.h
@@ -9,20 +9,24 @@
  
 struct _IMAGELIST
 {
-    HANDLE32  hHeap;
     HBITMAP32 hbmImage;
     HBITMAP32 hbmMask;
+    HBRUSH32  hbrushBlend25;
+    HBRUSH32  hbrushBlend50;
     COLORREF  clrBk;
+    INT32     cInitial;
     INT32     cGrow;
     INT32     cMaxImage;
     INT32     cCurImage;
     INT32     cx;
     INT32     cy;
     UINT32    flags;
-    INT32     nOvlIdx[4];
+    UINT32    uBitsPixel;
+    INT32     nOvlIdx[15];
 };
  
 typedef struct _IMAGELIST *HIMAGELIST;
  
  
 #endif  /* __WINE_IMAGELIST_H */
+
diff --git a/include/metafiledrv.h b/include/metafiledrv.h
index e89d091..b82ac98 100644
--- a/include/metafiledrv.h
+++ b/include/metafiledrv.h
@@ -9,6 +9,7 @@
 #include "gdi.h"
 
 /* FIXME: SDK docs says these should be 1 and 2 */
+/*  DR 980322: most wmf's have 1, so I think 0 and 1 is correct */
 #define METAFILE_MEMORY 0
 #define METAFILE_DISK   1
 
diff --git a/include/mmsystem.h b/include/mmsystem.h
index be29f5f..f293176 100644
--- a/include/mmsystem.h
+++ b/include/mmsystem.h
@@ -481,6 +481,8 @@
 #define MOM_CLOSE       MM_MOM_CLOSE
 #define MOM_DONE        MM_MOM_DONE
 
+/* device ID for MIDI mapper */
+
 #define MIDIMAPPER     (-1)
 #define MIDI_MAPPER    (-1)
 
diff --git a/include/multimedia.h b/include/multimedia.h
new file mode 100644
index 0000000..8c62070
--- /dev/null
+++ b/include/multimedia.h
@@ -0,0 +1,81 @@
+/*****************************************************************************
+ * Copyright 1998, Luiz Otavio L. Zorzella
+ *
+ * File:      multimedia.h
+ * Purpose:   multimedia declarations
+ *
+ *****************************************************************************
+ */
+#ifndef __WINE_MULTIMEDIA_H 
+#define __WINE_MULTIMEDIA_H
+
+#include "mmsystem.h"
+
+#define MAX_MIDIINDRV 	(1)
+/* For now I'm making 16 the maximum number of midi devices one can
+ * have. This should be more than enough for everybody. But as a purist,
+ * I intend to make it unbounded in the future, as soon as I figure
+ * a good way to do so.
+ */
+#define MAX_MIDIOUTDRV 	(16)
+#define MAX_MCIMIDIDRV 	(1)
+
+#if defined (linux)
+#define __HAS_SOUNDCARD_H__
+#include <sys/soundcard.h>
+#elif defined (__FreeBSD__)
+#define __HAS_SOUNDCARD_H__
+#include <machine/soundcard.h>
+#include <sys/errno.h>
+#endif
+
+#if defined (__HAS_SOUNDCARD_H__)
+
+#define MIDI_DEV "/dev/sequencer"
+
+#ifdef SOUND_VERSION
+#define IOCTL(a,b,c)		ioctl(a,b,&c)
+#else
+#define IOCTL(a,b,c)		(c = ioctl(a,b,c) )
+#endif
+
+typedef struct {
+	int		unixdev;
+	int		state;
+	DWORD		bufsize;
+	MIDIOPENDESC	midiDesc;
+	WORD		wFlags;
+	LPMIDIHDR 	lpQueueHdr;
+	DWORD		dwTotalPlayed;
+} LINUX_MIDIIN;
+
+typedef struct {
+	int		unixdev;
+	int		state;
+	DWORD		bufsize;
+	MIDIOPENDESC	midiDesc;
+	WORD		wFlags;
+	LPMIDIHDR 	lpQueueHdr;
+	DWORD		dwTotalPlayed;
+} LINUX_MIDIOUT;
+
+typedef struct {
+	int	nUseCount;          /* Incremented for each shared open */
+	BOOL16	fShareable;         /* TRUE if first open was shareable */
+	WORD	wNotifyDeviceID;    /* MCI device ID with a pending notification */
+	HANDLE16 hCallback;         /* Callback handle for pending notification */
+	HMMIO16	hFile;	            /* mmio file handle open as Element		*/
+	DWORD	dwBeginData;
+	DWORD	dwTotalLen;
+	WORD	wFormat;
+	WORD	nTracks;
+	WORD	nTempo;
+	MCI_OPEN_PARMS16 openParms;
+/* 	MIDIHDR	MidiHdr; */
+	HLOCAL16	hMidiHdr;
+	WORD	dwStatus;
+} LINUX_MCIMIDI;
+
+#endif
+
+#endif /* __WINE_MULTIMEDIA_H */
diff --git a/include/neexe.h b/include/neexe.h
index c5c263f..ff83390 100644
--- a/include/neexe.h
+++ b/include/neexe.h
@@ -31,9 +31,7 @@
     WORD  e_oemid;      /* 24: OEM identifier (for e_oeminfo) */
     WORD  e_oeminfo;    /* 26: OEM information; e_oemid specific */
     WORD  e_res2[10];   /* 28: Reserved words */
-    WORD  e_lfanew;     /* 3c: Offset to extended header */
-    WORD  e_xxx;        /* 3e: Wine internal pad (some programs expect
-                         *     this to be 0) */
+    DWORD e_lfanew;     /* 3c: Offset to extended header */
 } IMAGE_DOS_HEADER,*LPIMAGE_DOS_HEADER;
 
 #define	IMAGE_DOS_SIGNATURE	0x5A4D		/* MZ */
diff --git a/include/peexe.h b/include/peexe.h
index 78adf3b..848ed94 100644
--- a/include/peexe.h
+++ b/include/peexe.h
@@ -59,41 +59,42 @@
 	 * Standard fields.
 	 */
 
-	WORD	Magic;
-	BYTE	MajorLinkerVersion;
-	BYTE	MinorLinkerVersion;
-	DWORD	SizeOfCode;
-	DWORD	SizeOfInitializedData;
-	DWORD	SizeOfUninitializedData;
-	DWORD	AddressOfEntryPoint;
-	DWORD	BaseOfCode;
-	DWORD	BaseOfData;
+	WORD	Magic;				/* 00 */
+	BYTE	MajorLinkerVersion;		/* 02 */
+	BYTE	MinorLinkerVersion;		/* 03 */
+	DWORD	SizeOfCode;			/* 04 */
+	DWORD	SizeOfInitializedData;		/* 08 */
+	DWORD	SizeOfUninitializedData;	/* 0C */
+	DWORD	AddressOfEntryPoint;		/* 10 */
+	DWORD	BaseOfCode;			/* 14 */
+	DWORD	BaseOfData;			/* 18 */
 
 	/*
 	 * NT additional fields.
 	 */
 
-	DWORD	ImageBase;
-	DWORD	SectionAlignment;
-	DWORD	FileAlignment;
-	WORD	MajorOperatingSystemVersion;
-	WORD	MinorOperatingSystemVersion;
-	WORD	MajorImageVersion;
-	WORD	MinorImageVersion;
-	WORD	MajorSubsystemVersion;
-	WORD	MinorSubsystemVersion;
-	DWORD	Reserved1;
-	DWORD	SizeOfImage;
-	DWORD	SizeOfHeaders;
-	DWORD	CheckSum;
-	WORD	Subsystem;
-	WORD	DllCharacteristics;
-	DWORD	SizeOfStackReserve;
-	DWORD	SizeOfStackCommit;
-	DWORD	SizeOfHeapReserve;
-	DWORD	SizeOfHeapCommit;
-	DWORD	LoaderFlags;
-	DWORD	NumberOfRvaAndSizes;
+	DWORD	ImageBase;			/* 1C */
+	DWORD	SectionAlignment;		/* 20 */
+	DWORD	FileAlignment;			/* 24 */
+	WORD	MajorOperatingSystemVersion;	/* 28 */
+	WORD	MinorOperatingSystemVersion;	/* 2A */
+	WORD	MajorImageVersion;		/* 2C */
+	WORD	MinorImageVersion;		/* 2E */
+	WORD	MajorSubsystemVersion;		/* 30 */
+	WORD	MinorSubsystemVersion;		/* 32 */
+	DWORD	Reserved1;			/* 34 */
+	DWORD	SizeOfImage;			/* 38 */
+	DWORD	SizeOfHeaders;			/* 3C */
+	DWORD	CheckSum;			/* 40 */
+	WORD	Subsystem;			/* 44 */
+	WORD	DllCharacteristics;		/* 46 */
+	DWORD	SizeOfStackReserve;		/* 48 */
+	DWORD	SizeOfStackCommit;		/* 4C */
+	DWORD	SizeOfHeapReserve;		/* 50 */
+	DWORD	SizeOfHeapCommit;		/* 54 */
+	DWORD	LoaderFlags;			/* 58 */
+	DWORD	NumberOfRvaAndSizes;		/* 5C */
+						/* 60: */
 	IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
 } IMAGE_OPTIONAL_HEADER,*LPIMAGE_OPTIONAL_HEADER;
 
@@ -140,9 +141,9 @@
 #define	IMAGE_SUBSYSTEM_POSIX_CUI	7
 
 typedef struct _IMAGE_NT_HEADERS {
-	DWORD			Signature;
-	IMAGE_FILE_HEADER	FileHeader;
-	IMAGE_OPTIONAL_HEADER	OptionalHeader;
+	DWORD			Signature;	/* 00: PE\0\0 */
+	IMAGE_FILE_HEADER	FileHeader;	/* 04: Fileheader */
+	IMAGE_OPTIONAL_HEADER	OptionalHeader;	/* 18: Optional Header */
 } IMAGE_NT_HEADERS,*LPIMAGE_NT_HEADERS;
 
 
@@ -161,19 +162,20 @@
 #define	IMAGE_SIZEOF_SHORT_NAME	8
 
 typedef struct _IMAGE_SECTION_HEADER {
-	BYTE	Name[IMAGE_SIZEOF_SHORT_NAME];
+	BYTE	Name[IMAGE_SIZEOF_SHORT_NAME];	/* 00: */
 	union {
-		DWORD	PhysicalAddress;
-		DWORD	VirtualSize;
+		DWORD	PhysicalAddress;	/* 04: */
+		DWORD	VirtualSize;		/* 04: */
 	} Misc;
-	DWORD	VirtualAddress;
-	DWORD	SizeOfRawData;
-	DWORD	PointerToRawData;
-	DWORD	PointerToRelocations;
-	DWORD	PointerToLinenumbers;
-	WORD	NumberOfRelocations;
-	WORD	NumberOfLinenumbers;
-	DWORD	Characteristics;
+	DWORD	VirtualAddress;			/* 08: */
+	DWORD	SizeOfRawData;			/* 0C: */
+	DWORD	PointerToRawData;		/* 10: */
+	DWORD	PointerToRelocations;		/* 14: */
+	DWORD	PointerToLinenumbers;		/* 18: */
+	WORD	NumberOfRelocations;		/* 1C: */
+	WORD	NumberOfLinenumbers;		/* 1E: */
+	DWORD	Characteristics;		/* 20: */
+						/* 24: */
 } IMAGE_SECTION_HEADER,*LPIMAGE_SECTION_HEADER;
 
 #define	IMAGE_SIZEOF_SECTION_HEADER 40
diff --git a/include/version.h b/include/version.h
index 8f5202a..4fcacf6 100644
--- a/include/version.h
+++ b/include/version.h
@@ -1 +1 @@
-#define WINE_RELEASE_INFO "Wine release 980315"
+#define WINE_RELEASE_INFO "Wine release 980329"
diff --git a/include/windows.h b/include/windows.h
index 5944f83..21bf27d 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -817,6 +817,8 @@
 #define IDIGNORE            5
 #define IDYES               6
 #define IDNO                7
+#define IDCLOSE             8
+#define IDHELP              9      
 
 
 typedef struct
@@ -2495,6 +2497,9 @@
 #define IDC_SIZENESW     MAKEINTRESOURCE(32643)
 #define IDC_SIZEWE       MAKEINTRESOURCE(32644)
 #define IDC_SIZENS       MAKEINTRESOURCE(32645)
+#define IDC_NO           MAKEINTRESOURCE(32648)
+#define IDC_APPSTARTING  MAKEINTRESOURCE(32650)
+#define IDC_HELP         MAKEINTRESOURCE(32651)
 
 /* OEM Resource Ordinal Numbers */
 #define OBM_CLOSE           32754
@@ -2559,6 +2564,9 @@
 #define OCR_SIZENS          32645
 #define OCR_SIZEALL         32646
 #define OCR_ICOCUR          32647
+#define OCR_NO              32648
+#define OCR_APPSTARTING     32650
+#define OCR_HELP            32651  /* only defined in wine */
 
 #define OIC_SAMPLE          32512
 #define OIC_HAND            32513
diff --git a/include/winsock.h b/include/winsock.h
index 63a1878..f8bf7ef 100644
--- a/include/winsock.h
+++ b/include/winsock.h
@@ -518,7 +518,9 @@
 #define WSMSG_ASYNC_PROTOBYNUM  0x0020
 #define WSMSG_ASYNC_SERVBYNAME  0x0100
 #define WSMSG_ASYNC_SERVBYPORT  0x0200
-#define WSMSG_ASYNC_WIN32	0x1000
+#define WSMSG_ASYNC_RQMASK	0x0fff
+
+#define WSMSG_WIN32_AOP		0x1000
 #define WSMSG_DEAD_AOP		0x8000
 
 typedef struct __sop	/* WSAAsyncSelect() control struct */
diff --git a/loader/main.c b/loader/main.c
index d2a6423..35ac05d 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -82,6 +82,7 @@
 BOOL32 MAIN_UserInit(void)
 {
     extern BOOL32 WIDGETS_Init(void);
+    extern BOOL32 MULTIMEDIA_Init(void);
 
     int queueSize;
 
@@ -134,6 +135,9 @@
     /* Initialize menus */
     if (!MENU_Init()) return FALSE;
 
+    /* Initialize multimedia */
+    if (!MULTIMEDIA_Init()) return FALSE;
+
     /* Create desktop window */
     if (!WIN_CreateDesktopWindow()) return FALSE;
 
diff --git a/loader/module.c b/loader/module.c
index 7a8d585..6482610 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -115,86 +115,86 @@
     }
 
       /* Dump the module info */
-
-    printf( "Module %04x:\n", hModule );
-    printf( "count=%d flags=%04x heap=%d stack=%d\n",
-            pModule->count, pModule->flags,
-            pModule->heap_size, pModule->stack_size );
-    printf( "cs:ip=%04x:%04x ss:sp=%04x:%04x ds=%04x nb seg=%d modrefs=%d\n",
-           pModule->cs, pModule->ip, pModule->ss, pModule->sp, pModule->dgroup,
-           pModule->seg_count, pModule->modref_count );
-    printf( "os_flags=%d swap_area=%d version=%04x\n",
-            pModule->os_flags, pModule->min_swap_area,
-            pModule->expected_version );
+    DUMP( "---\n" );
+    DUMP( "Module %04x:\n", hModule );
+    DUMP( "count=%d flags=%04x heap=%d stack=%d\n",
+	  pModule->count, pModule->flags,
+	  pModule->heap_size, pModule->stack_size );
+    DUMP( "cs:ip=%04x:%04x ss:sp=%04x:%04x ds=%04x nb seg=%d modrefs=%d\n",
+	  pModule->cs, pModule->ip, pModule->ss, pModule->sp, pModule->dgroup,
+	  pModule->seg_count, pModule->modref_count );
+    DUMP( "os_flags=%d swap_area=%d version=%04x\n",
+	  pModule->os_flags, pModule->min_swap_area,
+	  pModule->expected_version );
     if (pModule->flags & NE_FFLAGS_WIN32)
-        printf( "PE module=%08x\n", pModule->module32 );
+        DUMP( "PE module=%08x\n", pModule->module32 );
 
       /* Dump the file info */
-
-    printf( "Filename: '%s'\n", NE_MODULE_NAME(pModule) );
+    DUMP( "---\n" );
+    DUMP( "Filename: '%s'\n", NE_MODULE_NAME(pModule) );
 
       /* Dump the segment table */
-
-    printf( "\nSegment table:\n" );
+    DUMP( "---\n" );
+    DUMP( "Segment table:\n" );
     pSeg = NE_SEG_TABLE( pModule );
     for (i = 0; i < pModule->seg_count; i++, pSeg++)
-        printf( "%02x: pos=%d size=%d flags=%04x minsize=%d sel=%04x\n",
-                i + 1, pSeg->filepos, pSeg->size, pSeg->flags,
-                pSeg->minsize, pSeg->selector );
+        DUMP( "%02x: pos=%d size=%d flags=%04x minsize=%d sel=%04x\n",
+	      i + 1, pSeg->filepos, pSeg->size, pSeg->flags,
+	      pSeg->minsize, pSeg->selector );
 
       /* Dump the resource table */
-
-    printf( "\nResource table:\n" );
+    DUMP( "---\n" );
+    DUMP( "Resource table:\n" );
     if (pModule->res_table)
     {
         pword = (WORD *)((BYTE *)pModule + pModule->res_table);
-        printf( "Alignment: %d\n", *pword++ );
+        DUMP( "Alignment: %d\n", *pword++ );
         while (*pword)
         {
             struct resource_typeinfo_s *ptr = (struct resource_typeinfo_s *)pword;
             struct resource_nameinfo_s *pname = (struct resource_nameinfo_s *)(ptr + 1);
-            printf( "id=%04x count=%d\n", ptr->type_id, ptr->count );
+            DUMP( "id=%04x count=%d\n", ptr->type_id, ptr->count );
             for (i = 0; i < ptr->count; i++, pname++)
-                printf( "offset=%d len=%d id=%04x\n",
-                       pname->offset, pname->length, pname->id );
+                DUMP( "offset=%d len=%d id=%04x\n",
+		      pname->offset, pname->length, pname->id );
             pword = (WORD *)pname;
         }
     }
-    else printf( "None\n" );
+    else DUMP( "None\n" );
 
       /* Dump the resident name table */
-
-    printf( "\nResident-name table:\n" );
+    DUMP( "---\n" );
+    DUMP( "Resident-name table:\n" );
     pstr = (char *)pModule + pModule->name_table;
     while (*pstr)
     {
-        printf( "%*.*s: %d\n", *pstr, *pstr, pstr + 1,
-                *(WORD *)(pstr + *pstr + 1) );
+        DUMP( "%*.*s: %d\n", *pstr, *pstr, pstr + 1,
+	      *(WORD *)(pstr + *pstr + 1) );
         pstr += *pstr + 1 + sizeof(WORD);
     }
 
       /* Dump the module reference table */
-
-    printf( "\nModule ref table:\n" );
+    DUMP( "---\n" );
+    DUMP( "Module ref table:\n" );
     if (pModule->modref_table)
     {
         pword = (WORD *)((BYTE *)pModule + pModule->modref_table);
         for (i = 0; i < pModule->modref_count; i++, pword++)
         {
-	    printf( "%d: %04x -> '%s'\n", i, *pword,
+	    DUMP( "%d: %04x -> '%s'\n", i, *pword,
 		    MODULE_GetModuleName(*pword));
         }
     }
-    else printf( "None\n" );
+    else DUMP( "None\n" );
 
       /* Dump the entry table */
-
-    printf( "\nEntry table:\n" );
+    DUMP( "---\n" );
+    DUMP( "Entry table:\n" );
     pstr = (char *)pModule + pModule->entry_table;
     ordinal = 1;
     while (*pstr)
     {
-        printf( "Bundle %d-%d: %02x\n", ordinal, ordinal + *pstr - 1, pstr[1]);
+        DUMP( "Bundle %d-%d: %02x\n", ordinal, ordinal + *pstr - 1, pstr[1]);
         if (!pstr[1])
         {
             ordinal += *pstr;
@@ -204,34 +204,34 @@
         {
             struct entry_tab_movable_s *pe = (struct entry_tab_movable_s*)(pstr+2);
             for (i = 0; i < *pstr; i++, pe++)
-                printf( "%d: %02x:%04x (moveable)\n",
-                        ordinal++, pe->seg_number, pe->offset );
+                DUMP( "%d: %02x:%04x (moveable)\n",
+		      ordinal++, pe->seg_number, pe->offset );
             pstr = (char *)pe;
         }
         else  /* fixed */
         {
             struct entry_tab_fixed_s *pe = (struct entry_tab_fixed_s*)(pstr+2);
             for (i = 0; i < *pstr; i++, pe++)
-                printf( "%d: %04x (fixed)\n",
-                        ordinal++, pe->offset[0] + (pe->offset[1] << 8) );
+                DUMP( "%d: %04x (fixed)\n",
+		      ordinal++, pe->offset[0] + (pe->offset[1] << 8) );
             pstr = (char *)pe;
         }
     }
 
     /* Dump the non-resident names table */
-
-    printf( "\nNon-resident names table:\n" );
+    DUMP( "---\n" );
+    DUMP( "Non-resident names table:\n" );
     if (pModule->nrname_handle)
     {
         pstr = (char *)GlobalLock16( pModule->nrname_handle );
         while (*pstr)
         {
-            printf( "%*.*s: %d\n", *pstr, *pstr, pstr + 1,
+            DUMP( "%*.*s: %d\n", *pstr, *pstr, pstr + 1,
                    *(WORD *)(pstr + *pstr + 1) );
             pstr += *pstr + 1 + sizeof(WORD);
         }
     }
-    printf( "\n" );
+    DUMP( "\n" );
 }
 
 
diff --git a/loader/ne_image.c b/loader/ne_image.c
index c47fd4c..3f00e22 100644
--- a/loader/ne_image.c
+++ b/loader/ne_image.c
@@ -289,7 +289,7 @@
 		else
                     *(unsigned char*)sp = (unsigned char)((int)address & 0xFF);
             }
-            while (offset != 0xffff && !additive);
+            while (offset && offset != 0xffff && !additive);
             break;
 
 	  case NE_RADDR_OFFSET16:
@@ -301,7 +301,7 @@
 		*sp = LOWORD(address);
 		if (additive) *sp += offset;
 	    } 
-	    while (offset != 0xffff && !additive);
+	    while (offset && offset != 0xffff && !additive);
 	    break;
 	    
 	  case NE_RADDR_POINTER32:
@@ -314,7 +314,7 @@
 		if (additive) *sp += offset;
 		*(sp+1) = HIWORD(address);
 	    } 
-	    while (offset != 0xffff && !additive);
+	    while (offset && offset != 0xffff && !additive);
 	    break;
 	    
 	  case NE_RADDR_SELECTOR:
@@ -328,7 +328,6 @@
 		if(additive && offset)
         	fprintf(stderr,"Additive selector to %4.4x.Please report\n",offset);
 	    } 
-            /* FIXME: Quicken 5 has a zero offset fixup.  This seems to work */
 	    while (offset && offset != 0xffff && !additive);
 	    break;
 	    
diff --git a/loader/ne_resource.c b/loader/ne_resource.c
index 005f828..abf688c 100644
--- a/loader/ne_resource.c
+++ b/loader/ne_resource.c
@@ -459,8 +459,8 @@
         pTypeInfo = (NE_TYPEINFO *)pNameInfo;
     }
 
-    TRACE(resource, "[%04x]: no intrinsic resource for %04x\n", 
+    TRACE(resource, "[%04x]: no intrinsic resource for %04x, assuming DirectResAlloc()!\n", 
 		 hModule, handle );
-    GlobalFree16( handle ); /* it could have been DirectResAlloc()'ed */
+    GlobalFree16( handle ); 
     return handle;
 }
diff --git a/loader/resource.c b/loader/resource.c
index 3219d78..24d87f2 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -20,9 +20,9 @@
 #include "task.h"
 #include "module.h"
 #include "resource.h"
-#include "debugstr.h"
 #include "debug.h"
 #include "libres.h"
+#include "winerror.h"
 
 extern WORD WINE_LanguageId;
 
@@ -414,6 +414,7 @@
 HACCEL16 WINAPI LoadAccelerators16(HINSTANCE16 instance, SEGPTR lpTableName)
 {
     HRSRC16	hRsrc;
+    HACCEL16    hAccel;
 
     if (HIWORD(lpTableName))
         TRACE(accel, "%04x '%s'\n",
@@ -422,8 +423,12 @@
         TRACE(accel, "%04x %04x\n",
                        instance, LOWORD(lpTableName) );
 
-    if (!(hRsrc = FindResource16( instance, lpTableName, RT_ACCELERATOR )))
+    if (!(hRsrc = FindResource16( instance, lpTableName, RT_ACCELERATOR ))) {
+      WARN(accel, "couldn't find accelerator table resource\n");
       return 0;
+    }
+
+    TRACE(accel, "returning HACCEL 0x%x\n", hRsrc);
     return LoadResource16(instance,hRsrc);
 }
 
@@ -439,18 +444,26 @@
 HACCEL32 WINAPI LoadAccelerators32W(HINSTANCE32 instance,LPCWSTR lpTableName)
 {
     HRSRC32 hRsrc;
+    HACCEL32 hRetval;
 
     if (HIWORD(lpTableName))
-        TRACE(accel, "%04x '%s'\n",
-                      instance, (char *)( lpTableName ) );
+        TRACE(accel, "%p '%s'\n",
+                      (LPVOID)instance, (char *)( lpTableName ) );
     else
-        TRACE(accel, "%04x %04x\n",
-                       instance, LOWORD(lpTableName) );
+        TRACE(accel, "%p 0x%04x\n",
+                       (LPVOID)instance, LOWORD(lpTableName) );
 
     if (!(hRsrc = FindResource32W( instance, lpTableName, 
-		(LPCWSTR)RT_ACCELERATOR )))
-      return 0;
-    return LoadResource32( instance, hRsrc );
+				   (LPCWSTR)RT_ACCELERATOR ))) {
+      WARN(accel, "couldn't find accelerator table resource\n");
+      hRetval = 0;
+    }
+    else {
+      hRetval = LoadResource32( instance, hRsrc );
+    }
+
+    TRACE(accel, "returning HACCEL 0x%x\n", hRsrc);
+    return hRetval;
 }
 
 HACCEL32 WINAPI LoadAccelerators32A(HINSTANCE32 instance,LPCSTR lpTableName)
@@ -471,25 +484,129 @@
  */
 INT32 WINAPI CopyAcceleratorTable32A(HACCEL32 src, LPACCEL32 dst, INT32 entries)
 {
-  fprintf(stderr,"CopyAcceleratorTable32A: not implemented: %d\n", entries);
-  return 0;
+  return CopyAcceleratorTable32W(src, dst, entries);
 }
 
 /**********************************************************************
  *             CopyAcceleratorTable32W   (USER32.59)
+ *
+ * By mortene@pvv.org 980321
  */
-INT32 WINAPI CopyAcceleratorTable32W(HACCEL32 src, LPACCEL32 dst, INT32 entries)
+INT32 WINAPI CopyAcceleratorTable32W(HACCEL32 src, LPACCEL32 dst,
+				     INT32 entries)
 {
-  fprintf(stderr,"CopyAcceleratorTable32W: not implemented: %d\n", entries);
-  return 0;
+  int i;
+  LPACCEL32 accel = (LPACCEL32)src;
+  BOOL32 done = FALSE;
+
+  /* Do parameter checking to avoid the explosions and the screaming
+     as far as possible. */
+  if((dst && (entries < 1)) || (src == (HACCEL32)NULL)) {
+    WARN(accel, "Application sent invalid parameters (%p %p %d).\n",
+	 (LPVOID)src, (LPVOID)dst, entries);
+    return 0;
+  }
+
+
+  i=0;
+  while(!done) {
+    /* Spit out some debugging information. */
+    TRACE(accel, "accel %d: type 0x%02x, event '%c', IDval 0x%04x.\n",
+	  i, accel[i].fVirt, accel[i].key, accel[i].cmd);
+
+    /* Copy data to the destination structure array (if dst == NULL,
+       we're just supposed to count the number of entries). */
+    if(dst) {
+      memcpy(&dst[i], &accel[i], sizeof(ACCEL32));
+
+      /* Check if we've reached the end of the application supplied
+         accelerator table. */
+      if(i+1 == entries) {
+	/* Turn off the high order bit, just in case. */
+	dst[i].fVirt &= 0x7f;
+	done = TRUE;
+      }
+    }
+
+    /* The highest order bit seems to mark the end of the accelerator
+       resource table. (?) */
+    if((accel[i].fVirt & 0x80) != 0) done = TRUE;
+
+    i++;
+  }
+
+  return i;
+}
+
+/*********************************************************************
+ *                    CreateAcceleratorTable   (USER32.64)
+ *
+ * By mortene@pvv.org 980321
+ */
+HACCEL32 WINAPI CreateAcceleratorTable32A(LPACCEL32 lpaccel, INT32 cEntries)
+{
+  HACCEL32 hAccel;
+
+  /* Do parameter checking just in case someone's trying to be
+     funny. */
+  if(cEntries < 1) {
+    WARN(accel, "Application sent invalid parameters (%p %d).\n",
+	 lpaccel, cEntries);
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return (HACCEL32)NULL;
+  }
+  FIXME(accel, "should check that the accelerator descriptions are valid,"
+	" return NULL and SetLastError() if not.\n");
+
+
+  /* Allocate memory and copy the table. */
+  hAccel = (HACCEL32)HeapAlloc(GetProcessHeap(), 0,
+			       cEntries * sizeof(ACCEL32));
+  TRACE(accel, "handle %p\n", (LPVOID)hAccel);
+  if(!hAccel) {
+    WARN(accel, "Out of memory.\n");
+    SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+    return (HACCEL32)NULL;
+  }
+  memcpy((LPACCEL32)hAccel, lpaccel, cEntries * sizeof(ACCEL32));
+
+  /* Set the end-of-table terminator. */
+  ((LPACCEL32)hAccel)[cEntries-1].fVirt |= 0x80;
+
+  TRACE(accel, "Allocated accelerator handle %x\n", hAccel);
+  return hAccel;
 }
 
 /**********************************************************************
  *             DestroyAcceleratorTable   (USER32.130)
+ *
+ * By mortene@pvv.org 980321
  */
 BOOL32 WINAPI DestroyAcceleratorTable( HACCEL32 handle )
 {
-  fprintf(stderr,"DestroyAcceleratorTable: not implemented\n");
+  FIXME(accel, "stub (handle 0x%x)\n", handle);
+
+
+  /* Weird.. I thought this should work. According to the API
+     specification, DestroyAcceleratorTable() should only be called on
+     HACCEL32's made by CreateAcceleratorTable(), but Microsoft Visual
+     Studio 97 calls this function with a series of different handle
+     values without ever calling CreateAcceleratorTable(). Something
+     is very fishy in Denmark... */
+  /* Update: looks like the calls to this function matches the calls
+     to LoadAccelerators() in M$ Visual Studio, except that the handle
+     values are off by some variable size from the HACCEL's returned
+     from LoadAccelerators(). WTH? */
+  
+  /* Parameter checking to avoid any embarassing situations. */
+/*   if(!handle) { */
+/*     WARN(accel, "Application sent NULL ptr.\n"); */
+/*     SetLastError(ERROR_INVALID_PARAMETER); */
+/*     return FALSE; */
+/*   } */
+  
+/*   HeapFree(GetProcessHeap(), 0, (LPACCEL32)handle); */
+
   return TRUE;
 }
   
@@ -586,9 +703,8 @@
 	fprintf(stderr,"LoadString // and try to obtain string '%s'\n", p + 1);
 #endif
     }
-#if 0
-    TRACE(resource,"'%s' copied !\n", buffer);
-#endif
+
+    TRACE(resource,"'%s' copied !\n", (char *)buffer);
     return i;
 }
 
diff --git a/loader/signal.c b/loader/signal.c
index ef850ad..931a461 100644
--- a/loader/signal.c
+++ b/loader/signal.c
@@ -74,11 +74,10 @@
 }
 #endif /* linux && __i386__ */
 
-
 /* Signal stack */
 
 static char SIGNAL_Stack[16384];
-
+static sigset_t async_signal_set;
 
 /**********************************************************************
  *              SIGNAL_child
@@ -155,6 +154,8 @@
 {
     extern void SYNC_SetupSignals(void);
 
+    sigemptyset(&async_signal_set);
+
 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__svr4__) || defined(_SCO_DS)
     struct sigaltstack ss;
     ss.ss_sp    = SIGNAL_Stack;
@@ -169,11 +170,19 @@
     
     SIGNAL_SetHandler( SIGCHLD, (void (*)())SIGNAL_child, 1);
 #ifdef CONFIG_IPC
+    sigaddset(&async_signal_set, SIGUSR2);
     SIGNAL_SetHandler( SIGUSR2, (void (*)())stop_wait, 1); 	/* For IPC */
 #endif
 #ifdef SIGIO
+    sigaddset(&async_signal_set, SIGIO);
     SIGNAL_SetHandler( SIGIO,   (void (*)())WINSOCK_sigio, 0); 
 #endif
+
+    sigaddset(&async_signal_set, SIGALRM);
+
+    /* ignore SIGPIPE so that WINSOCK can get a EPIPE error instead  */
+    signal (SIGPIPE, SIG_IGN);
+
     SYNC_SetupSignals();
     return TRUE;
 }
@@ -184,13 +193,6 @@
  */
 void SIGNAL_MaskAsyncEvents( BOOL32 flag )
 {
-  sigset_t 	set;
-  sigemptyset(&set);
-#ifdef SIGIO
-  sigaddset(&set, SIGIO);
-#endif
-#ifdef CONFIG_IPC
-  sigaddset(&set, SIGUSR2);
-#endif
-  sigprocmask( (flag) ? SIG_BLOCK : SIG_UNBLOCK , &set, NULL);
+  sigprocmask( (flag) ? SIG_BLOCK : SIG_UNBLOCK , &async_signal_set, NULL);
 }
+
diff --git a/loader/task.c b/loader/task.c
index bda4626..31218b6 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -486,7 +486,7 @@
     memset( pTask->pdb.fileHandles, 0xff, sizeof(pTask->pdb.fileHandles) );
     pTask->pdb.environment    = hEnvironment;
     pTask->pdb.nbFiles        = 20;
-    lstrcpyn32A( pTask->pdb.cmdLine, cmdLine, 127 );
+    lstrcpyn32A( pTask->pdb.cmdLine, cmdLine, sizeof(pTask->pdb.cmdLine) );
 
       /* Get the compatibility flags */
 
@@ -839,7 +839,7 @@
          * es:bx  pointer to command-line inside PSP
          */
         EAX_reg(context) = 1;
-        EBX_reg(context) = 0x81;
+        EBX_reg(context) = pTask->pdb.cmdLine[0] ? 0x81 : 0x80;
         ECX_reg(context) = pModule->stack_size;
         EDX_reg(context) = pTask->nCmdShow;
         ESI_reg(context) = (DWORD)pTask->hPrevInstance;
@@ -1005,7 +1005,8 @@
 {
     BYTE *thunk,*lfunc;
     SEGPTR thunkaddr;
-    
+
+    if (!hInstance) return 0;
     if (__winelib) return func; /* func can be called directly in Winelib */
     thunkaddr = TASK_AllocThunk( hCurrentTask );
     if (!thunkaddr) return (FARPROC16)0;
@@ -1358,8 +1359,8 @@
 WORD WINAPI SetSigHandler( FARPROC16 newhandler, FARPROC16* oldhandler,
                            UINT16 *oldmode, UINT16 newmode, UINT16 flag )
 {
-    fprintf(stdnimp,"SetSigHandler(%p,%p,%p,%d,%d), unimplemented.\n",
-            newhandler,oldhandler,oldmode,newmode,flag );
+    FIXME(task,"(%p,%p,%p,%d,%d), unimplemented.\n",
+	  newhandler,oldhandler,oldmode,newmode,flag );
 
     if (flag != 1) return 0;
     if (!newmode) newhandler = NULL;  /* Default handler */
diff --git a/memory/atom.c b/memory/atom.c
index dc82162..6da9694 100644
--- a/memory/atom.c
+++ b/memory/atom.c
@@ -42,9 +42,18 @@
 
 /***********************************************************************
  *           ATOM_InitTable
+ *
+ * NOTES
+ *	Should this validate the value of entries to be 0 < x < 0x3fff?
+ *
+ * RETURNS
+ *	Handle: Success
+ *	0: Failure
  */
-static HANDLE16 ATOM_InitTable( WORD selector, WORD entries )
-{
+static HANDLE16 ATOM_InitTable(
+                WORD selector, /* [in] Segment */
+                WORD entries   /* [in] Size of atom table */
+) {
     int i;
     HANDLE16 handle;
     ATOMTABLE *table;
@@ -81,9 +90,15 @@
  *
  * Return a pointer to the atom table of a given segment, creating
  * it if necessary.
+ *
+ * RETURNS
+ *	Pointer to table: Success
+ *	NULL: Failure
  */
-static ATOMTABLE * ATOM_GetTable( WORD selector, BOOL32 create )
-{
+static ATOMTABLE *ATOM_GetTable(
+                  WORD selector, /* [in] Segment */
+                  BOOL32 create  /* [in] Create */
+) {
     INSTANCEDATA *ptr = (INSTANCEDATA *)PTR_SEG_OFF_TO_LIN( selector, 0 );
     if (!ptr->atomtable)
     {
@@ -101,17 +116,24 @@
  *
  * Make an ATOMENTRY pointer from a handle (obtained from GetAtomHandle()).
  */
-static ATOMENTRY * ATOM_MakePtr( WORD selector, HANDLE16 handle )
-{
+static ATOMENTRY *ATOM_MakePtr(
+                  WORD selector,  /* [in] Segment */
+                  HANDLE16 handle /* [in] Handle */
+) {
     return (ATOMENTRY *)PTR_SEG_OFF_TO_LIN( selector, handle );
 }
 
 
 /***********************************************************************
  *           ATOM_Hash
+ * RETURNS
+ *	The hash value for the input string
  */
-static WORD ATOM_Hash( WORD entries, LPCSTR str, WORD len )
-{
+static WORD ATOM_Hash(
+            WORD entries, /* [in] Total number of entries */
+            LPCSTR str,   /* [in] Pointer to string to hash */
+            WORD len      /* [in] Length of string */
+) {
     WORD i, hash = 0;
 
     for (i = 0; i < len; i++) hash ^= toupper(str[i]) + i;
@@ -121,9 +143,15 @@
 
 /***********************************************************************
  *           ATOM_AddAtom
+ *
+ * RETURNS
+ *	Atom: Success
+ *	0: Failure
  */
-static ATOM ATOM_AddAtom( WORD selector, LPCSTR str )
-{
+static ATOM ATOM_AddAtom(
+            WORD selector, /* [in] Segment */
+            LPCSTR str     /* [in] Pointer to the string to add */
+) {
     WORD hash;
     HANDLE16 entry;
     ATOMENTRY * entryPtr;
@@ -163,9 +191,14 @@
 
 /***********************************************************************
  *           ATOM_DeleteAtom
+ * RETURNS
+ *	0: Success
+ *	Atom: Failure
  */
-static ATOM ATOM_DeleteAtom( WORD selector, ATOM atom )
-{
+static ATOM ATOM_DeleteAtom(
+            WORD selector, /* [in] Segment */
+            ATOM atom      /* [in] Atom to delete */
+) {
     ATOMENTRY * entryPtr;
     ATOMTABLE * table;
     HANDLE16 entry, *prevEntry;
@@ -199,9 +232,14 @@
 
 /***********************************************************************
  *           ATOM_FindAtom
+ * RETURNS
+ *	Atom: Success
+ *	0: Failure
  */
-static ATOM ATOM_FindAtom( WORD selector, LPCSTR str )
-{
+static ATOM ATOM_FindAtom(
+            WORD selector, /* [in] Segment */
+            LPCSTR str     /* [in] Pointer to string to find */
+) {
     ATOMTABLE * table;
     WORD hash;
     HANDLE16 entry;
@@ -226,10 +264,16 @@
 
 /***********************************************************************
  *           ATOM_GetAtomName
+ * RETURNS
+ *	Length of string copied to buffer: Success
+ *	0: Failure
  */
-static UINT32 ATOM_GetAtomName( WORD selector, ATOM atom,
-                                LPSTR buffer, INT32 count )
-{
+static UINT32 ATOM_GetAtomName(
+              WORD selector, /* [in]  Segment */
+              ATOM atom,     /* [in]  Atom identifier */
+              LPSTR buffer,  /* [out] Pointer to buffer for atom string */
+              INT32 count    /* [in]  Size of buffer */
+) {
     ATOMTABLE * table;
     ATOMENTRY * entryPtr;
     HANDLE16 entry;
@@ -302,15 +346,23 @@
 
 /***********************************************************************
  *           AddAtom32A   (KERNEL32.0)
+ * Adds a string to the atom table and returns the atom identifying the
+ * string.
+ *
+ * RETURNS
+ *	Atom: Success
+ *	0: Failure
  */
-ATOM WINAPI AddAtom32A( LPCSTR str )
-{
+ATOM WINAPI AddAtom32A(
+            LPCSTR str /* [in] Pointer to string to add */
+) {
     return GlobalAddAtom32A( str );  /* FIXME */
 }
 
 
 /***********************************************************************
  *           AddAtom32W   (KERNEL32.1)
+ * See AddAtom32A
  */
 ATOM WINAPI AddAtom32W( LPCWSTR str )
 {
@@ -329,9 +381,16 @@
 
 /***********************************************************************
  *           DeleteAtom32   (KERNEL32.69)
+ * Decrements the reference count of a string atom.  If count becomes
+ * zero, the string associated with the atom is removed from the table.
+ *
+ * RETURNS
+ *	0: Success
+ *	Atom: Failure
  */
-ATOM WINAPI DeleteAtom32( ATOM atom )
-{
+ATOM WINAPI DeleteAtom32(
+            ATOM atom /* [in] Atom to delete */
+) {
     return GlobalDeleteAtom( atom );  /* FIXME */
 }
 
@@ -348,15 +407,23 @@
 
 /***********************************************************************
  *           FindAtom32A   (KERNEL32.117)
+ * Searches the local atom table for the string and returns the atom
+ * associated with that string.
+ *
+ * RETURNS
+ *	Atom: Success
+ *	0: Failure
  */
-ATOM WINAPI FindAtom32A( LPCSTR str )
-{
+ATOM WINAPI FindAtom32A(
+            LPCSTR str /* [in] Pointer to string to find */
+) {
     return GlobalFindAtom32A( str );  /* FIXME */
 }
 
 
 /***********************************************************************
  *           FindAtom32W   (KERNEL32.118)
+ * See FindAtom32A
  */
 ATOM WINAPI FindAtom32W( LPCWSTR str )
 {
@@ -375,15 +442,24 @@
 
 /***********************************************************************
  *           GetAtomName32A   (KERNEL32.149)
+ * Retrieves a copy of the string associated with the atom.
+ *
+ * RETURNS
+ *	Length of string: Success
+ *	0: Failure
  */
-UINT32 WINAPI GetAtomName32A( ATOM atom, LPSTR buffer, INT32 count )
-{
+UINT32 WINAPI GetAtomName32A(
+              ATOM atom,    /* [in]  Atom */
+              LPSTR buffer, /* [out] Pointer to string for atom string */
+              INT32 count   /* [in]  Size of buffer */
+) {
     return GlobalGetAtomName32A( atom, buffer, count );  /* FIXME */
 }
 
 
 /***********************************************************************
  *           GetAtomName32W   (KERNEL32.150)
+ * See GetAtomName32A
  */
 UINT32 WINAPI GetAtomName32W( ATOM atom, LPWSTR buffer, INT32 count )
 {
@@ -407,9 +483,16 @@
 
 /***********************************************************************
  *           GlobalAddAtom32A   (KERNEL32.313)
+ * Adds a character string to the global atom table and returns a unique
+ * value identifying the string.
+ *
+ * RETURNS
+ *	Atom: Success
+ *	0: Failure
  */
-ATOM WINAPI GlobalAddAtom32A( LPCSTR str )
-{
+ATOM WINAPI GlobalAddAtom32A(
+            LPCSTR str /* [in] Pointer to string to add */
+) {
     if (!HIWORD(str)) return (ATOM)LOWORD(str);  /* Integer atom */
     return ATOM_AddAtom( USER_HeapSel, str );
 }
@@ -417,6 +500,7 @@
 
 /***********************************************************************
  *           GlobalAddAtom32W   (KERNEL32.314)
+ * See GlobalAddAtom32A
  */
 ATOM WINAPI GlobalAddAtom32W( LPCWSTR str )
 {
@@ -429,9 +513,16 @@
 
 /***********************************************************************
  *           GlobalDeleteAtom   (USER.269) (KERNEL32.317)
+ * Decrements the reference count of a string atom.  If the count is
+ * zero, the string associated with the atom is removed from the table.
+ *
+ * RETURNS
+ *	0: Success
+ *	Atom: Failure
  */
-ATOM WINAPI GlobalDeleteAtom( ATOM atom )
-{
+ATOM WINAPI GlobalDeleteAtom(
+            ATOM atom /* [in] Atom to delete */
+) {
 #ifdef CONFIG_IPC
     return DDE_GlobalDeleteAtom( atom );
 #else
@@ -456,9 +547,16 @@
 
 /***********************************************************************
  *           GlobalFindAtom32A   (KERNEL32.318)
+ * Searches the atom table for the string and returns the atom
+ * associated with it.
+ *
+ * RETURNS
+ *	Atom: Success
+ *	0: Failure
  */
-ATOM WINAPI GlobalFindAtom32A( LPCSTR str )
-{
+ATOM WINAPI GlobalFindAtom32A(
+            LPCSTR str /* [in] Pointer to string to search for */
+) {
     if (!HIWORD(str)) return (ATOM)LOWORD(str);  /* Integer atom */
     return ATOM_FindAtom( USER_HeapSel, str );
 }
@@ -466,6 +564,7 @@
 
 /***********************************************************************
  *           GlobalFindAtom32W   (KERNEL32.319)
+ * See GlobalFindAtom32A
  */
 ATOM WINAPI GlobalFindAtom32W( LPCWSTR str )
 {
@@ -491,14 +590,24 @@
 
 /***********************************************************************
  *           GlobalGetAtomName32A   (KERNEL32.323)
+ * Retrieves a copy of the string associated with an atom.
+ *
+ * RETURNS
+ *	Length of string in characters: Success
+ *	0: Failure
  */
-UINT32 WINAPI GlobalGetAtomName32A( ATOM atom, LPSTR buffer, INT32 count )
-{
+UINT32 WINAPI GlobalGetAtomName32A(
+              ATOM atom,    /* [in]  Atom identifier */
+              LPSTR buffer, /* [out] Pointer to buffer for atom string */
+              INT32 count   /* [in]  Size of buffer */
+) {
     return ATOM_GetAtomName( USER_HeapSel, atom, buffer, count );
 }
 
+
 /***********************************************************************
  *           GlobalGetAtomName32W   (KERNEL32.324)
+ * See GlobalGetAtomName32A
  */
 UINT32 WINAPI GlobalGetAtomName32W( ATOM atom, LPWSTR buffer, INT32 count )
 {
diff --git a/memory/global.c b/memory/global.c
index 960e3da..54a4b46 100644
--- a/memory/global.c
+++ b/memory/global.c
@@ -81,11 +81,11 @@
     for (i = globalArenaSize-1 ; i>=0 ; i--) {
 	if (pGlobalArena[i].size!=0 && (pGlobalArena[i].handle & 0x8000)){
 	    printed=1;
-	    printf("0x%08x, ",pGlobalArena[i].handle);
+	    DUMP("0x%08x, ",pGlobalArena[i].handle);
 	}
     }
     if (printed)
-	printf("\n");
+	DUMP("\n");
 }
 
 
@@ -271,9 +271,14 @@
 
 /***********************************************************************
  *           GlobalAlloc16   (KERNEL.15)
+ * RETURNS
+ *	Handle: Success
+ *	NULL: Failure
  */
-HGLOBAL16 WINAPI GlobalAlloc16( UINT16 flags, DWORD size )
-{
+HGLOBAL16 WINAPI GlobalAlloc16(
+                 UINT16 flags, /* [in] Object allocation attributes */
+                 DWORD size    /* [in] Number of bytes to allocate */
+) {
     HANDLE16 owner = GetCurrentPDB();
 
     if (flags & GMEM_DDESHARE)
@@ -284,9 +289,15 @@
 
 /***********************************************************************
  *           GlobalReAlloc16   (KERNEL.16)
+ * RETURNS
+ *	Handle: Success
+ *	NULL: Failure
  */
-HGLOBAL16 WINAPI GlobalReAlloc16( HGLOBAL16 handle, DWORD size, UINT16 flags )
-{
+HGLOBAL16 WINAPI GlobalReAlloc16(
+                 HGLOBAL16 handle, /* [in] Handle of global memory object */
+                 DWORD size,       /* [in] New size of block */
+                 UINT16 flags      /* [in] How to reallocate object */
+) {
     WORD selcount;
     DWORD oldsize;
     void *ptr;
@@ -300,14 +311,13 @@
 #ifdef CONFIG_IPC
     if (flags & GMEM_DDESHARE || is_dde_handle(handle))
     {
-	fprintf(stdnimp,
-               "GlobalReAlloc16: shared memory reallocating unimplemented\n"); 
+	FIXME(global, "shared memory reallocating unimplemented\n"); 
 	return 0;
     }
 #endif  /* CONFIG_IPC */
 
     if (!VALID_HANDLE(handle)) {
-    	fprintf(stderr," Invalid handle 0x%04x passed to GlobalReAlloc16!\n",handle);
+    	WARN(global, "Invalid handle 0x%04x!\n", handle);
     	return 0;
     }
     pArena = GET_ARENA_PTR( handle );
@@ -398,9 +408,13 @@
 
 /***********************************************************************
  *           GlobalFree16   (KERNEL.17)
+ * RETURNS
+ *	NULL: Success
+ *	Handle: Failure
  */
-HGLOBAL16 WINAPI GlobalFree16( HGLOBAL16 handle )
-{
+HGLOBAL16 WINAPI GlobalFree16(
+                 HGLOBAL16 handle /* [in] Handle of global memory object */
+) {
     void *ptr;
 
     if (!VALID_HANDLE(handle)) {
@@ -454,9 +468,14 @@
  *           GlobalLock16   (KERNEL.18)
  *
  * This is the GlobalLock16() function used by 32-bit code.
+ * 
+ * RETURNS
+ *	Pointer to first byte of memory block
+ *	NULL: Failure
  */
-LPVOID WINAPI GlobalLock16( HGLOBAL16 handle )
-{
+LPVOID WINAPI GlobalLock16(
+              HGLOBAL16 handle /* [in] Handle of global memory object */
+) {
     if (!handle) return 0;
     if (!VALID_HANDLE(handle))
 	return (LPVOID)0;
@@ -470,9 +489,16 @@
 
 /***********************************************************************
  *           GlobalUnlock16   (KERNEL.19)
+ * NOTES
+ *	Should the return values be cast to booleans?
+ *
+ * RETURNS
+ *	TRUE: Object is still locked
+ *	FALSE: Object is unlocked
  */
-BOOL16 WINAPI GlobalUnlock16( HGLOBAL16 handle )
-{
+BOOL16 WINAPI GlobalUnlock16(
+              HGLOBAL16 handle /* [in] Handle of global memory object */
+) {
     GLOBALARENA *pArena = GET_ARENA_PTR(handle);
     if (!VALID_HANDLE(handle)) {
 	fprintf(stderr,"Invalid handle 0x%04x passed to GlobalUnlock16!\n",handle);
@@ -486,9 +512,13 @@
 
 /***********************************************************************
  *           GlobalSize16   (KERNEL.20)
+ * RETURNS
+ *	Size in bytes of object
+ *	0: Failure
  */
-DWORD WINAPI GlobalSize16( HGLOBAL16 handle )
-{
+DWORD WINAPI GlobalSize16(
+             HGLOBAL16 handle /* [in] Handle of global memory object */
+) {
     TRACE(global, "%04x\n", handle );
     if (!handle) return 0;
     if (!VALID_HANDLE(handle))
@@ -499,9 +529,16 @@
 
 /***********************************************************************
  *           GlobalHandle16   (KERNEL.21)
+ * NOTES
+ *	Why is GlobalHandleToSel used here with the sel as input?
+ *
+ * RETURNS
+ *	Handle: Success
+ *	NULL: Failure
  */
-DWORD WINAPI GlobalHandle16( WORD sel )
-{
+DWORD WINAPI GlobalHandle16(
+             WORD sel /* [in] Address of global memory block */
+) {
     TRACE(global, "%04x\n", sel );
     if (!VALID_HANDLE(sel)) {
 	fprintf(stderr,"Invalid handle 0x%04x passed to GlobalHandle16!\n",sel);
@@ -523,11 +560,20 @@
     return 0;
 }
 
+
 /***********************************************************************
  *           GlobalFlags16   (KERNEL.22)
+ * NOTES
+ *	Should this return GMEM_INVALID_HANDLE instead of 0 on invalid
+ *	handle?
+ *
+ * RETURNS
+ *	Value specifying flags and lock count
+ *	GMEM_INVALID_HANDLE: Invalid handle
  */
-UINT16 WINAPI GlobalFlags16( HGLOBAL16 handle )
-{
+UINT16 WINAPI GlobalFlags16(
+              HGLOBAL16 handle /* [in] Handle of global memory object */
+) {
     GLOBALARENA *pArena;
 
     TRACE(global, "%04x\n", handle );
@@ -662,12 +708,15 @@
 
 /***********************************************************************
  *           GlobalDOSAlloc   (KERNEL.184)
+ * RETURNS
+ *	Address (HW=Paragraph segment; LW=Selector)
  */
-DWORD WINAPI GlobalDOSAlloc(DWORD size)
-{
+DWORD WINAPI GlobalDOSAlloc(
+             DWORD size /* [in] Number of bytes to be allocated */
+) {
    UINT16    uParagraph;
    LPVOID    lpBlock = DOSMEM_GetBlock( size, &uParagraph );
-   
+
    if( lpBlock )
    {
        HMODULE16 hModule = GetModuleHandle16("KERNEL");
@@ -680,11 +729,16 @@
    return 0;
 }
 
+
 /***********************************************************************
  *           GlobalDOSFree      (KERNEL.185)
+ * RETURNS
+ *	NULL: Success
+ *	sel: Failure
  */
-WORD WINAPI GlobalDOSFree(WORD sel)
-{
+WORD WINAPI GlobalDOSFree(
+            WORD sel /* [in] Selector */
+) {
    DWORD   block = GetSelectorBase(sel);
 
    if( block && block < 0x100000 ) 
@@ -697,6 +751,7 @@
    return sel;
 }
 
+
 /***********************************************************************
  *           GlobalPageLock   (KERNEL.191)
  */
@@ -966,9 +1021,14 @@
 
 /***********************************************************************
  *           GlobalAlloc32   (KERNEL32.315)
+ * RETURNS
+ *	Handle: Success
+ *	NULL: Failure
  */
-HGLOBAL32 WINAPI GlobalAlloc32(UINT32 flags, DWORD size)
-{
+HGLOBAL32 WINAPI GlobalAlloc32(
+                 UINT32 flags, /* [in] Object allocation attributes */
+                 DWORD size    /* [in] Number of bytes to allocate */
+) {
    PGLOBAL32_INTERN     pintern;
    DWORD		hpflags;
    LPVOID               palloc;
@@ -1009,9 +1069,13 @@
 
 /***********************************************************************
  *           GlobalLock32   (KERNEL32.326)
+ * RETURNS
+ *	Pointer to first byte of block
+ *	NULL: Failure
  */
-LPVOID WINAPI GlobalLock32(HGLOBAL32 hmem)
-{
+LPVOID WINAPI GlobalLock32(
+              HGLOBAL32 hmem /* [in] Handle of global memory object */
+) {
    PGLOBAL32_INTERN pintern;
    LPVOID           palloc;
 
@@ -1039,9 +1103,13 @@
 
 /***********************************************************************
  *           GlobalUnlock32   (KERNEL32.332)
+ * RETURNS
+ *	TRUE: Object is still locked
+ *	FALSE: Object is unlocked
  */
-BOOL32 WINAPI GlobalUnlock32(HGLOBAL32 hmem)
-{
+BOOL32 WINAPI GlobalUnlock32(
+              HGLOBAL32 hmem /* [in] Handle of global memory object */
+) {
    PGLOBAL32_INTERN       pintern;
    BOOL32                 locked;
 
@@ -1070,9 +1138,19 @@
 
 /***********************************************************************
  *           GlobalHandle32   (KERNEL32.325)
+ * Returns the handle associated with the specified pointer.
+ *
+ * NOTES
+ *	Since there in only one goto, can it be removed and the return
+ *	be put 'inline'?
+ *
+ * RETURNS
+ *	Handle: Success
+ *	NULL: Failure
  */
-HGLOBAL32 WINAPI GlobalHandle32(LPCVOID pmem)
-{
+HGLOBAL32 WINAPI GlobalHandle32(
+                 LPCVOID pmem /* [in] Pointer to global memory block */
+) {
     HGLOBAL32 handle;
 
     if (!HEAP_IsInsideHeap( GetProcessHeap(), 0, pmem )) goto error;
@@ -1094,9 +1172,15 @@
 
 /***********************************************************************
  *           GlobalReAlloc32   (KERNEL32.328)
+ * RETURNS
+ *	Handle: Success
+ *	NULL: Failure
  */
-HGLOBAL32 WINAPI GlobalReAlloc32(HGLOBAL32 hmem, DWORD size, UINT32 flags)
-{
+HGLOBAL32 WINAPI GlobalReAlloc32(
+                 HGLOBAL32 hmem, /* [in] Handle of global memory object */
+                 DWORD size,     /* [in] New size of block */
+                 UINT32 flags    /* [in] How to reallocate object */
+) {
    LPVOID               palloc;
    HGLOBAL32            hnew;
    PGLOBAL32_INTERN     pintern;
@@ -1177,9 +1261,13 @@
 
 /***********************************************************************
  *           GlobalFree32   (KERNEL32.322)
+ * RETURNS
+ *	NULL: Success
+ *	Handle: Failure
  */
-HGLOBAL32 WINAPI GlobalFree32(HGLOBAL32 hmem)
-{
+HGLOBAL32 WINAPI GlobalFree32(
+                 HGLOBAL32 hmem /* [in] Handle of global memory object */
+) {
    PGLOBAL32_INTERN pintern;
    HGLOBAL32        hreturned = 0;
    
@@ -1211,9 +1299,13 @@
 
 /***********************************************************************
  *           GlobalSize32   (KERNEL32.329)
+ * RETURNS
+ *	Size in bytes of the global memory object
+ *	0: Failure
  */
-DWORD WINAPI GlobalSize32(HGLOBAL32 hmem)
-{
+DWORD WINAPI GlobalSize32(
+             HGLOBAL32 hmem /* [in] Handle of global memory object */
+) {
    DWORD                retval;
    PGLOBAL32_INTERN     pintern;
 
@@ -1280,9 +1372,18 @@
 
 /***********************************************************************
  *           GlobalFlags32   (KERNEL32.321)
+ * Returns information about the specified global memory object
+ *
+ * NOTES
+ *	Should this return GMEM_INVALID_HANDLE on invalid handle?
+ *
+ * RETURNS
+ *	Value specifying allocation flags and lock count
+ *	GMEM_INVALID_HANDLE: Failure
  */
-UINT32 WINAPI GlobalFlags32(HGLOBAL32 hmem)
-{
+UINT32 WINAPI GlobalFlags32(
+              HGLOBAL32 hmem /* [in] Handle to global memory object */
+) {
    DWORD                retval;
    PGLOBAL32_INTERN     pintern;
    
@@ -1302,7 +1403,7 @@
       }
       else
       {
-	 WARN(global,"invalid handle\n");
+	 WARN(global,"Invalid handle: %04x", hmem);
 	 retval=0;
       }
       /* HeapUnlock(GetProcessHeap()); */
@@ -1322,9 +1423,12 @@
 
 /***********************************************************************
  *           GlobalMemoryStatus   (KERNEL32.327)
+ * RETURNS
+ *	None
  */
-VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpmem )
-{
+VOID WINAPI GlobalMemoryStatus(
+            LPMEMORYSTATUS lpmem
+) {
 #ifdef linux
     FILE *f = fopen( "/proc/meminfo", "r" );
     if (f)
@@ -1380,6 +1484,7 @@
     lpmem->dwAvailVirtual  = 32*1024*1024;
 }
 
+
 /**********************************************************************
  *           WOWGlobalAllocLock (KERNEL32.62)
  *
@@ -1393,6 +1498,7 @@
     return WIN16_GlobalLock16(xhmem);
 }
 
+
 /**********************************************************************
  *           WOWGlobalUnlockFree (KERNEL32.64)
  *
diff --git a/memory/heap.c b/memory/heap.c
index e657d38..446b63d 100644
--- a/memory/heap.c
+++ b/memory/heap.c
@@ -106,42 +106,42 @@
     SUBHEAP *subheap;
     char *ptr;
 
-    printf( "Heap: %08lx\n", (DWORD)heap );
-    printf( "Next: %08lx  Sub-heaps: %08lx",
-            (DWORD)heap->next, (DWORD)&heap->subheap );
+    DUMP( "Heap: %08lx\n", (DWORD)heap );
+    DUMP( "Next: %08lx  Sub-heaps: %08lx",
+	  (DWORD)heap->next, (DWORD)&heap->subheap );
     subheap = &heap->subheap;
     while (subheap->next)
     {
-        printf( " -> %08lx", (DWORD)subheap->next );
+        DUMP( " -> %08lx", (DWORD)subheap->next );
         subheap = subheap->next;
     }
 
-    printf( "\nFree lists:\n Block   Stat   Size    Id\n" );
+    DUMP( "\nFree lists:\n Block   Stat   Size    Id\n" );
     for (i = 0; i < HEAP_NB_FREE_LISTS; i++)
-        printf( "%08lx free %08lx %04x prev=%08lx next=%08lx\n",
-                (DWORD)&heap->freeList[i].arena, heap->freeList[i].arena.size,
-                heap->freeList[i].arena.threadId,
-                (DWORD)heap->freeList[i].arena.prev,
-                (DWORD)heap->freeList[i].arena.next );
+        DUMP( "%08lx free %08lx %04x prev=%08lx next=%08lx\n",
+	      (DWORD)&heap->freeList[i].arena, heap->freeList[i].arena.size,
+	      heap->freeList[i].arena.threadId,
+	      (DWORD)heap->freeList[i].arena.prev,
+	      (DWORD)heap->freeList[i].arena.next );
 
     subheap = &heap->subheap;
     while (subheap)
     {
         DWORD freeSize = 0, usedSize = 0, arenaSize = subheap->headerSize;
-        printf( "\n\nSub-heap %08lx: size=%08lx committed=%08lx\n",
-                (DWORD)subheap, subheap->size, subheap->commitSize );
-
-        printf( "\n Block   Stat   Size    Id\n" );
+        DUMP( "\n\nSub-heap %08lx: size=%08lx committed=%08lx\n",
+	      (DWORD)subheap, subheap->size, subheap->commitSize );
+	
+        DUMP( "\n Block   Stat   Size    Id\n" );
         ptr = (char*)subheap + subheap->headerSize;
         while (ptr < (char *)subheap + subheap->size)
         {
             if (*(DWORD *)ptr & ARENA_FLAG_FREE)
             {
                 ARENA_FREE *pArena = (ARENA_FREE *)ptr;
-                printf( "%08lx free %08lx %04x prev=%08lx next=%08lx\n",
-                        (DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
-                        pArena->threadId, (DWORD)pArena->prev,
-                        (DWORD)pArena->next);
+                DUMP( "%08lx free %08lx %04x prev=%08lx next=%08lx\n",
+		      (DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
+		      pArena->threadId, (DWORD)pArena->prev,
+		      (DWORD)pArena->next);
                 ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
                 arenaSize += sizeof(ARENA_FREE);
                 freeSize += pArena->size & ARENA_SIZE_MASK;
@@ -149,10 +149,10 @@
             else if (*(DWORD *)ptr & ARENA_FLAG_PREV_FREE)
             {
                 ARENA_INUSE *pArena = (ARENA_INUSE *)ptr;
-                printf( "%08lx Used %08lx %04x back=%08lx EIP=%08lx\n",
-                        (DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
-                        pArena->threadId, *((DWORD *)pArena - 1),
-                        pArena->callerEIP );
+                DUMP( "%08lx Used %08lx %04x back=%08lx EIP=%08lx\n",
+		      (DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
+		      pArena->threadId, *((DWORD *)pArena - 1),
+		      pArena->callerEIP );
                 ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
                 arenaSize += sizeof(ARENA_INUSE);
                 usedSize += pArena->size & ARENA_SIZE_MASK;
@@ -160,17 +160,17 @@
             else
             {
                 ARENA_INUSE *pArena = (ARENA_INUSE *)ptr;
-                printf( "%08lx used %08lx %04x EIP=%08lx\n",
-                        (DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
-                        pArena->threadId, pArena->callerEIP );
+                DUMP( "%08lx used %08lx %04x EIP=%08lx\n",
+		      (DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
+		      pArena->threadId, pArena->callerEIP );
                 ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
                 arenaSize += sizeof(ARENA_INUSE);
                 usedSize += pArena->size & ARENA_SIZE_MASK;
             }
         }
-        printf( "\nTotal: Size=%08lx Committed=%08lx Free=%08lx Used=%08lx Arenas=%08lx (%ld%%)\n\n",
-                subheap->size, subheap->commitSize, freeSize, usedSize,
-                arenaSize, (arenaSize * 100) / subheap->size );
+        DUMP( "\nTotal: Size=%08lx Committed=%08lx Free=%08lx Used=%08lx Arenas=%08lx (%ld%%)\n\n",
+	      subheap->size, subheap->commitSize, freeSize, usedSize,
+	      arenaSize, (arenaSize * 100) / subheap->size );
         subheap = subheap->next;
     }
 }
@@ -178,9 +178,13 @@
 
 /***********************************************************************
  *           HEAP_GetPtr
+ * RETURNS
+ *	Pointer to the heap
+ *	NULL: Failure
  */
-static HEAP *HEAP_GetPtr( HANDLE32 heap )
-{
+static HEAP *HEAP_GetPtr(
+             HANDLE32 heap /* [in] Handle to the heap */
+) {
     HEAP *heapPtr = (HEAP *)heap;
     if (!heapPtr || (heapPtr->magic != HEAP_MAGIC))
     {
@@ -218,11 +222,16 @@
 
 /***********************************************************************
  *           HEAP_FindSubHeap
- *
  * Find the sub-heap containing a given address.
+ *
+ * RETURNS
+ *	Pointer: Success
+ *	NULL: Failure
  */
-static SUBHEAP *HEAP_FindSubHeap( HEAP *heap, LPCVOID ptr )
-{
+static SUBHEAP *HEAP_FindSubHeap(
+                HEAP *heap, /* [in] Heap pointer */
+                LPCVOID ptr /* [in] Address */
+) {
     SUBHEAP *sub = &heap->subheap;
     while (sub)
     {
@@ -717,11 +726,20 @@
 
 /***********************************************************************
  *           HEAP_IsInsideHeap
+ * Checks whether the pointer points to a block inside a given heap.
  *
- * Check whether the pointer is to a block inside a given heap.
+ * NOTES
+ *	Should this return BOOL32?
+ *
+ * RETURNS
+ *	!0: Success
+ *	0: Failure
  */
-int HEAP_IsInsideHeap( HANDLE32 heap, DWORD flags, LPCVOID ptr )
-{
+int HEAP_IsInsideHeap(
+    HANDLE32 heap, /* [in] Heap */
+    DWORD flags,   /* [in] Flags */
+    LPCVOID ptr    /* [in] Pointer */
+) {
     HEAP *heapPtr = HEAP_GetPtr( heap );
     SUBHEAP *subheap;
     int ret;
@@ -783,9 +801,15 @@
 
 /***********************************************************************
  *           HeapCreate   (KERNEL32.336)
+ * RETURNS
+ *	Handle of heap: Success
+ *	NULL: Failure
  */
-HANDLE32 WINAPI HeapCreate( DWORD flags, DWORD initialSize, DWORD maxSize )
-{
+HANDLE32 WINAPI HeapCreate(
+                DWORD flags,       /* [in] Heap allocation flag */
+                DWORD initialSize, /* [in] Initial heap size */
+                DWORD maxSize      /* [in] Maximum heap size */
+) {
     int i;
     HEAP *heap;
     SUBHEAP *subheap;
@@ -844,9 +868,13 @@
 
 /***********************************************************************
  *           HeapDestroy   (KERNEL32.337)
+ * RETURNS
+ *	TRUE: Success
+ *	FALSE: Failure
  */
-BOOL32 WINAPI HeapDestroy( HANDLE32 heap )
-{
+BOOL32 WINAPI HeapDestroy(
+              HANDLE32 heap /* [in] Handle of heap */
+) {
     HEAP *heapPtr = HEAP_GetPtr( heap );
     SUBHEAP *subheap;
 
@@ -868,9 +896,15 @@
 
 /***********************************************************************
  *           HeapAlloc   (KERNEL32.334)
+ * RETURNS
+ *	Pointer to allocated memory block
+ *	NULL: Failure
  */
-LPVOID WINAPI HeapAlloc( HANDLE32 heap, DWORD flags, DWORD size )
-{
+LPVOID WINAPI HeapAlloc(
+              HANDLE32 heap, /* [in] Handle of private heap block */
+              DWORD flags,   /* [in] Heap allocation control flags */
+              DWORD size     /* [in] Number of bytes to allocate */
+) {
     ARENA_FREE *pArena;
     ARENA_INUSE *pInUse;
     SUBHEAP *subheap;
@@ -927,9 +961,15 @@
 
 /***********************************************************************
  *           HeapFree   (KERNEL32.338)
+ * RETURNS
+ *	TRUE: Success
+ *	FALSE: Failure
  */
-BOOL32 WINAPI HeapFree( HANDLE32 heap, DWORD flags, LPVOID ptr )
-{
+BOOL32 WINAPI HeapFree(
+              HANDLE32 heap, /* [in] Handle of heap */
+              DWORD flags,   /* [in] Heap freeing flags */
+              LPVOID ptr     /* [in] Address of memory to free */
+) {
     ARENA_INUSE *pInUse;
     SUBHEAP *subheap;
     HEAP *heapPtr = HEAP_GetPtr( heap );
@@ -966,9 +1006,16 @@
 
 /***********************************************************************
  *           HeapReAlloc   (KERNEL32.340)
+ * RETURNS
+ *	Pointer to reallocated memory block
+ *	NULL: Failure
  */
-LPVOID WINAPI HeapReAlloc( HANDLE32 heap, DWORD flags, LPVOID ptr, DWORD size )
-{
+LPVOID WINAPI HeapReAlloc(
+              HANDLE32 heap, /* [in] Handle of heap block */
+              DWORD flags,   /* [in] Heap reallocation flags */
+              LPVOID ptr,    /* [in] Address of memory to reallocate */
+              DWORD size     /* [in] Number of bytes to reallocate */
+) {
     ARENA_INUSE *pArena;
     DWORD oldSize;
     HEAP *heapPtr;
@@ -1091,9 +1138,15 @@
 
 /***********************************************************************
  *           HeapLock   (KERNEL32.339)
+ * Attempts to acquire the critical section object for a specified heap.
+ *
+ * RETURNS
+ *	TRUE: Success
+ *	FALSE: Failure
  */
-BOOL32 WINAPI HeapLock( HANDLE32 heap )
-{
+BOOL32 WINAPI HeapLock(
+              HANDLE32 heap /* [in] Handle of heap to lock for exclusive access */
+) {
     HEAP *heapPtr = HEAP_GetPtr( heap );
     if (!heapPtr) return FALSE;
     EnterCriticalSection( &heapPtr->critSection );
@@ -1103,9 +1156,15 @@
 
 /***********************************************************************
  *           HeapUnlock   (KERNEL32.342)
+ * Releases ownership of the critical section object.
+ *
+ * RETURNS
+ *	TRUE: Success
+ *	FALSE: Failure
  */
-BOOL32 WINAPI HeapUnlock( HANDLE32 heap )
-{
+BOOL32 WINAPI HeapUnlock(
+              HANDLE32 heap /* [in] Handle to the heap to unlock */
+) {
     HEAP *heapPtr = HEAP_GetPtr( heap );
     if (!heapPtr) return FALSE;
     LeaveCriticalSection( &heapPtr->critSection );
@@ -1115,9 +1174,15 @@
 
 /***********************************************************************
  *           HeapSize   (KERNEL32.341)
+ * RETURNS
+ *	Size in bytes of allocated memory
+ *	0: Failure
  */
-DWORD WINAPI HeapSize( HANDLE32 heap, DWORD flags, LPVOID ptr )
-{
+DWORD WINAPI HeapSize(
+             HANDLE32 heap, /* [in] Handle of heap */
+             DWORD flags,   /* [in] Heap size control flags */
+             LPVOID ptr     /* [in] Address of memory to return size for */
+) {
     DWORD ret;
     HEAP *heapPtr = HEAP_GetPtr( heap );
 
@@ -1145,11 +1210,22 @@
 
 /***********************************************************************
  *           HeapValidate   (KERNEL32.343)
+ * Validates a specified heap.
+ *
+ * NOTES
+ *	Flags is ignored.
+ *
+ * RETURNS
+ *	TRUE: Success
+ *	FALSE: Failure
  */
-BOOL32 WINAPI HeapValidate( HANDLE32 heap, DWORD flags, LPCVOID block )
-{
+BOOL32 WINAPI HeapValidate(
+              HANDLE32 heap, /* [in] Handle to the heap */
+              DWORD flags,   /* [in] Bit flags that control access during operation */
+              LPCVOID block  /* [in] Optional pointer to memory block to validate */
+) {
     SUBHEAP *subheap;
-    HEAP *heapPtr = (HEAP *)heap;
+    HEAP *heapPtr = HEAP_GetPtr(heap);
 
     if (!heapPtr || (heapPtr->magic != HEAP_MAGIC))
     {
@@ -1159,6 +1235,7 @@
 
     if (block)
     {
+        /* Only check this single memory block */
         if (!(subheap = HEAP_FindSubHeap( heapPtr, block )) ||
             ((char *)block < (char *)subheap + subheap->headerSize
                               + sizeof(ARENA_INUSE)))
@@ -1197,9 +1274,16 @@
 
 /***********************************************************************
  *           HeapWalk   (KERNEL32.344)
+ * Enumerates the memory blocks in a specified heap.
+ *
+ * RETURNS
+ *	TRUE: Success
+ *	FALSE: Failure
  */
-BOOL32 WINAPI HeapWalk( HANDLE32 heap, void *entry )
-{
+BOOL32 WINAPI HeapWalk(
+              HANDLE32 heap,               /* [in]  Handle to heap to enumerate */
+              LPPROCESS_HEAP_ENTRY *entry  /* [out] Pointer to structure of enumeration info */
+) {
     fprintf( stderr, "HeapWalk(%08x): not implemented\n", heap );
     return FALSE;
 }
diff --git a/memory/local.c b/memory/local.c
index 479d382..910665f 100644
--- a/memory/local.c
+++ b/memory/local.c
@@ -266,43 +266,43 @@
 
     if (!pInfo)
     {
-        printf( "Local Heap corrupted!  ds=%04x\n", ds );
+        DUMP( "Local Heap corrupted!  ds=%04x\n", ds );
         return;
     }
-    printf( "Local Heap  ds=%04x first=%04x last=%04x items=%d\n",
-            ds, pInfo->first, pInfo->last, pInfo->items );
+    DUMP( "Local Heap  ds=%04x first=%04x last=%04x items=%d\n",
+	  ds, pInfo->first, pInfo->last, pInfo->items );
 
     arena = pInfo->first;
     for (;;)
     {
         LOCALARENA *pArena = ARENA_PTR(ptr,arena);
-        printf( "  %04x: prev=%04x next=%04x type=%d\n", arena,
-                pArena->prev & ~3, pArena->next, pArena->prev & 3 );
+        DUMP( "  %04x: prev=%04x next=%04x type=%d\n", arena,
+	      pArena->prev & ~3, pArena->next, pArena->prev & 3 );
         if (arena == pInfo->first)
 	{
-            printf( "        size=%d free_prev=%04x free_next=%04x\n",
-                    pArena->size, pArena->free_prev, pArena->free_next );
+            DUMP( "        size=%d free_prev=%04x free_next=%04x\n",
+		  pArena->size, pArena->free_prev, pArena->free_next );
 	}
         if ((pArena->prev & 3) == LOCAL_ARENA_FREE)
         {
-            printf( "        size=%d free_prev=%04x free_next=%04x\n",
-                    pArena->size, pArena->free_prev, pArena->free_next );
+            DUMP( "        size=%d free_prev=%04x free_next=%04x\n",
+		  pArena->size, pArena->free_prev, pArena->free_next );
             if (pArena->next == arena) break;  /* last one */
             if (ARENA_PTR(ptr,pArena->free_next)->free_prev != arena)
             {
-                printf( "*** arena->free_next->free_prev != arena\n" );
+                DUMP( "*** arena->free_next->free_prev != arena\n" );
                 break;
             }
         }
         if (pArena->next == arena)
         {
-            printf( "*** last block is not marked free\n" );
+	    DUMP( "*** last block is not marked free\n" );
             break;
         }
         if ((ARENA_PTR(ptr,pArena->next)->prev & ~3) != arena)
         {
-            printf( "*** arena->next->prev != arena (%04x, %04x)\n",
-		   pArena->next, ARENA_PTR(ptr,pArena->next)->prev);
+            DUMP( "*** arena->next->prev != arena (%04x, %04x)\n",
+		  pArena->next, ARENA_PTR(ptr,pArena->next)->prev);
             break;
         }
         arena = pArena->next;
@@ -717,7 +717,7 @@
                     /* Free the old location */  
                     LOCAL_FreeArena(ds, movearena);
                     /* Update handle table entry */
-                    pEntry->addr = finalarena + ARENA_HEADER_SIZE;
+                    pEntry->addr = finalarena + ARENA_HEADER_SIZE + sizeof(HLOCAL16) ;
                 }
                 else if((ARENA_PTR(ptr, pMoveArena->prev & ~3)->prev & 3)
 			       == LOCAL_ARENA_FREE)
@@ -727,7 +727,7 @@
                     finalarena = pMoveArena->prev & ~3;
                     LOCAL_GrowArenaDownward( ds, movearena, movesize );
                     /* Update handle table entry */
-                    pEntry->addr = finalarena + ARENA_HEADER_SIZE;
+                    pEntry->addr = finalarena + ARENA_HEADER_SIZE + sizeof(HLOCAL16) ;
                 }
             }
         }
@@ -1246,7 +1246,12 @@
     }
     if(HANDLE_MOVEABLE(handle)) size += sizeof(HLOCAL16);
     hmem = LOCAL_GetBlock( ds, size, flags );
-    ptr = PTR_SEG_OFF_TO_LIN( ds, 0 );  /* Reload ptr */
+    ptr = PTR_SEG_OFF_TO_LIN( ds, 0 );  /* Reload ptr                             */
+    if(HANDLE_MOVEABLE(handle))         /* LOCAL_GetBlock might have triggered    */
+    {                                   /* a compaction, which might in turn have */
+      blockhandle = pEntry->addr ;      /* moved the very block we are resizing   */
+      arena = ARENA_HEADER( blockhandle );   /* thus, we reload arena, too        */
+    }
     if (!hmem)
     {
         /* Remove the block from the heap and try again */
@@ -1569,12 +1574,12 @@
 
     if (!(pInfo = LOCAL_GetHeap( ds )))
     {
-        fprintf( stderr, "LOCAL_Notify(%04x): Local heap not found\n", ds );
+        ERR(local, "(%04x): Local heap not found\n", ds );
 	LOCAL_PrintHeap( ds );
 	return 0;
     }
     TRACE(local, "(%04x): %08lx\n", ds, (DWORD)func );
-    fprintf(stdnimp, "LocalNotify(): Half implemented\n");
+    FIXME(local, "Half implemented\n");
     oldNotify = pInfo->notify;
     pInfo->notify = func;
     return oldNotify;
@@ -1633,7 +1638,7 @@
 
     if (!(pInfo = LOCAL_GetHeap( CURRENT_DS )))
     {
-        fprintf( stderr, "LocalHandleDelta: Local heap not found\n");
+        ERR(local, "Local heap not found\n");
 	LOCAL_PrintHeap( CURRENT_DS );
 	return 0;
     }
@@ -1707,9 +1712,14 @@
 
 /***********************************************************************
  *           LocalAlloc32   (KERNEL32.371)
+ * RETURNS
+ *	Handle: Success
+ *	NULL: Failure
  */
-HLOCAL32 WINAPI LocalAlloc32( UINT32 flags, DWORD size )
-{
+HLOCAL32 WINAPI LocalAlloc32(
+                UINT32 flags, /* [in] Allocation attributes */
+                DWORD size    /* [in] Number of bytes to allocate */
+) {
     return (HLOCAL32)GlobalAlloc32( flags, size );
 }
 
@@ -1725,45 +1735,70 @@
 
 /***********************************************************************
  *           LocalFlags32   (KERNEL32.374)
+ * RETURNS
+ *	Value specifying allocation flags and lock count.
+ *	LMEM_INVALID_HANDLE: Failure
  */
-UINT32 WINAPI LocalFlags32( HLOCAL32 handle )
-{
+UINT32 WINAPI LocalFlags32(
+              HLOCAL32 handle /* [in] Handle of memory object */
+) {
     return GlobalFlags32( (HGLOBAL32)handle );
 }
 
 
 /***********************************************************************
  *           LocalFree32   (KERNEL32.375)
+ * RETURNS
+ *	NULL: Success
+ *	Handle: Failure
  */
-HLOCAL32 WINAPI LocalFree32( HLOCAL32 handle )
-{
+HLOCAL32 WINAPI LocalFree32(
+                HLOCAL32 handle /* [in] Handle of memory object */
+) {
     return (HLOCAL32)GlobalFree32( (HGLOBAL32)handle );
 }
 
 
 /***********************************************************************
  *           LocalHandle32   (KERNEL32.376)
+ * RETURNS
+ *	Handle: Success
+ *	NULL: Failure
  */
-HLOCAL32 WINAPI LocalHandle32( LPCVOID ptr )
-{
+HLOCAL32 WINAPI LocalHandle32(
+                LPCVOID ptr /* [in] Address of local memory object */
+) {
     return (HLOCAL32)GlobalHandle32( ptr );
 }
 
 
 /***********************************************************************
  *           LocalLock32   (KERNEL32.377)
+ * Locks a local memory object and returns pointer to the first byte
+ * of the memory block.
+ *
+ * RETURNS
+ *	Pointer: Success
+ *	NULL: Failure
  */
-LPVOID WINAPI LocalLock32( HLOCAL32 handle )
-{
+LPVOID WINAPI LocalLock32(
+              HLOCAL32 handle /* [in] Address of local memory object */
+) {
     return GlobalLock32( (HGLOBAL32)handle );
 }
 
 
 /***********************************************************************
  *           LocalReAlloc32   (KERNEL32.378)
+ * RETURNS
+ *	Handle: Success
+ *	NULL: Failure
  */
-HLOCAL32 WINAPI LocalReAlloc32( HLOCAL32 handle, DWORD size, UINT32 flags )
-{
+HLOCAL32 WINAPI LocalReAlloc32(
+                HLOCAL32 handle, /* [in] Handle of memory object */
+                DWORD size,      /* [in] New size of block */
+                UINT32 flags     /* [in] How to reallocate object */
+) {
     return (HLOCAL32)GlobalReAlloc32( (HGLOBAL32)handle, size, flags );
 }
 
@@ -1779,17 +1814,25 @@
 
 /***********************************************************************
  *           LocalSize32   (KERNEL32.380)
+ * RETURNS
+ *	Size: Success
+ *	0: Failure
  */
-UINT32 WINAPI LocalSize32( HLOCAL32 handle )
-{
+UINT32 WINAPI LocalSize32(
+              HLOCAL32 handle /* [in] Handle of memory object */
+) {
     return GlobalSize32( (HGLOBAL32)handle );
 }
 
 
 /***********************************************************************
  *           LocalUnlock32   (KERNEL32.381)
+ * RETURNS
+ *	TRUE: Object is still locked
+ *	FALSE: Object is unlocked
  */
-BOOL32 WINAPI LocalUnlock32( HLOCAL32 handle )
-{
+BOOL32 WINAPI LocalUnlock32(
+              HLOCAL32 handle /* [in] Handle of memory object */
+) {
     return GlobalUnlock32( (HGLOBAL32)handle );
 }
diff --git a/memory/string.c b/memory/string.c
index 65e5709..6e063a8 100644
--- a/memory/string.c
+++ b/memory/string.c
@@ -11,7 +11,6 @@
 #include "winerror.h"
 #include "ldt.h"
 #include "debug.h"
-#include "debugstr.h"
 
 static const BYTE STRING_Oem2Ansi[256] =
 "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\244"
diff --git a/memory/virtual.c b/memory/virtual.c
index 937e482..f128cc1 100644
--- a/memory/virtual.c
+++ b/memory/virtual.c
@@ -137,28 +137,28 @@
     UINT32 addr = view->base;
     BYTE prot = view->prot[0];
 
-    printf( "View: %08x - %08x%s",
-             view->base, view->base + view->size - 1,
-             (view->flags & VFLAG_SYSTEM) ? " (system)" : "" );
+    DUMP( "View: %08x - %08x%s",
+	  view->base, view->base + view->size - 1,
+	  (view->flags & VFLAG_SYSTEM) ? " (system)" : "" );
     if (view->mapping && view->mapping->file)
-        printf( " %s @ %08x\n", view->mapping->file->unix_name, view->offset );
+        DUMP( " %s @ %08x\n", view->mapping->file->unix_name, view->offset );
     else
-        printf( " (anonymous)\n");
+        DUMP( " (anonymous)\n");
 
     for (count = i = 1; i < view->size >> page_shift; i++, count++)
     {
         if (view->prot[i] == prot) continue;
-        printf( "      %08x - %08x %s\n",
-                addr, addr + (count << page_shift) - 1,
-                VIRTUAL_GetProtStr(prot) );
+        DUMP( "      %08x - %08x %s\n",
+	      addr, addr + (count << page_shift) - 1,
+	      VIRTUAL_GetProtStr(prot) );
         addr += (count << page_shift);
         prot = view->prot[i];
         count = 0;
     }
     if (count)
-        printf( "      %08x - %08x %s\n",
-                addr, addr + (count << page_shift) - 1,
-                VIRTUAL_GetProtStr(prot) );
+        DUMP( "      %08x - %08x %s\n",
+	      addr, addr + (count << page_shift) - 1,
+	      VIRTUAL_GetProtStr(prot) );
 }
 
 
@@ -168,7 +168,7 @@
 void VIRTUAL_Dump(void)
 {
     FILE_VIEW *view = VIRTUAL_FirstView;
-    printf( "\nDump of all virtual memory views:\n\n" );
+    DUMP( "\nDump of all virtual memory views:\n\n" );
     while (view)
     {
         VIRTUAL_DumpView( view );
@@ -181,9 +181,14 @@
  *           VIRTUAL_FindView
  *
  * Find the view containing a given address.
+ *
+ * RETURNS
+ *	View: Success
+ *	NULL: Failure
  */
-static FILE_VIEW *VIRTUAL_FindView( UINT32 addr )
-{
+static FILE_VIEW *VIRTUAL_FindView(
+                  UINT32 addr /* [in] Address */
+) {
     FILE_VIEW *view = VIRTUAL_FirstView;
     while (view)
     {
@@ -245,11 +250,14 @@
 
 /***********************************************************************
  *           VIRTUAL_DeleteView
+ * Deletes a view.
  *
- * Delete an view.
+ * RETURNS
+ *	None
  */
-static void VIRTUAL_DeleteView( FILE_VIEW *view )
-{
+static void VIRTUAL_DeleteView(
+            FILE_VIEW *view /* [in] View */
+) {
     FILE_munmap( (void *)view->base, 0, view->size );
     if (view->next) view->next->prev = view->prev;
     if (view->prev) view->prev->next = view->next;
@@ -281,9 +289,15 @@
  *           VIRTUAL_GetWin32Prot
  *
  * Convert page protections to Win32 flags.
+ *
+ * RETURNS
+ *	None
  */
-static void VIRTUAL_GetWin32Prot( BYTE vprot, DWORD *protect, DWORD *state )
-{
+static void VIRTUAL_GetWin32Prot(
+            BYTE vprot,     /* [in] Page protection flags */
+            DWORD *protect, /* [out] Location to store Win32 protection flags */
+            DWORD *state    /* [out] Location to store mem state flag */
+) {
     if (protect) {
     	*protect = VIRTUAL_Win32Flags[vprot & 0x0f];
     	if (vprot & VPROT_GUARD) *protect |= PAGE_GUARD;
@@ -298,9 +312,13 @@
  *           VIRTUAL_GetProt
  *
  * Build page protections from Win32 flags.
+ *
+ * RETURNS
+ *	Value of page protection flags
  */
-static BYTE VIRTUAL_GetProt( DWORD protect )
-{
+static BYTE VIRTUAL_GetProt(
+            DWORD protect  /* [in] Win32 protection flags */
+) {
     BYTE vprot;
 
     switch(protect & 0xff)
@@ -341,10 +359,17 @@
  *           VIRTUAL_SetProt
  *
  * Change the protection of a range of pages.
+ *
+ * RETURNS
+ *	TRUE: Success
+ *	FALSE: Failure
  */
-static BOOL32 VIRTUAL_SetProt( FILE_VIEW *view, UINT32 base,
-                               UINT32 size, BYTE vprot )
-{
+static BOOL32 VIRTUAL_SetProt(
+              FILE_VIEW *view, /* [in] Pointer to view */
+              UINT32 base,     /* [in] Starting address */
+              UINT32 size,     /* [in] Size in bytes */
+              BYTE vprot       /* [in] Protections to use */
+) {
     TRACE(virtual, "%08x-%08x %s\n",
                      base, base + size - 1, VIRTUAL_GetProtStr( vprot ) );
 
@@ -362,9 +387,16 @@
  *             VIRTUAL_CheckFlags
  *
  * Check that all pages in a range have the given flags.
+ *
+ * RETURNS
+ *	TRUE: They do
+ *	FALSE: They do not
  */
-static BOOL32 VIRTUAL_CheckFlags( UINT32 base, UINT32 size, BYTE flags )
-{
+static BOOL32 VIRTUAL_CheckFlags(
+              UINT32 base, /* [in] Starting address */
+              UINT32 size, /* [in] Size in bytes */
+              BYTE flags   /* [in] Flags to check for */
+) {
     FILE_VIEW *view;
     UINT32 page;
 
@@ -444,10 +476,10 @@
  *	NULL: Failure
  */
 LPVOID WINAPI VirtualAlloc(
-              LPVOID addr,  /* Address of region to reserve or commit */
-              DWORD size,   /* Size of region */
-              DWORD type,   /* Type of allocation */
-              DWORD protect /* Type of access protection */
+              LPVOID addr,  /* [in] Address of region to reserve or commit */
+              DWORD size,   /* [in] Size of region */
+              DWORD type,   /* [in] Type of allocation */
+              DWORD protect /* [in] Type of access protection */
 ) {
     FILE_VIEW *view;
     UINT32 base, ptr, view_size;
@@ -568,9 +600,9 @@
  *	FALSE: Failure
  */
 BOOL32 WINAPI VirtualFree(
-              LPVOID addr, /* Address of region of committed pages */
-              DWORD size,  /* Size of region */
-              DWORD type   /* Type of operation */
+              LPVOID addr, /* [in] Address of region of committed pages */
+              DWORD size,  /* [in] Size of region */
+              DWORD type   /* [in] Type of operation */
 ) {
     FILE_VIEW *view;
     UINT32 base;
@@ -612,7 +644,6 @@
     }
 
     /* Decommit the pages */
-
     return VIRTUAL_SetProt( view, base, size, 0 );
 }
 
@@ -629,8 +660,8 @@
  *	FALSE: Failure
  */
 BOOL32 WINAPI VirtualLock(
-              LPVOID addr, /* Address of first byte of range to lock */
-              DWORD size   /* Number of bytes in range to lock */
+              LPVOID addr, /* [in] Address of first byte of range to lock */
+              DWORD size   /* [in] Number of bytes in range to lock */
 ) {
     return TRUE;
 }
@@ -648,8 +679,8 @@
  *	FALSE: Failure
  */
 BOOL32 WINAPI VirtualUnlock(
-              LPVOID addr, /* Address of first byte of range */
-              DWORD size   /* Number of bytes in range */
+              LPVOID addr, /* [in] Address of first byte of range */
+              DWORD size   /* [in] Number of bytes in range */
 ) {
     return TRUE;
 }
@@ -664,10 +695,10 @@
  *	FALSE: Failure
  */
 BOOL32 WINAPI VirtualProtect(
-              LPVOID addr,     /* Address of region of committed pages */
-              DWORD size,      /* Size of region */
-              DWORD new_prot,  /* Desired access protection */
-              LPDWORD old_prot /* Address of variable to get old protection */
+              LPVOID addr,     /* [in] Address of region of committed pages */
+              DWORD size,      /* [in] Size of region */
+              DWORD new_prot,  /* [in] Desired access protection */
+              LPDWORD old_prot /* [out] Address of variable to get old protection */
 ) {
     FILE_VIEW *view;
     UINT32 base, i;
@@ -716,11 +747,11 @@
  *	FALSE: Failure
  */
 BOOL32 WINAPI VirtualProtectEx(
-              HANDLE32 handle, /* Handle of process */
-              LPVOID addr,     /* Address of region of committed pages */
-              DWORD size,      /* Size of region */
-              DWORD new_prot,  /* Desired access protection */
-	      LPDWORD old_prot /* Address of variable to get old protection */
+              HANDLE32 handle, /* [in]  Handle of process */
+              LPVOID addr,     /* [in]  Address of region of committed pages */
+              DWORD size,      /* [in]  Size of region */
+              DWORD new_prot,  /* [in]  Desired access protection */
+              LPDWORD old_prot /* [out] Address of variable to get old protection */
 ) {
     BOOL32 ret = FALSE;
 
@@ -745,9 +776,9 @@
  *	Number of bytes returned in information buffer
  */
 DWORD WINAPI VirtualQuery(
-             LPCVOID addr, /* Address of region */
-             LPMEMORY_BASIC_INFORMATION info, /* Address of info buffer */
-             DWORD len     /* Size of buffer */
+             LPCVOID addr,                    /* [in]  Address of region */
+             LPMEMORY_BASIC_INFORMATION info, /* [out] Address of info buffer */
+             DWORD len                        /* [in]  Size of buffer */
 ) {
     FILE_VIEW *view = VIRTUAL_FirstView;
     UINT32 base = ROUND_ADDR( addr );
@@ -814,10 +845,10 @@
  *	Number of bytes returned in information buffer
  */
 DWORD WINAPI VirtualQueryEx(
-             HANDLE32 handle, /* Handle of process */
-             LPCVOID addr,    /* Address of region */
-             LPMEMORY_BASIC_INFORMATION info, /* Address of info buffer */
-             DWORD len        /* Size of buffer */
+             HANDLE32 handle,                 /* [in] Handle of process */
+             LPCVOID addr,                    /* [in] Address of region */
+             LPMEMORY_BASIC_INFORMATION info, /* [out] Address of info buffer */
+             DWORD len                        /* [in] Size of buffer */
 ) {
     DWORD ret = len;
 
@@ -858,8 +889,8 @@
  *      TRUE: Otherwise
  */
 BOOL32 WINAPI IsBadWritePtr32(
-	      LPVOID ptr, /* address of memory block */
-	      UINT32 size /* size of block */
+              LPVOID ptr, /* [in] Address of memory block */
+              UINT32 size /* [in] Size of block in bytes */
 ) {
     return !VIRTUAL_CheckFlags( (UINT32)ptr, size,
                                 VPROT_WRITE | VPROT_COMMITTED );
@@ -868,27 +899,42 @@
 
 /***********************************************************************
  *             IsBadHugeReadPtr32   (KERNEL32.352)
+ * RETURNS
+ *	FALSE: Process has read access to entire block
+ *      TRUE: Otherwise
  */
-BOOL32 WINAPI IsBadHugeReadPtr32( LPCVOID ptr, UINT32 size )
-{
+BOOL32 WINAPI IsBadHugeReadPtr32(
+              LPCVOID ptr, /* [in] Address of memory block */
+              UINT32 size  /* [in] Size of block */
+) {
     return IsBadReadPtr32( ptr, size );
 }
 
 
 /***********************************************************************
  *             IsBadHugeWritePtr32   (KERNEL32.353)
+ * RETURNS
+ *	FALSE: Process has write access to entire block
+ *      TRUE: Otherwise
  */
-BOOL32 WINAPI IsBadHugeWritePtr32( LPVOID ptr, UINT32 size )
-{
+BOOL32 WINAPI IsBadHugeWritePtr32(
+              LPVOID ptr, /* [in] Address of memory block */
+              UINT32 size /* [in] Size of block */
+) {
     return IsBadWritePtr32( ptr, size );
 }
 
 
 /***********************************************************************
  *             IsBadCodePtr32   (KERNEL32.351)
+ *
+ * RETURNS
+ *	FALSE: Process has read access to specified memory
+ *	TRUE: Otherwise
  */
-BOOL32 WINAPI IsBadCodePtr32( FARPROC32 ptr )
-{
+BOOL32 WINAPI IsBadCodePtr32(
+              FARPROC32 ptr /* [in] Address of function */
+) {
     return !VIRTUAL_CheckFlags( (UINT32)ptr, 1, VPROT_EXEC | VPROT_COMMITTED );
 }
 
@@ -901,8 +947,8 @@
  *	TRUE: Else
  */
 BOOL32 WINAPI IsBadStringPtr32A(
-              LPCSTR str, /* Address of string */
-              UINT32 max  /* Maximum size of string */
+              LPCSTR str, /* [in] Address of string */
+              UINT32 max  /* [in] Maximum size of string */
 ) {
     FILE_VIEW *view;
     UINT32 page, count;
@@ -929,15 +975,10 @@
 
 /***********************************************************************
  *             IsBadStringPtr32W   (KERNEL32.356)
- *
- * RETURNS
- *	FALSE: Read access to all bytes in string
- *	TRUE: Else
+ * See IsBadStringPtr32A
  */
-BOOL32 WINAPI IsBadStringPtr32W(
-              LPCWSTR str, /* Address of string */
-              UINT32 max   /* Maximum size of string */
-) {
+BOOL32 WINAPI IsBadStringPtr32W( LPCWSTR str, UINT32 max )
+{
     FILE_VIEW *view;
     UINT32 page, count;
 
@@ -966,17 +1007,17 @@
  * Creates a named or unnamed file-mapping object for the specified file
  *
  * RETURNS
- *	Handle of the file-mapping object
- *	0: Mapping object did not exist
+ *	Handle: Success
+ *	0: Mapping object does not exist
  *	NULL: Failure
  */
 HANDLE32 WINAPI CreateFileMapping32A(
-                HFILE32 hFile,   /* Handle of file to map */
-                LPSECURITY_ATTRIBUTES attr, /* Optional security attributes */
-                DWORD protect,   /* Protection for mapping object */
-                DWORD size_high, /* High-order 32 bits of object size */
-                DWORD size_low,  /* Low-order 32 bits of object size */
-                LPCSTR name      /* Name of file-mapping object */
+                HFILE32 hFile,   /* [in] Handle of file to map */
+                LPSECURITY_ATTRIBUTES attr, /* [in] Optional security attributes */
+                DWORD protect,   /* [in] Protection for mapping object */
+                DWORD size_high, /* [in] High-order 32 bits of object size */
+                DWORD size_low,  /* [in] Low-order 32 bits of object size */
+                LPCSTR name      /* [in] Name of file-mapping object */
 ) {
     FILE_MAPPING *mapping = NULL;
     HANDLE32 handle;
@@ -1084,10 +1125,11 @@
 
 /***********************************************************************
  *             CreateFileMapping32W   (KERNEL32.47)
+ * See CreateFileMapping32A
  */
-HANDLE32 WINAPI CreateFileMapping32W(HFILE32 hFile, LPSECURITY_ATTRIBUTES attr,
-                                     DWORD protect, DWORD size_high,
-                                     DWORD size_low, LPCWSTR name )
+HANDLE32 WINAPI CreateFileMapping32W( HFILE32 hFile, LPSECURITY_ATTRIBUTES attr, 
+                                      DWORD protect, DWORD size_high,  
+                                      DWORD size_low, LPCWSTR name )
 {
     LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, name );
     HANDLE32 ret = CreateFileMapping32A( hFile, attr, protect,
@@ -1099,16 +1141,16 @@
 
 /***********************************************************************
  *             OpenFileMapping32A   (KERNEL32.397)
- * Opens a named file-mapping object
+ * Opens a named file-mapping object.
  *
  * RETURNS
- *	Open handle to specified file-mapping object
+ *	Handle: Success
  *	NULL: Failure
  */
 HANDLE32 WINAPI OpenFileMapping32A(
-                DWORD access,   /* Access mode */
-                BOOL32 inherit, /* Inherit flag */
-                LPCSTR name     /* Name of file-mapping object */
+                DWORD access,   /* [in] Access mode */
+                BOOL32 inherit, /* [in] Inherit flag */
+                LPCSTR name     /* [in] Name of file-mapping object */
 ) {
     HANDLE32 handle = 0;
     K32OBJ *obj;
@@ -1125,6 +1167,7 @@
 
 /***********************************************************************
  *             OpenFileMapping32W   (KERNEL32.398)
+ * See OpenFileMapping32A
  */
 HANDLE32 WINAPI OpenFileMapping32W( DWORD access, BOOL32 inherit, LPCWSTR name)
 {
@@ -1160,11 +1203,11 @@
  *	NULL: Failure
  */
 LPVOID WINAPI MapViewOfFile(
-              HANDLE32 mapping,  /* File-mapping object to map */
-              DWORD access,      /* Access mode */
-              DWORD offset_high, /* High-order 32 bits of file offset */
-              DWORD offset_low,  /* Low-order 32 bits of file offset */
-              DWORD count        /* Number of bytes to map */
+              HANDLE32 mapping,  /* [in] File-mapping object to map */
+              DWORD access,      /* [in] Access mode */
+              DWORD offset_high, /* [in] High-order 32 bits of file offset */
+              DWORD offset_low,  /* [in] Low-order 32 bits of file offset */
+              DWORD count        /* [in] Number of bytes to map */
 ) {
     return MapViewOfFileEx( mapping, access, offset_high,
                             offset_low, count, NULL );
@@ -1180,12 +1223,12 @@
  *	NULL: Failure
  */
 LPVOID WINAPI MapViewOfFileEx(
-              HANDLE32 handle,   /* File-mapping object to map */
-              DWORD access,      /* Access mode */
-              DWORD offset_high, /* High-order 32 bits of file offset */
-              DWORD offset_low,  /* Low-order 32 bits of file offset */
-              DWORD count,       /* Number of bytes to map */
-              LPVOID addr        /* Suggested starting address for mapped view */
+              HANDLE32 handle,   /* [in] File-mapping object to map */
+              DWORD access,      /* [in] Access mode */
+              DWORD offset_high, /* [in] High-order 32 bits of file offset */
+              DWORD offset_low,  /* [in] Low-order 32 bits of file offset */
+              DWORD count,       /* [in] Number of bytes to map */
+              LPVOID addr        /* [in] Suggested starting address for mapped view */
 ) {
     FILE_MAPPING *mapping;
     FILE_VIEW *view;
@@ -1278,8 +1321,8 @@
  *	FALSE: Failure
  */
 BOOL32 WINAPI FlushViewOfFile(
-              LPCVOID base, /* Start address of byte range to flush */
-              DWORD cbFlush /* Number of bytes in range */
+              LPCVOID base, /* [in] Start address of byte range to flush */
+              DWORD cbFlush /* [in] Number of bytes in range */
 ) {
     FILE_VIEW *view;
     UINT32 addr = ROUND_ADDR( base );
@@ -1298,11 +1341,21 @@
     return FALSE;
 }
 
+
 /***********************************************************************
  *             UnmapViewOfFile   (KERNEL32.540)
+ * Unmaps a mapped view of a file.
+ *
+ * NOTES
+ *	Should addr be an LPCVOID?
+ *
+ * RETURNS
+ *	TRUE: Success
+ *	FALSE: Failure
  */
-BOOL32 WINAPI UnmapViewOfFile( LPVOID addr )
-{
+BOOL32 WINAPI UnmapViewOfFile(
+              LPVOID addr /* [in] Address where mapped view begins */
+) {
     FILE_VIEW *view;
     UINT32 base = ROUND_ADDR( addr );
     if (!(view = VIRTUAL_FindView( base )) || (base != view->base))
diff --git a/misc/commdlg.c b/misc/commdlg.c
index 85c0f2b..5e3ca51 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -1156,7 +1156,7 @@
  */
 BOOL32 WINAPI PrintDlg32A( LPPRINTDLG32A printdlg )
 {
-    fprintf( stdnimp, "PrintDlg32A: empty stub\n" );
+    FIXME(commdlg, "empty stub\n" );
     return FALSE;
 }
 
@@ -1166,7 +1166,7 @@
  */
 BOOL32 WINAPI PrintDlg32W( LPPRINTDLG32W printdlg )
 {
-    fprintf( stdnimp, "PrintDlg32A: empty stub\n" );
+    FIXME(commdlg, "empty stub\n" );
     return FALSE;
 }
 
@@ -3231,7 +3231,10 @@
 /***********************************************************************
  *           ChooseFontA   (COMDLG32.3)
  */
-DWORD WINAPI ChooseFont32A(CHOOSEFONT pChoosefont)
+DWORD WINAPI ChooseFont32A(PCHOOSEFONT32A pChoosefont)
 {
+	FIXME(commdlg,"empty stub!\n");
+
+	CommDlgLastError = CDERR_DIALOGFAILURE;
 	return NULL;
 }
diff --git a/misc/crtdll.c b/misc/crtdll.c
index ac5beeb..e4cdda0 100644
--- a/misc/crtdll.c
+++ b/misc/crtdll.c
@@ -197,7 +197,7 @@
     DWORD *args = (DWORD *)ESP_reg(context);
     PEXCEPTION_FRAME endframe = (PEXCEPTION_FRAME)args[1];
     DWORD nr = args[2];
-    fprintf(stderr,"(%p,%ld)\n",endframe,nr);
+    TRACE(crtdll,"(%p,%ld)\n",endframe,nr);
 }
 
 /*********************************************************************
@@ -1111,7 +1111,7 @@
 	case CRTDLL_LC_TIME: categorystr="LC_TIME";break;
 	default: categorystr = "UNKNOWN?";break;
 	}
-	fprintf(stderr,"CRTDLL_setlocale(%s,%s),stub!\n",categorystr,locale);
+	FIXME(crtdll,"(%s,%s),stub!\n",categorystr,locale);
 	return "C";
 }
 
@@ -1348,8 +1348,7 @@
  */
 INT32 __cdecl CRTDLL_atexit(LPVOID x)
 {
-	/* FIXME */
-	fprintf(stdnimp,"CRTDLL.atexit(%p), STUB.\n",x);
+	FIXME(crtdll,"(%p), STUB.\n",x);
 	return 0; /* successful */
 }
 
diff --git a/misc/imagelist.c b/misc/imagelist.c
index f212a9c..db4c8b4 100644
--- a/misc/imagelist.c
+++ b/misc/imagelist.c
@@ -4,18 +4,43 @@
  *  Copyright 1998 Eric Kohl
  *
  *  TODO:
- *    - Use device independent bitmaps (DIBs) instead of device
- *      dependent bitmaps (DDBs).
- *    - Fix image selection (ImageList_Draw).
- *    - Improve error checking.
- *    - Add missing functions.
- *    - Many many other things. (undocumented functions)
+ *    - Improve the documentation.
+ *    - Fix ImageList_DrawIndirect.
+ *        - Drawing selected images is awfully slow since it has to
+ *          be done pixel by pixel.
+ *    - Fix ImageList_GetIcon (almost fixed).
+ *    - Fix all other stubs.
+ *    - Fix drag functions.
+ *    - Improve error checking in most functions.
+ *    - Add ImageList_SetFilter (undocumented).
+ *      BTW does anybody know anything about this function???
+ *        - It removes 12 Bytes from the stack (3 Parameters).
+ *        - First parameter SHOULD be a HIMAGELIST.
+ *        - Second parameter COULD be an index?????
+ *        - Third parameter.... ?????????????????????
+ *    - Add undocumented functions.
+ *        Are there any other undocumented ImageList functions?
+ *
+ *  Testing:
+ *    - Test ImageList_LoadImageA/W with Icons and Cursors.
+ *    - Test ImageList_Copy.
+ *    - Test ImageList_Duplicate.
+ *    - Test ImageList_Remove.
+ *    - Test ImageList_SetImageCount.
+ *    - Test ImageList_GetImageRect (undocumented).
+ *    - Test all the other functions.
+ *
+ *  Comments:
+ *    - ImageList_Draw, ImageList_DrawEx and ImageList_GetIcon use
+ *      ImageList_DrawIndirect. Since ImageList_DrawIndirect is still
+ *      partially imlemented, the functions mentioned above will be 
+ *      limited in functionality too.
  */
 
 /* This must be defined because the HIMAGELIST type is just a pointer
- * to the _IMAGELIST data structure. But MS does not want us to know
+ * to the _IMAGELIST data structure. But M$ does not want us to know
  * anything about its contents. Applications just see a pointer to
- * a struct without any content. It's just to keep compatibility.
+ * an empty structure. It's just to keep compatibility.
  */
 #define __WINE_IMAGELIST_C
  
@@ -25,36 +50,51 @@
  */
 #define __GET_ICON_INFO_HACK__ 
  
-#include <stdlib.h>
 #include "windows.h"
 #include "imagelist.h"
 #include "commctrl.h"
 #include "debug.h"
+#include "heap.h"
 
 #ifdef __GET_ICON_INFO_HACK__
 #include "bitmap.h"
 #endif
 
 
+#define _MAX(a,b) (((a)>(b))?(a):(b))
+#define _MIN(a,b) (((a)>(b))?(b):(a))
+
+#define MAX_OVERLAYIMAGE 15
+
+
+/*
+ * internal ImageList data used for dragging
+ */
+static HIMAGELIST himlInternalDrag = NULL;
+static INT32      nInternalDragHotspotX = 0;
+static INT32      nInternalDragHotspotY = 0;
+static HCURSOR32  hcurInternal = 0;
+
+
 static void
-IMAGELIST_GrowBitmaps (HIMAGELIST himl, INT32 nImageCount)
+IMAGELIST_InternalGrowBitmaps (HIMAGELIST himl, INT32 nImageCount)
 {
-    HDC32     hdcScreen, hdcImageList, hdcBitmap;
+    HDC32     hdcImageList, hdcBitmap;
     HBITMAP32 hbmNewBitmap;
-    INT32     nNewWidth;
+    INT32     nNewWidth, nNewCount;
 
-    /* no space left for new Image(s) ==> create new Bitmap(s) */
-    printf ("IMAGELIST_GrowBitmaps: Create grown bitmaps!!\n");
+    TRACE(imagelist, "Create grown bitmaps!\n");
 
-    nNewWidth = (himl->cCurImage + nImageCount + himl->cGrow) * himl->cx;
+    nNewCount = himl->cCurImage + nImageCount + himl->cGrow;
+    nNewWidth = nNewCount * himl->cx;
 
-    hdcScreen = GetDC32 (GetDesktopWindow32 ());
-    hdcImageList = CreateCompatibleDC32 (hdcScreen);
-    hdcBitmap = CreateCompatibleDC32 (hdcScreen);
-    ReleaseDC32 (hdcScreen, GetDesktopWindow32 ());
+    hdcImageList = CreateCompatibleDC32 (0);
+    hdcBitmap = CreateCompatibleDC32 (0);
 
     hbmNewBitmap =
-        CreateCompatibleBitmap32 (hdcImageList, nNewWidth, himl->cy);
+        CreateBitmap32 (nNewWidth, himl->cy, 1, himl->uBitsPixel, NULL);
+    if (hbmNewBitmap == 0)
+        ERR (imagelist, "Error creating new image bitmap!\n");
 
     SelectObject32 (hdcImageList, himl->hbmImage);
     SelectObject32 (hdcBitmap, hbmNewBitmap);
@@ -66,7 +106,11 @@
 
     if (himl->hbmMask) {
         hbmNewBitmap = 
-            CreateCompatibleBitmap32 (hdcImageList, nNewWidth, himl->cy); 
+            CreateBitmap32 (nNewWidth, himl->cy, 1, 1, NULL);
+
+        if (hbmNewBitmap == 0)
+            ERR (imagelist, "Error creating new mask bitmap!");
+
         SelectObject32 (hdcImageList, himl->hbmMask);
         SelectObject32 (hdcBitmap, hbmNewBitmap);
         BitBlt32 (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, himl->cy,
@@ -75,13 +119,57 @@
         himl->hbmMask = hbmNewBitmap;
     }
 
+    himl->cMaxImage = nNewCount;
+
     DeleteDC32 (hdcImageList);
     DeleteDC32 (hdcBitmap);
 }
 
 
-INT32 WINAPI
-ImageList_Add (HIMAGELIST himl, HBITMAP32 hbmImage, HBITMAP32 hbmMask)
+static void
+IMAGELIST_InternalDrawMask (HIMAGELIST himl, INT32 i, HDC32 hdc,
+                            INT32 x, INT32 y)
+{
+    HDC32 hdcImageList;
+
+    if (himl->hbmMask)
+    {
+        hdcImageList = CreateCompatibleDC32 (0);
+        SelectObject32 (hdcImageList, himl->hbmMask);
+        BitBlt32 (hdc, x, y, himl->cx, himl->cy, hdcImageList,
+                  himl->cx * i, 0, SRCCOPY);
+        DeleteDC32 (hdcImageList);
+    }  
+}
+
+
+static void
+IMAGELIST_InternalDrawImage (HIMAGELIST himl, INT32 i, HDC32 hdc,
+                             INT32 x, INT32 y, UINT32 fStyle)
+{
+    HDC32 hdcImageList;
+
+    hdcImageList = CreateCompatibleDC32 (0);
+    SelectObject32 (hdcImageList, himl->hbmImage);
+    BitBlt32 (hdc, x, y, himl->cx, himl->cy, hdcImageList,
+              himl->cx * i, 0, SRCCOPY);
+    DeleteDC32 (hdcImageList);
+}
+
+
+/*************************************************************************
+ *	 		 ImageList_Add   [COMCTL32.39]
+ *
+ *  Add an image (and a mask) to an image list.
+ *
+ *  RETURNS
+ *    Index of the first image that was added, -1 if an error occurred.
+ */
+
+INT32 WINAPI ImageList_Add (
+	HIMAGELIST himl,     /* imagelist handle */
+	HBITMAP32 hbmImage,  /* image bitmap */
+	HBITMAP32 hbmMask)   /* mask bitmap */
 {
     HDC32    hdcImageList, hdcImage, hdcMask;
     INT32    nFirstIndex, nImageCount;
@@ -89,11 +177,14 @@
     COLORREF clrColor;
     BITMAP32 bmp;
 
+    if (himl == NULL) return (-1);
+
     GetObject32A (hbmImage, sizeof(BITMAP32), (LPVOID)&bmp);
     nImageCount = bmp.bmWidth / himl->cx;
 
     if (himl->cCurImage + nImageCount >= himl->cMaxImage)
-        IMAGELIST_GrowBitmaps (himl, nImageCount);
+        IMAGELIST_InternalGrowBitmaps (himl, nImageCount);
+//        ImageList_SetImageCount (himl, himl->cCurImage + nImageCount);
 
     hdcImageList = CreateCompatibleDC32 (0);
     hdcImage = CreateCompatibleDC32 (0);
@@ -104,22 +195,28 @@
     BitBlt32 (hdcImageList, himl->cCurImage * himl->cx, 0,
               bmp.bmWidth, himl->cy, hdcImage, 0, 0, SRCCOPY);
           
-    if (himl->hbmMask) {
-        if (hbmMask) {
+    if (himl->hbmMask)
+    {
+        if (hbmMask)
+        {
             SelectObject32 (hdcImageList, himl->hbmMask);
             SelectObject32 (hdcImage, hbmMask);
             BitBlt32 (hdcImageList, himl->cCurImage * himl->cx, 0,
                       bmp.bmWidth, himl->cy, hdcImage, 0, 0, SRCCOPY);
         }
-        else {
+        else
+        {
             /* create mask from the imagelist's background color */
             hdcMask = CreateCompatibleDC32 (0);
             SelectObject32 (hdcMask, himl->hbmMask);
             nStartX = himl->cCurImage * himl->cx;
-            for (nRunY = 0; nRunY < himl->cy; nRunY++) {
-                for (nRunX = 0; nRunX < bmp.bmWidth; nRunX++) {
-                    clrColor = GetPixel32 (hdcImage, nRunX, nRunY);
-                    if (clrColor == himl->clrBk) {
+            for (nRunY = 0; nRunY < himl->cy; nRunY++)
+            {
+                for (nRunX = 0; nRunX < bmp.bmWidth; nRunX++)
+                {
+                    clrColor = GetPixel32 (hdcImageList, nStartX + nRunX, nRunY);
+                    if (clrColor == himl->clrBk)
+                    {
                         SetPixel32 (hdcImageList, nStartX + nRunX, nRunY, 
                                     RGB(0, 0, 0));
                         SetPixel32 (hdcMask, nStartX + nRunX, nRunY, 
@@ -144,20 +241,34 @@
 }
 
 
-INT32 WINAPI
-ImageList_AddMasked (HIMAGELIST himl, HBITMAP32 hbmImage, COLORREF crMask)
+/*************************************************************************
+ *	 		 ImageList_AddMasked   [COMCTL32.41]
+ *
+ *  Adds an image to an imagelist and creates a mask from the given
+ *  mask color.
+ *
+ *  RETURNS
+ *    Index of the first image that was added, -1 if an error occurred.
+ */
+
+INT32 WINAPI ImageList_AddMasked (
+	HIMAGELIST himl,    /* image list handle */
+	HBITMAP32 hbmImage, /* bitmap handle */
+	COLORREF clrMask)   /* backround color of the image */
 {
     HDC32    hdcImageList, hdcImage, hdcMask;
     INT32    nIndex, nImageCount;
     BITMAP32 bmp;
     INT32    nStartX, nRunX, nRunY;
-    COLORREF crColor;
+    COLORREF clrColor;
+
+    if (himl == NULL) return (-1);
 
     GetObject32A (hbmImage, sizeof(BITMAP32), &bmp);
     nImageCount = bmp.bmWidth / himl->cx;
 
     if (himl->cCurImage + nImageCount >= himl->cMaxImage)
-        IMAGELIST_GrowBitmaps (himl, nImageCount);
+        IMAGELIST_InternalGrowBitmaps (himl, nImageCount);
 
     nIndex = himl->cCurImage;
     himl->cCurImage += nImageCount;
@@ -167,18 +278,22 @@
 
     SelectObject32 (hdcImageList, himl->hbmImage);
     SelectObject32 (hdcImage, hbmImage);
-    BitBlt32 (hdcImageList, nIndex * himl->cx, 0,
-              bmp.bmWidth, himl->cy, hdcImage, 0, 0, SRCCOPY);
+    BitBlt32 (hdcImageList, nIndex * himl->cx, 0, bmp.bmWidth, himl->cy,
+              hdcImage, 0, 0, SRCCOPY);
 
-    if (himl->hbmMask) {
+    if (himl->hbmMask)
+    {
         /* create Mask */
         hdcMask = CreateCompatibleDC32 (0);
         SelectObject32 (hdcMask, himl->hbmMask);
         nStartX = nIndex * himl->cx;
-        for (nRunY = 0; nRunY < himl->cy; nRunY++) {
-            for (nRunX = 0; nRunX < bmp.bmWidth; nRunX++) {
-                crColor = GetPixel32 (hdcImage, nRunX, nRunY);
-                if (crColor == crMask) {
+        for (nRunY = 0; nRunY < himl->cy; nRunY++)
+        {
+            for (nRunX = 0; nRunX < bmp.bmWidth; nRunX++)
+            {
+                clrColor = GetPixel32 (hdcImageList, nStartX + nRunX, nRunY);
+                if (clrColor == clrMask)
+                {
                     SetPixel32 (hdcImageList, nStartX + nRunX, nRunY,
                                 RGB(0, 0, 0));
                     SetPixel32 (hdcMask, nStartX + nRunX, nRunY,
@@ -198,102 +313,581 @@
 }
 
 
-HIMAGELIST WINAPI
-ImageList_Create (INT32 cx, INT32 cy, UINT32 flags, INT32 cInitial, INT32 cGrow)
+/*************************************************************************
+ *	 		 ImageList_BeginDrag   [COMCTL32.42]
+ *
+ * Creates a temporary imagelist with an image in it, which will be used
+ * as a drag image.
+ */
+
+BOOL32 WINAPI ImageList_BeginDrag (
+	HIMAGELIST himlTrack, /* Handle of the source imagelist */
+	INT32 iTrack,         /* Index of the image in the source imagelist */
+	INT32 dxHotspot,      /* Position of the hot spot of the */
+	INT32 dyHotspot)      /* drag image */
+{
+    HDC32 hdcSrc, hdcDst;
+
+    FIXME(imagelist, "ImageList_BeginDrag: partially implemented!\n");
+
+    if (himlTrack == NULL) return (FALSE);
+    if (himlInternalDrag)
+        ImageList_EndDrag ();
+
+    himlInternalDrag = ImageList_Create (himlTrack->cx, himlTrack->cy,
+                                         himlTrack->flags, 1, 1);
+    if (himlInternalDrag == NULL)
+    {
+        ERR(imagelist, "Error creating drag image list!\n");
+        return (FALSE);
+    }
+
+    nInternalDragHotspotX = dxHotspot;
+    nInternalDragHotspotY = dyHotspot;
+
+    hdcSrc = CreateCompatibleDC32 (0);
+    hdcDst = CreateCompatibleDC32 (0);
+
+    /* copy image */
+    SelectObject32 (hdcSrc, himlTrack->hbmImage);
+    SelectObject32 (hdcDst, himlInternalDrag->hbmImage);
+    StretchBlt32 (hdcDst, 0, 0, himlInternalDrag->cx, himlInternalDrag->cy, hdcSrc,
+                  iTrack * himlTrack->cx, 0, himlTrack->cx, himlTrack->cy, SRCCOPY);
+
+    /* copy mask */
+    SelectObject32 (hdcSrc, himlTrack->hbmMask);
+    SelectObject32 (hdcDst, himlInternalDrag->hbmMask);
+    StretchBlt32 (hdcDst, 0, 0, himlInternalDrag->cx, himlInternalDrag->cy, hdcSrc,
+                  iTrack * himlTrack->cx, 0, himlTrack->cx, himlTrack->cy, SRCCOPY);
+
+    DeleteDC32 (hdcSrc);
+    DeleteDC32 (hdcDst);
+
+    himlInternalDrag->cCurImage = 1;
+
+    return (TRUE);
+}
+
+
+/*************************************************************************
+ *	 		 ImageList_Copy   [COMCTL32.43]
+ *
+ *  Copies an image of the source imagelist to an image of the 
+ *  destination imagelist. Images can be copied or swapped.
+ *  Copying from one imagelist to another is allowed, in contrary to
+ *  M$'s original implementation. They just allow copying or swapping
+ *  within one imagelist (himlDst and himlSrc must be the same).
+ */
+
+BOOL32 WINAPI ImageList_Copy (
+	HIMAGELIST himlDst,  /* Handle of the destination imagelist */
+	INT32 iDst,          /* Index of the destination image */
+	HIMAGELIST himlSrc,  /* Handel od the source imagelist */
+	INT32 iSrc,          /* Index of the source image */
+	INT32 uFlags)        /* Flags used for the copy operation */
+{
+    HDC32 hdcSrc, hdcDst;    
+
+    TRACE(imagelist, "iDst=%d  iSrc=%d\n", iDst, iSrc);
+
+    if ((himlSrc == NULL) || (himlDst == NULL)) return (FALSE);
+    if ((iDst < 0) || (iDst >= himlDst->cCurImage)) return (FALSE);
+    if ((iSrc < 0) || (iSrc >= himlSrc->cCurImage)) return (FALSE);
+
+    hdcSrc = CreateCompatibleDC32 (0);
+    if (himlDst == himlSrc)
+        hdcDst = hdcSrc;
+    else
+        hdcDst = CreateCompatibleDC32 (0);
+
+    if (uFlags & ILCF_SWAP)
+    {
+        /* swap */
+        HBITMAP32 hbmTempImage, hbmTempMask;
+
+        /* create temporary bitmaps */
+        hbmTempImage = CreateBitmap32 (himlSrc->cx, himlSrc->cy, 1,
+                                       himlSrc->uBitsPixel, NULL);
+        hbmTempMask = CreateBitmap32 (himlSrc->cx, himlSrc->cy, 1, 1, NULL);
+
+        /* copy (and stretch) destination to temporary bitmaps.(save) */
+        /* image */
+        SelectObject32 (hdcSrc, himlDst->hbmImage);
+        SelectObject32 (hdcDst, hbmTempImage);
+        StretchBlt32 (hdcDst, 0, 0, himlSrc->cx, himlSrc->cy,
+                      hdcSrc, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
+                      SRCCOPY);
+        /* mask */
+        SelectObject32 (hdcSrc, himlDst->hbmMask);
+        SelectObject32 (hdcDst, hbmTempMask);
+        StretchBlt32 (hdcDst, 0, 0, himlSrc->cx, himlSrc->cy,
+                      hdcSrc, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
+                      SRCCOPY);
+
+        /* copy (and stretch) source to destination */
+        /* image */
+        SelectObject32 (hdcSrc, himlSrc->hbmImage);
+        SelectObject32 (hdcDst, himlDst->hbmImage);
+        StretchBlt32 (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
+                      hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+                      SRCCOPY);
+        /* mask */
+        SelectObject32 (hdcSrc, himlSrc->hbmMask);
+        SelectObject32 (hdcDst, himlDst->hbmMask);
+        StretchBlt32 (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
+                      hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+                      SRCCOPY);
+
+        /* copy (without stretching) temporary bitmaps to source (restore) */
+        /* image */
+        SelectObject32 (hdcSrc, hbmTempImage);
+        SelectObject32 (hdcDst, himlSrc->hbmImage);
+        BitBlt32 (hdcDst, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+                  hdcSrc, 0, 0, SRCCOPY);
+        /* mask */
+        SelectObject32 (hdcSrc, hbmTempMask);
+        SelectObject32 (hdcDst, himlSrc->hbmMask);
+        BitBlt32 (hdcDst, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+                  hdcSrc, 0, 0, SRCCOPY);
+
+        /* delete temporary bitmaps */
+        DeleteObject32 (hbmTempMask);
+        DeleteObject32 (hbmTempImage);
+    }
+    else
+    {
+        /* copy image */
+        SelectObject32 (hdcSrc, himlSrc->hbmImage);
+        if (himlSrc == himlDst)
+            hdcDst = hdcSrc;
+        else
+            SelectObject32 (hdcDst, himlDst->hbmImage);
+        StretchBlt32 (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
+                      hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+                      SRCCOPY);
+
+        /* copy mask */
+        SelectObject32 (hdcSrc, himlSrc->hbmMask);
+        if (himlSrc == himlDst)
+            hdcDst = hdcSrc;
+        else
+            SelectObject32 (hdcDst, himlDst->hbmMask);
+        StretchBlt32 (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
+                      hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+                      SRCCOPY);
+    }
+
+    DeleteDC32 (hdcSrc);
+    if (himlSrc != himlDst)
+        DeleteDC32 (hdcDst);
+
+    return (TRUE);
+}
+
+
+/*************************************************************************
+ *	 		 ImageList_Create   [COMCTL32.44]
+ *
+ *  Creates an imagelist of the given image size and number of images.
+ *
+ *  RETURNS
+ *    Handle of the created image list, 0 if an error occurred.
+ */
+
+HIMAGELIST WINAPI ImageList_Create (
+	INT32 cx,        /* Width of an image */
+	INT32 cy,        /* Height of an image */
+	UINT32 flags,    /* Flags for imagelist creation */
+	INT32 cInitial,  /* Initial number of images in the imaglist */
+	INT32 cGrow)     /* Number of images that is added to the */
+	                 /* imagelist when it grows */
 {
     HIMAGELIST himl;
-    HANDLE32 hHeap;
-    HDC32 hdcDesktop;
-    HWND32 hwndDesktop;
+    HDC32      hdc;
+    INT32      nCount;
 
-    hHeap = GetProcessHeap ();
-    himl = (HIMAGELIST) HeapAlloc (hHeap, 0, sizeof(struct _IMAGELIST));
+    himl = (HIMAGELIST)LocalAlloc32 (LMEM_FIXED | LMEM_ZEROINIT,
+                                     sizeof(struct _IMAGELIST));
     if (!himl)
-        return (0);
-    himl->hHeap = hHeap;
+        return (NULL);
     himl->cx = cx;
     himl->cy = cy;
     himl->flags = flags;
     himl->cMaxImage = cInitial + cGrow;
+    himl->cInitial = cInitial;
     himl->cGrow = cGrow;
     himl->cCurImage = 0;
-    himl->clrBk = CLR_NONE;  /* ??? or CLR_DEFAULT */
-    himl->nOvlIdx[0] = -1;
-    himl->nOvlIdx[1] = -1;
-    himl->nOvlIdx[2] = -1;
-    himl->nOvlIdx[3] = -1;
+    himl->clrBk = CLR_NONE;
 
-    hwndDesktop = GetDesktopWindow32();
-    hdcDesktop = GetDC32 (hwndDesktop);
-    
+    /* initialize overlay mask indices */
+    for (nCount = 0; nCount <= MAX_OVERLAYIMAGE; nCount++)
+        himl->nOvlIdx[nCount] = -1;
+
+    hdc = CreateCompatibleDC32 (0);
+    himl->uBitsPixel = (UINT32)GetDeviceCaps32 (hdc, BITSPIXEL);
+    DeleteDC32 (hdc);
+
+    TRACE(imagelist, "Image: %d Bits per Pixel\n", himl->uBitsPixel);
+
     himl->hbmImage =
-        CreateCompatibleBitmap32 (hdcDesktop, himl->cx * himl->cMaxImage, 
-                                  himl->cy);
+        CreateBitmap32 (himl->cx * himl->cMaxImage, himl->cy,
+                        1, himl->uBitsPixel, NULL);
+    if (himl->hbmImage == 0)
+    {
+        ERR(imagelist, "Error creating image bitmap!\n");
+        return (0);
+    }
+
     if (himl->flags & ILC_MASK)
+    {
         himl->hbmMask = 
-            CreateCompatibleBitmap32 (hdcDesktop, himl->cx * himl->cMaxImage, 
-                                      himl->cy); 
+            CreateBitmap32 (himl->cx * himl->cMaxImage, himl->cy, 1, 1, NULL);
+        if (himl->hbmMask == 0)
+        {
+            ERR(imagelist, "Error creating mask bitmap!\n");
+            if (himl->hbmImage)
+                DeleteObject32 (himl->hbmImage);
+            return (0);
+        }
+    }
     else
         himl->hbmMask = 0;
 
-    ReleaseDC32 (hwndDesktop, hdcDesktop);
-    
     return (himl);    
 }
 
 
-BOOL32 WINAPI
-ImageList_Destroy (HIMAGELIST himl)
-{
+/*************************************************************************
+ *	 		 ImageList_Destroy   [COMCTL32.45]
+ *
+ *  Destroy the given imagelist.
+ *
+ *  RETURNS
+ *    TRUE if the image list was destryed, FALSE if an error occurred.
+ */
+
+BOOL32 WINAPI ImageList_Destroy (
+	HIMAGELIST himl)  /* Handle of the imagelist */
+{ 
+    if (himl == NULL) return (FALSE);
+
     if (himl->hbmImage)
         DeleteObject32 (himl->hbmImage);
     if (himl->hbmMask)
         DeleteObject32 (himl->hbmMask);
         
-    HeapFree (himl->hHeap, 0, (LPVOID)himl);
+    LocalFree32 ((HLOCAL32)himl);
     return (TRUE);
 }
 
 
+/*************************************************************************
+ *	 		 ImageList_DragEnter   [COMCTL32.46]
+ *
+ *  FIXME
+ *    This is still an empty stub.
+ */
+
+BOOL32 WINAPI ImageList_DragEnter (
+	HWND32 hwndLock, 
+	INT32 x, 
+	INT32 y)
+{
+    FIXME (imagelist, "empty stub!\n");
+
+    hcurInternal = GetCursor32 ();
+
+
+    ShowCursor32 (TRUE);
+
+    return (FALSE);
+}
+
+
+/*************************************************************************
+ *	 		 ImageList_DragLeave   [COMCTL32.47]
+ */
+
+BOOL32 WINAPI ImageList_DragLeave (
+	HWND32 hwndLock)
+{
+    FIXME (imagelist, "empty stub!\n");
+
+
+
+    SetCursor32 (hcurInternal);
+    hcurInternal = 0;
+ 
+    ShowCursor32 (FALSE);
+
+    return (FALSE);
+}
+
+
+/*************************************************************************
+ *	 		 ImageList_DragMove   [COMCTL32.48]
+ */
+
+BOOL32 WINAPI ImageList_DragMove (
+	INT32 x,
+	INT32 y)
+{
+    FIXME (imagelist, "empty stub!\n");
+
+//    if (hcurInternal)
+//        SetCursor32 (hcurInternal);
+//    ImageList_Draw (himlInternalDrag, 0, x, y, 0);
+
+
+    return (FALSE);
+}
+
+
+/*************************************************************************
+ *	 		 ImageList_DragShowNolock   [COMCTL32.49]
+ */
 
 BOOL32 WINAPI
-ImageList_Draw (HIMAGELIST himl, INT32 i, HDC32 hdc, 
-                INT32 x, INT32 y, UINT32 fStyle)
+ImageList_DragShowNolock (BOOL32 bShow)
 {
-    HDC32     hdcImageList,hdcMask;
-    HBITMAP32 hbmMask;
-    HBRUSH32 hBrush, hOldBrush;
-    INT32 nOvlIdx;
+    FIXME (imagelist, "empty stub!\n");
+
+    return (FALSE);
+}
+
+
+/*************************************************************************
+ *	 		 ImageList_Draw   [COMCTL32.50]
+ */
+
+BOOL32 WINAPI ImageList_Draw (
+	HIMAGELIST himl,
+	INT32 i,
+	HDC32 hdc, 
+	INT32 x,
+	INT32 y,
+	UINT32 fStyle)
+{
+    IMAGELISTDRAWPARAMS imldp;
+
+    imldp.cbSize  = sizeof(IMAGELISTDRAWPARAMS);
+    imldp.himl    = himl;
+    imldp.i       = i;
+    imldp.hdcDst  = hdc,
+    imldp.x       = x;
+    imldp.y       = y;
+    imldp.cx      = 0;
+    imldp.cy      = 0;
+    imldp.xBitmap = 0;
+    imldp.yBitmap = 0;
+    imldp.rgbBk   = CLR_DEFAULT;
+    imldp.rgbFg   = CLR_DEFAULT;
+    imldp.fStyle  = fStyle;
+    imldp.dwRop   = 0;
+
+    return (ImageList_DrawIndirect (&imldp));
+}
+
+
+/*************************************************************************
+ *	 		 ImageList_DrawEx   [COMCTL32.51]
+ */
+
+BOOL32 WINAPI ImageList_DrawEx (
+	HIMAGELIST himl,
+	INT32 i,
+	HDC32 hdc,
+	INT32 x,
+	INT32 y,
+	INT32 xOffs,
+	INT32 yOffs,
+	COLORREF rgbBk,
+	COLORREF rgbFg,
+	UINT32 fStyle)
+{
+    IMAGELISTDRAWPARAMS imldp;
+
+    imldp.cbSize  = sizeof(IMAGELISTDRAWPARAMS);
+    imldp.himl    = himl;
+    imldp.i       = i;
+    imldp.hdcDst  = hdc,
+    imldp.x       = x;
+    imldp.y       = y;
+    imldp.cx      = xOffs;
+    imldp.cy      = yOffs;
+    imldp.xBitmap = 0;
+    imldp.yBitmap = 0;
+    imldp.rgbBk   = rgbBk;
+    imldp.rgbFg   = rgbFg;
+    imldp.fStyle  = fStyle;
+    imldp.dwRop   = 0;
+
+    return (ImageList_DrawIndirect (&imldp));
+}
+
+
+/*************************************************************************
+ *	 		 ImageList_Drawindirect   [COMCTL32.52]
+ */
+
+BOOL32 WINAPI ImageList_DrawIndirect (
+	IMAGELISTDRAWPARAMS *pimldp)
+{
+    HIMAGELIST himlLocal;
+    HDC32      hdcImageList,hdcMask, hdcTempImage;
+    HBITMAP32  hbmMask, hbmTempImage;
+    HBRUSH32   hBrush, hOldBrush;
+    INT32      nOvlIdx, nStartX, nRunX, nRunY;
+    COLORREF   clrBlend, clrImage;
+    BOOL32     bImage;       /* draw image ? */
+    BOOL32     bImageTrans;  /* draw image transparent ? */
+    BOOL32     bMask;        /* draw mask ? */
+    BOOL32     bMaskTrans;   /* draw mask transparent ? */
+    BOOL32     bBlend = FALSE;
+
+    if (pimldp == NULL) return (FALSE);
+    if (pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS)) return (FALSE);
+
+    himlLocal = pimldp->himl;
+    
+    /* ILD_NORMAL state */
+    bImage      = TRUE;
+    bImageTrans = FALSE;
+    bMask       = FALSE;
+    bMaskTrans  = FALSE;
+    if ((himlLocal->clrBk == CLR_NONE) && (himlLocal->hbmMask))
+    {
+        bImageTrans = TRUE;
+        bMask = TRUE;
+        bMaskTrans = TRUE;
+    }
+    
+    /* ILD_IMAGE state (changes) */
+    if (pimldp->fStyle & ILD_IMAGE)
+    {
+        bMask = FALSE;
+        bImage = TRUE;
+        bImageTrans = FALSE;
+    }
+    
+    /* ILD_MASK state (changes) */
+    if ((pimldp->fStyle & ILD_MASK) && (himlLocal->hbmMask))
+    {
+        bMask  = TRUE;
+        bMaskTrans = FALSE;
+        bImage = FALSE;
+    }
+    if ((pimldp->fStyle & ILD_TRANSPARENT) && (himlLocal->hbmMask))
+        bMaskTrans = TRUE;
+    if ((himlLocal->clrBk == CLR_NONE) && (himlLocal->hbmMask))
+        bMaskTrans = TRUE;
+
+
+    if ((pimldp->fStyle & ILD_BLEND25) || (pimldp->fStyle & ILD_BLEND50))
+        bBlend = TRUE;
 
     hdcImageList = CreateCompatibleDC32 (0);
-  
-    if (himl->hbmMask) {  
-        SelectObject32 (hdcImageList, himl->hbmMask);
-        BitBlt32 (hdc, x, y, himl->cx, himl->cy, hdcImageList,
-                  himl->cx * i, 0, SRCAND);  
-    }  
 
-    SelectObject32 (hdcImageList, himl->hbmImage);
 
-    BitBlt32 (hdc, x, y, himl->cx, himl->cy, hdcImageList,
-              himl->cx * i, 0, SRCPAINT);
+    if (bMask)
+    {
+        /* draw the mask */
+        SelectObject32 (hdcImageList, himlLocal->hbmMask);
+        
+        BitBlt32 (pimldp->hdcDst, pimldp->x, pimldp->y, pimldp->himl->cx,
+                  pimldp->himl->cy, hdcImageList,
+                  pimldp->himl->cx * pimldp->i, 0,
+                  bMaskTrans ? SRCAND : SRCCOPY);
+    }
+    if (bImage)
+    {
+        /* draw the image */
+        SelectObject32 (hdcImageList, himlLocal->hbmImage);
+        if (!bBlend)
+        {
+            if (!bImageTrans)
+            {
+                hBrush = CreateSolidBrush32 (himlLocal->clrBk);
+                hOldBrush = SelectObject32 (pimldp->hdcDst, hBrush);
+                PatBlt32 (pimldp->hdcDst, pimldp->x, pimldp->y,
+                          himlLocal->cx, himlLocal->cy, PATCOPY);
+                DeleteObject32 (SelectObject32 (pimldp->hdcDst, hOldBrush));
+            }
+            BitBlt32 (pimldp->hdcDst, pimldp->x, pimldp->y, himlLocal->cx,
+                      himlLocal->cy, hdcImageList, himlLocal->cx * pimldp->i, 0,
+                      SRCPAINT);
+        }
+        else
+        {
+            if (pimldp->rgbFg == CLR_DEFAULT)
+                clrBlend = (GetSysColor32 (COLOR_HIGHLIGHT) & 0xFEFEFEFE)>>1;
+            else
+                clrBlend = (pimldp->rgbFg & 0xFEFEFEFE)>>1;
+
+            hdcTempImage = CreateCompatibleDC32 (0);
+            hbmTempImage = CreateBitmap32 (himlLocal->cx, himlLocal->cy,
+                                           1, himlLocal->uBitsPixel, NULL);
+            SelectObject32 (hdcTempImage, hbmTempImage);
+            PatBlt32 (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, BLACKNESS);
+
+#if 0
+            if (bImageTrans)
+            {
+#endif
+                hdcMask = CreateCompatibleDC32 (0);           
+                SelectObject32 (hdcMask, himlLocal->hbmMask);
+                nStartX = pimldp->i * himlLocal->cx;
+
+                for (nRunY = 0; nRunY < himlLocal->cy; nRunY++)
+                {
+                    for (nRunX = 0; nRunX < himlLocal->cx; nRunX++)
+                    {
+                        if (GetPixel32 (hdcMask, nStartX + nRunX, nRunY) == 0)
+                        {
+                            clrImage = GetPixel32 (hdcImageList, nStartX + nRunX, nRunY);
+                            clrImage = ((clrImage & 0xFEFEFEFE)>>1) + clrBlend;
+
+                            SetPixel32 (hdcTempImage, nRunX, nRunY, clrImage);
+                        }
+                    }
+                }
+
+                DeleteDC32 (hdcMask);
+                BitBlt32 (pimldp->hdcDst, pimldp->x, pimldp->y, himlLocal->cx,
+                          himlLocal->cy, hdcTempImage, 0, 0, SRCPAINT);
+#if 0
+            }
+            else
+            {
+
+            }
+#endif
+
+            DeleteObject32 (hbmTempImage);
+            DeleteDC32 (hdcTempImage);
+        }
+    }   
 
     /* Draw overlay image */
-    if (fStyle & 0x0700) {
-        nOvlIdx = (fStyle & 0x0700) >> 8;
-        if ((nOvlIdx >= 1) && (nOvlIdx <= 4)) {
-            nOvlIdx = himl->nOvlIdx[nOvlIdx - 1];
-            if ((nOvlIdx >= 0) && (nOvlIdx <= himl->cCurImage)) {
-
-                if (himl->hbmMask) {  
-                    SelectObject32 (hdcImageList, himl->hbmMask);
-                    BitBlt32 (hdc, x, y, himl->cx, himl->cy, hdcImageList,
-                              himl->cx * nOvlIdx, 0, SRCAND);  
+    if (pimldp->fStyle & 0x0700)
+    {
+        nOvlIdx = (pimldp->fStyle & 0x0700) >> 8;
+        if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE))
+        {
+            nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1];
+            if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage))
+            {
+                if (pimldp->himl->hbmMask)
+                {  
+                    SelectObject32 (hdcImageList, pimldp->himl->hbmMask);
+                    BitBlt32 (pimldp->hdcDst, pimldp->x, pimldp->y, 
+                              pimldp->himl->cx, pimldp->himl->cy, hdcImageList,
+                              pimldp->himl->cx * nOvlIdx, 0, SRCAND);  
                 }  
-                SelectObject32 (hdcImageList, himl->hbmImage);
-                BitBlt32 (hdc, x, y, himl->cx, himl->cy, hdcImageList,
-                          himl->cx * nOvlIdx, 0, SRCPAINT);
-
+                SelectObject32 (hdcImageList, pimldp->himl->hbmImage);
+                BitBlt32 (pimldp->hdcDst, pimldp->x, pimldp->y, 
+                          pimldp->himl->cx, pimldp->himl->cy, hdcImageList,
+                          pimldp->himl->cx * nOvlIdx, 0, SRCPAINT);
             }
         }
     }
@@ -304,42 +898,166 @@
 }
 
 
+/*************************************************************************
+ *	 		 ImageList_Duplicate   [COMCTL32.53]
+ *
+ *  Duplicates an image list.
+ *
+ *  RETURNS
+ *    Handle of duplicate image list, 0 if an error occurred.
+ */
 
-COLORREF WINAPI
-ImageList_GetBkColor (HIMAGELIST himl)
+HIMAGELIST WINAPI ImageList_Duplicate (
+	HIMAGELIST himlSrc)
+{
+    HIMAGELIST himlDst;
+    HDC32 hdcSrc, hdcDst;
+
+    if (himlSrc == NULL) {
+        ERR (imagelist, "Invalid image list handle!\n");
+        return (NULL);
+    }
+
+    himlDst = ImageList_Create (himlSrc->cx, himlSrc->cy, himlSrc->flags,
+                                himlSrc->cInitial, himlSrc->cGrow);
+
+    if (himlDst)
+    {
+        hdcSrc = CreateCompatibleDC32 (0);
+        hdcDst = CreateCompatibleDC32 (0);
+        SelectObject32 (hdcSrc, himlSrc->hbmImage);
+        SelectObject32 (hdcDst, himlDst->hbmImage);
+        BitBlt32 (hdcDst, 0, 0, himlSrc->cCurImage * himlSrc->cx, himlSrc->cy,
+                  hdcSrc, 0, 0, SRCCOPY);
+
+        if (himlDst->hbmMask)
+        {
+            SelectObject32 (hdcSrc, himlSrc->hbmMask);
+            SelectObject32 (hdcDst, himlDst->hbmMask);
+            BitBlt32 (hdcDst, 0, 0, himlSrc->cCurImage * himlSrc->cx,
+                      himlSrc->cy, hdcSrc, 0, 0, SRCCOPY);
+        }
+
+        DeleteDC32 (hdcDst);
+        DeleteDC32 (hdcSrc);
+    }
+
+    return (himlDst);
+}
+
+
+BOOL32 WINAPI ImageList_EndDrag (VOID)
+{
+    FIXME (imagelist, "partially implemented!\n");
+
+    if (himlInternalDrag)
+    {
+
+        ImageList_Destroy (himlInternalDrag);
+        himlInternalDrag = NULL;
+
+        nInternalDragHotspotX = 0;
+        nInternalDragHotspotY = 0;
+
+    }
+
+    return (TRUE);
+}
+
+
+COLORREF WINAPI ImageList_GetBkColor (
+	HIMAGELIST himl)
 {
     return (himl->clrBk);
 }
 
 
-HICON32 WINAPI
-ImageList_GetIcon (HIMAGELIST himl, INT32 i, UINT32 flags)
+HIMAGELIST WINAPI ImageList_GetDragImage (
+	POINT32 *ppt,
+	POINT32 *pptHotspot)
 {
+    FIXME (imagelist, "partially imlemented!\n");
 
+    if (himlInternalDrag)
+        return (himlInternalDrag);
 
-    return (0);
+    return (NULL);
 }
 
 
-BOOL32 WINAPI
-ImageList_GetIconSize (HIMAGELIST himl, INT32 *cx, INT32 *cy)
+HICON32 WINAPI ImageList_GetIcon (
+	HIMAGELIST himl, 
+	INT32 i, 
+	UINT32 fStyle)
 {
-    *cx = himl->cx;
-    *cy = himl->cy;
+    ICONINFO ii;
+    HICON32  hIcon;
+    HDC32    hdc;
+    INT32    nWidth, nHeight;
+
+    nWidth = GetSystemMetrics32 (SM_CXICON);
+    nHeight = GetSystemMetrics32 (SM_CYICON);
+
+    ii.fIcon = TRUE;
+    ii.xHotspot = 0;
+    ii.yHotspot = 0;
+    ii.hbmMask  = CreateBitmap32 (nWidth, nHeight, 1, 1, NULL);
+    ii.hbmColor = CreateBitmap32 (nWidth, nHeight,
+                                  1, 1, NULL);
+
+    hdc = CreateCompatibleDC32(0);
+
+    /* draw image*/
+    SelectObject32 (hdc, ii.hbmColor);
+    PatBlt32 (hdc, 0, 0, nWidth, nHeight, BLACKNESS);
+    ImageList_Draw (himl, i, hdc, 0, 0, fStyle | ILD_TRANSPARENT);
+
+    /* draw mask*/
+    SelectObject32 (hdc, ii.hbmMask);
+    PatBlt32 (hdc, 0, 0, nWidth, nHeight, WHITENESS);
+    ImageList_Draw (himl, i, hdc, 0, 0, fStyle | ILD_MASK);
+
+    hIcon = CreateIconIndirect (&ii);    
+
+    DeleteDC32 (hdc);
+    DeleteObject32 (ii.hbmMask);
+    DeleteObject32 (ii.hbmColor);
+
+    return (hIcon);
+}
+
+
+BOOL32 WINAPI ImageList_GetIconSize (
+	HIMAGELIST himl,
+	INT32 *cx,
+	INT32 *cy)
+{
+
+    if (himl == NULL) return (FALSE);
+
+    if (cx)
+        *cx = himl->cx;
+    
+    if (cy)
+        *cy = himl->cy;
     return (TRUE);
 }
 
 
-INT32 WINAPI
-ImageList_GetImageCount (HIMAGELIST himl)
+INT32 WINAPI ImageList_GetImageCount (
+	HIMAGELIST himl)
 {
     return (himl->cCurImage);
 }
 
 
-BOOL32 WINAPI
-ImageList_GetImageInfo (HIMAGELIST himl, INT32 i, IMAGEINFO *pImageInfo)
+BOOL32 WINAPI ImageList_GetImageInfo (
+	HIMAGELIST himl,
+	INT32 i,
+	IMAGEINFO *pImageInfo)
 {
+    if ((himl == NULL) || (pImageInfo == NULL)) return (FALSE);
+
     pImageInfo->hbmImage = himl->hbmImage;
     pImageInfo->hbmMask  = himl->hbmMask;
     
@@ -352,15 +1070,41 @@
 }
 
 
-HIMAGELIST WINAPI
-ImageList_LoadImage32A (HINSTANCE32 hi, LPCSTR lpbmp, INT32 cx, INT32 cGrow, 
-                        COLORREF clrMask, UINT32 uType, UINT32 uFlags)
+/* I don't know if it is really a BOOL32 or something else!!!?? */
+
+BOOL32 WINAPI ImageList_GetImageRect (
+	HIMAGELIST himl,
+	INT32 i,
+	LPRECT32 lpRect)
+{
+    if (himl == NULL) return (FALSE);
+    if ((i < 0) || (i >= himl->cCurImage)) return (FALSE);
+    if (lpRect == NULL) return (FALSE);
+
+    lpRect->left = i * himl->cx;
+    lpRect->top = 0;
+    lpRect->right = lpRect->left + himl->cx;
+    lpRect->bottom = himl->cy;
+
+    return (TRUE);
+}
+
+
+HIMAGELIST WINAPI ImageList_LoadImage32A (
+	HINSTANCE32 hi,
+	LPCSTR lpbmp,
+	INT32 cx,
+	INT32 cGrow, 
+	COLORREF clrMask,
+	UINT32 uType,
+	UINT32 uFlags)
 {
     HIMAGELIST himl = NULL;
     HANDLE32   handle;
     INT32      nImageCount;
 
     handle = LoadImage32A (hi, lpbmp, uType, 0, 0, uFlags);
+    if (!handle) return (NULL);
 
     if (uType == IMAGE_BITMAP) {
         BITMAP32 bmp;
@@ -408,15 +1152,24 @@
 }
 
 
-HIMAGELIST WINAPI
-ImageList_LoadImage32W (HINSTANCE32 hi, LPCWSTR lpbmp, INT32 cx, INT32 cGrow, 
-                        COLORREF clrMask, UINT32 uType, UINT32 uFlags)
+HIMAGELIST WINAPI ImageList_LoadImage32W (
+	HINSTANCE32 hi,
+	LPCWSTR lpbmp,
+	INT32 cx,
+	INT32 cGrow,
+	COLORREF clrMask,
+	UINT32 uType,
+	UINT32 uFlags)
 {
     HIMAGELIST himl = NULL;
     HANDLE32   handle;
     INT32      nImageCount;
 
     handle = LoadImage32W (hi, lpbmp, uType, 0, 0, uFlags);
+    if (!handle) {
+        ERR (imagelist, "Error loading image!\n");
+        return (NULL);
+    }
 
     if (uType == IMAGE_BITMAP) {
         BITMAP32 bmp;
@@ -464,16 +1217,59 @@
 }
 
 
-HIMAGELIST WINAPI
-ImageList_Merge (HIMAGELIST himl1, INT32 i1, HIMAGELIST himl2, INT32 i2,
-                 INT32 xOffs, INT32 yOffs)
+HIMAGELIST WINAPI ImageList_Merge (
+	HIMAGELIST himl1,
+	INT32 i1,
+	HIMAGELIST himl2,
+	INT32 i2,
+	INT32 xOffs,
+	INT32 yOffs)
 {
     HIMAGELIST himlDst = NULL;
     HDC32      hdcSrcImage, hdcDstImage;
+    INT32      cxDst, cyDst;
+    INT32      xOff1, yOff1, xOff2, yOff2;
     INT32      nX1, nX2;
 
-    himlDst = ImageList_Create (himl1->cx, himl1->cy,
-                                ILC_MASK | ILC_COLOR, 1, 1);
+    if ((himl1 == NULL) || (himl2 == NULL)) return (NULL);
+
+    /* check indices */
+
+
+    if (xOffs > 0) {
+        cxDst = _MAX (himl1->cx, xOffs + himl2->cx);
+        xOff1 = 0;
+        xOff2 = xOffs;
+    }
+    else if (xOffs < 0) {
+        cxDst = _MAX (himl2->cx, himl1->cx - xOffs);
+        xOff1 = -xOffs;
+        xOff2 = 0;
+    }
+    else {
+        cxDst = 0;
+        xOff1 = 0;
+        xOff2 = 0;
+    }
+
+    if (yOffs > 0) {
+        cyDst = _MAX (himl1->cy, yOffs + himl2->cy);
+        yOff1 = 0;
+        yOff2 = yOffs;
+    }
+    else if (yOffs < 0) {
+        cyDst = _MAX (himl2->cy, himl1->cy - yOffs);
+        yOff1 = -yOffs;
+        yOff2 = 0;
+    }
+    else {
+        cyDst = 0;
+        yOff1 = 0;
+        yOff2 = 0;
+    }
+
+    himlDst = ImageList_Create (cxDst, cyDst, ILC_MASK | ILC_COLOR, 1, 1);
+
     if (himlDst) {
         hdcSrcImage = CreateCompatibleDC32 (0);
         hdcDstImage = CreateCompatibleDC32 (0);
@@ -483,28 +1279,29 @@
         /* copy image */
         SelectObject32 (hdcSrcImage, himl1->hbmImage);
         SelectObject32 (hdcDstImage, himlDst->hbmImage);
-        BitBlt32 (hdcDstImage, 0, 0, himlDst->cx, himlDst->cy, 
-                  hdcSrcImage, nX1, 0, SRCCOPY);  /* SRCCOPY */
+        BitBlt32 (hdcDstImage, 0, 0, cxDst, cyDst, 
+                  hdcSrcImage, 0, 0, BLACKNESS);
+        BitBlt32 (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
+                  hdcSrcImage, nX1, 0, SRCCOPY);
 
         SelectObject32 (hdcSrcImage, himl2->hbmMask);
-        BitBlt32 (hdcDstImage, xOffs, yOffs, 
-                  himlDst->cx - xOffs, himlDst->cy - yOffs, 
+        BitBlt32 (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
                   hdcSrcImage, nX2, 0, SRCAND);
 
         SelectObject32 (hdcSrcImage, himl2->hbmImage);
-        BitBlt32 (hdcDstImage, xOffs, yOffs, 
-                  himlDst->cx - xOffs, himlDst->cy - yOffs, 
+        BitBlt32 (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
                   hdcSrcImage, nX2, 0, SRCPAINT);
 
         /* copy mask */
         SelectObject32 (hdcSrcImage, himl1->hbmMask);
         SelectObject32 (hdcDstImage, himlDst->hbmMask);
-        BitBlt32 (hdcDstImage, 0, 0, himlDst->cx, himlDst->cy, 
+        BitBlt32 (hdcDstImage, 0, 0, cxDst, cyDst, 
+                  hdcSrcImage, 0, 0, WHITENESS);
+        BitBlt32 (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
                   hdcSrcImage, nX1, 0, SRCCOPY);
 
         SelectObject32 (hdcSrcImage, himl2->hbmMask);
-        BitBlt32 (hdcDstImage, xOffs, yOffs, 
-                  himlDst->cx - xOffs, himlDst->cy - yOffs, 
+        BitBlt32 (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
                   hdcSrcImage, nX2, 0, SRCAND);
 
         DeleteDC32 (hdcSrcImage);
@@ -515,32 +1312,176 @@
 }
 
 
+#if 0
+#if __IStream_INTERFACE_DEFINED__
+HIMAGELIST WINAPI ImageList_Read (
+	LPSTREAM pstm)
+{
+    FIXME (imagelist, "empty stub!\n");
 
-BOOL32 WINAPI
-ImageList_Replace (HIMAGELIST himl, INT32 i,  HBITMAP32 hbmImage, 
-                   HBITMAP32 hbmMask)
+
+    return (NULL);
+}
+#endif /* __IStream_INTERFACE_DEFINED__ */
+#endif /* 0 */
+
+
+BOOL32 WINAPI ImageList_Remove (
+	HIMAGELIST himl,
+	INT32 i)
+{
+    HBITMAP32 hbmNewImage, hbmNewMask;
+    HDC32     hdcSrc, hdcDst;
+    INT32     cxNew, nCount;
+
+    if ((i < -1) || (i >= himl->cCurImage)) {
+        ERR (imagelist, "Index out of range! %d\n", i);
+        return (FALSE);
+    }
+
+    if (himl->cCurImage == 0) {
+        ERR (imagelist, "List is already empty!\n");
+        return (FALSE);
+    }
+
+    if (i == -1) {
+        /* remove all */
+        TRACE (imagelist, "Remove all!\n");
+
+        himl->cMaxImage = himl->cInitial + himl->cGrow;
+        himl->cCurImage = 0;
+        for (nCount = 0; nCount <= MAX_OVERLAYIMAGE; nCount++)
+             himl->nOvlIdx[nCount] = -1;
+
+        DeleteObject32 (himl->hbmImage);
+        himl->hbmImage =
+            CreateBitmap32 (himl->cMaxImage * himl->cx, himl->cy,
+                            1, himl->uBitsPixel, NULL);
+
+        if (himl->hbmMask) {
+            DeleteObject32 (himl->hbmMask);
+            himl->hbmMask =
+                CreateBitmap32 (himl->cMaxImage * himl->cx, himl->cy,
+                                1, 1, NULL);
+        }
+    }
+    else {
+        /* delete one image */
+        TRACE (imagelist, "Remove single image! %d\n", i);
+
+        /* create new bitmap(s) */
+        cxNew = (himl->cCurImage + himl->cGrow - 1) * himl->cx;
+
+        fprintf (stderr, " - Number of images: %d / %d (Old/New)\n",
+                 himl->cCurImage, himl->cCurImage - 1);
+        fprintf (stderr, " - Max. number of images: %d / %d (Old/New)\n",
+                 himl->cMaxImage, himl->cCurImage + himl->cGrow - 1);
+        
+        hbmNewImage =
+            CreateBitmap32 (cxNew, himl->cy, 1, himl->uBitsPixel, NULL);
+
+        if (himl->hbmMask)
+            hbmNewMask = CreateBitmap32 (cxNew, himl->cy, 1, 1, NULL);
+        else
+            hbmNewMask = 0;  /* Just to keep compiler happy! */
+
+        hdcSrc = CreateCompatibleDC32 (0);
+        hdcDst = CreateCompatibleDC32 (0);
+
+        /* copy all images and masks prior to the "removed" image */
+        if (i > 0) {
+            TRACE (imagelist, "Pre image copy: Copy %d images\n", i);
+       
+            SelectObject32 (hdcSrc, himl->hbmImage);
+            SelectObject32 (hdcDst, hbmNewImage);
+            BitBlt32 (hdcDst, 0, 0, i * himl->cx, himl->cy,
+                      hdcSrc, 0, 0, SRCCOPY);
+
+            if (himl->hbmMask) {
+                SelectObject32 (hdcSrc, himl->hbmMask);
+                SelectObject32 (hdcDst, hbmNewMask);
+                BitBlt32 (hdcDst, 0, 0, i * himl->cx, himl->cy,
+                          hdcSrc, 0, 0, SRCCOPY);
+            }
+        }
+
+        /* copy all images and masks behind the removed image */
+        if (i < himl->cCurImage - 1) {
+            TRACE (imagelist, "Post image copy!\n");
+            SelectObject32 (hdcSrc, himl->hbmImage);
+            SelectObject32 (hdcDst, hbmNewImage);
+            BitBlt32 (hdcDst, i * himl->cx, 0, (himl->cCurImage - i - 1) * himl->cx,
+                      himl->cy, hdcSrc, (i + 1) * himl->cx, 0, SRCCOPY);
+
+            if (himl->hbmMask) {
+                SelectObject32 (hdcSrc, himl->hbmMask);
+                SelectObject32 (hdcDst, hbmNewMask);
+                BitBlt32 (hdcDst, i * himl->cx, 0,
+                          (himl->cCurImage - i - 1) * himl->cx,
+                          himl->cy, hdcSrc, (i + 1) * himl->cx, 0, SRCCOPY);
+            }
+        }
+
+        DeleteDC32 (hdcSrc);
+        DeleteDC32 (hdcDst);
+
+        /* delete old images and insert new ones */
+        DeleteObject32 (himl->hbmImage);
+        himl->hbmImage = hbmNewImage;
+        if (himl->hbmMask) {
+            DeleteObject32 (himl->hbmMask);
+            himl->hbmMask = hbmNewMask;
+        }
+
+        himl->cCurImage--;
+        himl->cMaxImage = himl->cCurImage + himl->cGrow;
+
+        TRACE (imagelist, "Number of images: %d\n", himl->cCurImage);
+        TRACE (imagelist, "Max. number of images: %d\n", himl->cMaxImage);
+    }
+
+    return (TRUE);
+}
+
+
+BOOL32 WINAPI ImageList_Replace (
+	HIMAGELIST himl,
+	INT32 i,
+	HBITMAP32 hbmImage, 
+	HBITMAP32 hbmMask)
 {
     HDC32 hdcImageList, hdcImage;
+    BITMAP32 bmp;
 
-    if ((i >= himl->cCurImage) || (i < 0)) return (FALSE);
+    if (himl == NULL) {
+        ERR (imagelist, "Invalid image list handle!\n");
+        return (FALSE);
+    }
+    
+    if ((i >= himl->cCurImage) || (i < 0)) {
+        ERR (imagelist, "Invalid image index!\n");
+        return (FALSE);
+    }
 
     hdcImageList = CreateCompatibleDC32 (0);
     hdcImage = CreateCompatibleDC32 (0);
+    GetObject32A (hbmImage, sizeof(BITMAP32), (LPVOID)&bmp);
 
     /* Replace Image */
     SelectObject32 (hdcImageList, himl->hbmImage);
     SelectObject32 (hdcImage, hbmImage);
 
-    BitBlt32 (hdcImageList, i * himl->cx, 0,
-              himl->cx, himl->cy, hdcImage, 0, 0, SRCCOPY);
+    StretchBlt32 (hdcImageList, i * himl->cx, 0, himl->cx, himl->cy,
+                  hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
 
-    if (himl->hbmMask) {
+    if (himl->hbmMask)
+    {
         /* Replace Mask */
         SelectObject32 (hdcImageList, himl->hbmMask);
         SelectObject32 (hdcImage, hbmMask);
 
-        BitBlt32 (hdcImageList, i * himl->cx, 0,
-                  himl->cx, himl->cy, hdcImage, 0, 0, SRCCOPY);
+        StretchBlt32 (hdcImageList, i * himl->cx, 0, himl->cx, himl->cy,
+                      hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
     }
 
     DeleteDC32 (hdcImage);
@@ -550,8 +1491,10 @@
 }
 
 
-INT32 WINAPI
-ImageList_ReplaceIcon (HIMAGELIST himl, INT32 i, HICON32 hIcon)
+INT32 WINAPI ImageList_ReplaceIcon (
+	HIMAGELIST himl,
+	INT32 i,
+	HICON32 hIcon)
 {
     HDC32     hdcImageList, hdcImage;
     INT32     nIndex;
@@ -581,7 +1524,7 @@
 
     if (i == -1) {
         if (himl->cCurImage + 1 >= himl->cMaxImage)
-            IMAGELIST_GrowBitmaps (himl, 1);
+            IMAGELIST_InternalGrowBitmaps (himl, 1);
         nIndex = himl->cCurImage;
         himl->cCurImage ++;
     }
@@ -594,22 +1537,25 @@
 #ifdef __GET_ICON_INFO_HACK__
     SelectObject32 (hdcImageList, himl->hbmImage);
     SelectObject32 (hdcImage, hbmImage);
+    StretchBlt32 (hdcImageList, nIndex * himl->cx, 0, himl->cx, himl->cy,
+                  hdcImage, 0, 0, ptr->nWidth, ptr->nHeight, SRCCOPY);
 #else
     SelectObject32 (hdcImage, ii->hbmColor);
+    StretchBlt32 (hdcImageList, nIndex * himl->cx, 0, himl->cx, himl->cy,
+                  hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
 #endif
 
-    BitBlt32 (hdcImageList, nIndex * himl->cx, 0,
-              himl->cx, himl->cy, hdcImage, 0, 0, SRCCOPY);
-
     if (himl->hbmMask) {
 #ifdef __GET_ICON_INFO_HACK__
         SelectObject32 (hdcImageList, himl->hbmMask);
         SelectObject32 (hdcImage, hbmMask);
+        StretchBlt32 (hdcImageList, nIndex * himl->cx, 0, himl->cx, himl->cy,
+                      hdcImage, 0, 0, ptr->nWidth, ptr->nHeight, SRCCOPY);
 #else
         SelectObject32 (hdcImage, ii->hbmMask);
+        StretchBlt32 (hdcImageList, nIndex * himl->cx, 0, himl->cx, himl->cy,
+                      hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
 #endif
-        BitBlt32 (hdcImageList, nIndex * himl->cx, 0,
-                  himl->cx, himl->cy, hdcImage, 0, 0, SRCCOPY);
     }
 
     DeleteDC32 (hdcImageList);
@@ -623,8 +1569,9 @@
 }
 
 
-COLORREF WINAPI
-ImageList_SetBkColor (HIMAGELIST himl, COLORREF clrBk)
+COLORREF WINAPI ImageList_SetBkColor (
+	HIMAGELIST himl,
+	COLORREF clrBk)
 {
     COLORREF clrOldBk;
 
@@ -634,14 +1581,150 @@
 }
 
 
-
-BOOL32 WINAPI
-ImageList_SetOverlayImage (HIMAGELIST himl, INT32 iImage, INT32 iOverlay)
+BOOL32 WINAPI ImageList_SetDragCursorImage (
+	HIMAGELIST himlDrag,
+	INT32 iDrag,
+	INT32 dxHotspot,
+	INT32 dyHotspot)
 {
-    if ((iOverlay < 1) || (iOverlay > 4)) return (FALSE);
+    FIXME (imagelist, "empty stub!\n");
+
+    return (FALSE);
+}
+
+
+#if 0
+BOOL32 WINAPI ImageList_SetFilter (
+	HIMAGELIST himl, 
+	INT32 iIndex, 
+	INT32 iFilter)
+{
+    FIXME (imagelist, "empty stub!\n");
+
+
+}
+#endif /* 0 */
+
+
+BOOL32 WINAPI ImageList_SetIconSize (
+	HIMAGELIST himl, 
+	INT32 cx, 
+	INT32 cy)
+{
+    INT32 nCount;
+
+    /* remove all images*/
+    himl->cMaxImage  = himl->cInitial + himl->cGrow;
+    himl->cCurImage  = 0;
+    himl->cx         = cx;
+    himl->cy         = cy;
+
+    /* initialize overlay mask indices */
+    for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++)
+        himl->nOvlIdx[nCount] = -1;
+
+    DeleteObject32 (himl->hbmImage);
+    himl->hbmImage =
+        CreateBitmap32 (himl->cMaxImage * himl->cx, himl->cy,
+                        1, himl->uBitsPixel, NULL);
+
+    if (himl->hbmMask) {
+        DeleteObject32 (himl->hbmMask);
+        himl->hbmMask =
+            CreateBitmap32 (himl->cMaxImage * himl->cx, himl->cy,
+                            1, 1, NULL);
+    }
+
+    return (TRUE);
+}
+
+
+BOOL32 WINAPI ImageList_SetImageCount (
+	HIMAGELIST himl, 
+	INT32 iImageCount)
+{
+    HDC32     hdcImageList, hdcBitmap;
+    HBITMAP32 hbmNewBitmap;
+    INT32     nNewWidth;
+
+    if (himl == NULL) return (FALSE);
+    if (himl->cCurImage <= iImageCount) return (FALSE);
+    if (himl->cMaxImage > iImageCount) return (TRUE);
+
+    nNewWidth = (iImageCount + himl->cGrow) * himl->cx;
+
+    hdcImageList = CreateCompatibleDC32 (0);
+    hdcBitmap = CreateCompatibleDC32 (0);
+
+    hbmNewBitmap =
+        CreateBitmap32 (nNewWidth, himl->cy, 1, himl->uBitsPixel, NULL);
+    if (hbmNewBitmap == 0)
+    {
+        SelectObject32 (hdcImageList, himl->hbmImage);
+        SelectObject32 (hdcBitmap, hbmNewBitmap);
+        BitBlt32 (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, himl->cy,
+                  hdcImageList, 0, 0, SRCCOPY);
+        DeleteObject32 (himl->hbmImage);
+        himl->hbmImage = hbmNewBitmap;
+    }
+    else
+    {
+        WARN (imagelist, "Could not create new image bitmap !\n");
+    }
+
+    if (himl->hbmMask)
+    {
+        hbmNewBitmap = 
+            CreateBitmap32 (nNewWidth, himl->cy, 1, 1, NULL);
+
+        if (hbmNewBitmap != 0)
+        {
+            SelectObject32 (hdcImageList, himl->hbmMask);
+            SelectObject32 (hdcBitmap, hbmNewBitmap);
+            BitBlt32 (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, himl->cy,
+                      hdcImageList, 0, 0, SRCCOPY);
+            DeleteObject32 (himl->hbmMask);
+            himl->hbmMask = hbmNewBitmap;
+        }
+        else
+        {
+            WARN (imagelist, "Could not create new mask bitmap!\n");
+        }
+    }
+
+    DeleteDC32 (hdcImageList);
+    DeleteDC32 (hdcBitmap);
+
+    /* Update max image count */
+    himl->cMaxImage = iImageCount + himl->cx;
+
+    return (TRUE);
+}
+
+
+BOOL32 WINAPI ImageList_SetOverlayImage (
+	HIMAGELIST himl, 
+	INT32 iImage, 
+	INT32 iOverlay)
+{
+    if ((iOverlay < 1) || (iOverlay > MAX_OVERLAYIMAGE)) return (FALSE);
     if ((iImage < 0) || (iImage > himl->cCurImage)) return (FALSE);
     
     himl->nOvlIdx[iOverlay - 1] = iImage;
     return (TRUE);
 }
 
+
+#if 0
+#if __IStream_INTERFACE_DEFINED__
+BOOL32 WINAPI ImageList_Write (
+	HIMAGELIST himl, 
+	LPSTREAM pstm)
+{
+    FIXME (imagelist, "empty stub!\n");
+
+
+    return (FALSE);
+}
+#endif  /* __IStream_INTERFACE_DEFINED__ */
+#endif  /* 0 */
diff --git a/misc/main.c b/misc/main.c
index 2ecb720..292a4d0 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -327,7 +327,7 @@
         if (!strcmp( argv[i], "-display" )) display_name = argv[i+1];
         if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
         {
-            printf( "%s\n", WINE_RELEASE_INFO );
+            MSG( "%s\n", WINE_RELEASE_INFO );
             exit(0);
         }
     }
@@ -683,6 +683,9 @@
 			*(BOOL32 *) lpvParam = FALSE;
 		break;
 
+	case SPI_GETDRAGFULLWINDOWS:
+	  *(BOOL32 *) lpvParam = FALSE;
+		
 	case SPI_GETGRIDGRANULARITY:
 		*(INT32*)lpvParam=GetProfileInt32A("desktop","GridGranularity",1);
 		break;
@@ -1067,5 +1070,5 @@
 */
 void WINAPI FileCDR(FARPROC16 x)
 {
-	printf("FileCDR(%8x)\n", (int) x);
+	FIXME(file,"(%8x): stub\n", (int) x);
 }
diff --git a/misc/mpr.c b/misc/mpr.c
index 3691e61..e5cf26e 100644
--- a/misc/mpr.c
+++ b/misc/mpr.c
@@ -14,9 +14,8 @@
 	LPWORD	pcbPassword,
 	BYTE	nType
 ) {
-	fprintf(stdnimp,"WNetGetCachedPassword(%s,%d,%p,%d,%d)\n",
-		pbResource,cbResource,pbPassword,*pcbPassword,nType
-	);
+	FIXME(mpr,"(%s,%d,%p,%d,%d): stub\n",
+		pbResource,cbResource,pbPassword,*pcbPassword,nType);
 	return 0;
 }
 
@@ -24,9 +23,6 @@
 	LPNETRESOURCE32A lpNetResource,
 	LPNETCONNECTINFOSTRUCT lpNetConnectInfoStruct
 ) {
-	fprintf(stdnimp,"MultinetGetConnectionPerformance(%p,%p)\n",
-			lpNetResource,
-			lpNetConnectInfoStruct
-	);
+	FIXME(mpr,"(%p,%p): stub\n",lpNetResource,lpNetConnectInfoStruct);
 	return 1;
 }
diff --git a/misc/network.c b/misc/network.c
index 601ca07..7af8b4c 100644
--- a/misc/network.c
+++ b/misc/network.c
@@ -9,14 +9,14 @@
 #include "winerror.h"
 #include "drive.h"
 #include "wnet.h"
+#include "debug.h"
 
 /**************************************************************************
  *              WNetErrorText       [USER.499]
  */
 int WINAPI WNetErrorText(WORD nError,LPSTR lpszText,WORD cbText)
 {
-	printf("EMPTY STUB !!! WNetErrorText(%x,%p,%x)\n",
-		nError,lpszText,cbText);
+        FIXME(wnet, "(%x,%p,%x): stub\n",nError,lpszText,cbText);
 	return FALSE;
 }
 
@@ -25,8 +25,8 @@
  */
 int WINAPI WNetOpenJob(LPSTR szQueue,LPSTR szJobTitle,WORD nCopies,LPWORD pfh)
 {
-	printf("EMPTY STUB !!! WNetOpenJob('%s','%s',%x,%p)\n",
-		szQueue,szJobTitle,nCopies,pfh);
+	FIXME(wnet, "('%s','%s',%x,%p): stub\n",
+	      szQueue,szJobTitle,nCopies,pfh);
 	return WN_NET_ERROR;
 }
 
@@ -35,8 +35,7 @@
  */
 int WINAPI WNetCloseJob(WORD fh,LPWORD pidJob,LPSTR szQueue)
 {
-	printf("EMPTY STUB !!! WNetCloseJob(%x,%p,'%s')\n",
-		fh,pidJob,szQueue);
+	FIXME(wnet, "(%x,%p,'%s'): stub\n",fh,pidJob,szQueue);
 	return WN_NET_ERROR;
 }
 
@@ -45,8 +44,7 @@
  */
 int WINAPI WNetAbortJob(LPSTR szQueue,WORD wJobId)
 {
-	printf("EMPTY STUB !!! WNetAbortJob('%s',%x)\n",
-		szQueue,wJobId);
+	FIXME(wnet, "('%s',%x): stub\n",szQueue,wJobId);
 	return WN_NET_ERROR;
 }
 
@@ -55,8 +53,7 @@
  */
 int WINAPI WNetHoldJob(LPSTR szQueue,WORD wJobId)
 {
-	printf("EMPTY STUB !!! WNetHoldJob('%s',%x)\n",
-		szQueue,wJobId);
+	FIXME(wnet, "('%s',%x): stub\n",szQueue,wJobId);
 	return WN_NET_ERROR;
 }
 
@@ -65,8 +62,7 @@
  */
 int WINAPI WNetReleaseJob(LPSTR szQueue,WORD wJobId)
 {
-	printf("EMPTY STUB !!! WNetReleaseJob('%s',%x)\n",
-		szQueue,wJobId);
+	FIXME(wnet, "('%s',%x): stub\n",szQueue,wJobId);
 	return WN_NET_ERROR;
 }
 
@@ -75,8 +71,7 @@
  */
 int WINAPI WNetCancelJob(LPSTR szQueue,WORD wJobId)
 {
-	printf("EMPTY STUB !!! WNetCancelJob('%s',%x)\n",
-		szQueue,wJobId);
+	FIXME(wnet, "('%s',%x): stub\n",szQueue,wJobId);
 	return WN_NET_ERROR;
 }
 
@@ -85,8 +80,7 @@
  */
 int WINAPI WNetSetJobCopies(LPSTR szQueue,WORD wJobId,WORD nCopies)
 {
-	printf("EMPTY STUB !!! WNetSetJobCopies('%s',%x,%x)\n",
-		szQueue,wJobId,nCopies);
+	FIXME(wnet, "('%s',%x,%x): stub\n",szQueue,wJobId,nCopies);
 	return WN_NET_ERROR;
 }
 
@@ -95,8 +89,7 @@
  */
 int WINAPI WNetWatchQueue(HWND16 hWnd,LPSTR szLocal,LPSTR szUser,WORD nQueue)
 {
-	printf("EMPTY STUB !!! WNetWatchQueue(%04x,'%s','%s',%x)\n",
-		hWnd,szLocal,szUser,nQueue);
+	FIXME(wnet, "(%04x,'%s','%s',%x): stub\n",hWnd,szLocal,szUser,nQueue);
 	return WN_NET_ERROR;
 }
 
@@ -105,7 +98,7 @@
  */
 int WINAPI WNetUnwatchQueue(LPSTR szQueue)
 {
-	printf("EMPTY STUB !!! WNetUnwatchQueue('%s')\n", szQueue);
+	FIXME(wnet, "('%s'): stub\n", szQueue);
 	return WN_NET_ERROR;
 }
 
@@ -114,8 +107,7 @@
  */
 int WINAPI WNetLockQueueData(LPSTR szQueue,LPSTR szUser,void *lplpQueueStruct)
 {
-	printf("EMPTY STUB !!! WNetLockQueueData('%s','%s',%p)\n",
-		szQueue,szUser,lplpQueueStruct);
+	FIXME(wnet, "('%s','%s',%p): stub\n",szQueue,szUser,lplpQueueStruct);
 	return WN_NET_ERROR;
 }
 
@@ -124,7 +116,7 @@
  */
 int WINAPI WNetUnlockQueueData(LPSTR szQueue)
 {
-	printf("EMPTY STUB !!! WNetUnlockQueueData('%s')\n",szQueue);
+	FIXME(wnet, "('%s'): stub\n",szQueue);
 	return WN_NET_ERROR;
 }
 
@@ -170,10 +162,11 @@
 	switch (capability) {
 		case WNNC_SPEC_VERSION:
 		{
-			return 0x30a; /* WfW 3.11 (and apparently other 3.1x) */
+			return 0x30a; /* WfW 3.11(and apparently other 3.1x) */
 		}
 		case WNNC_NET_TYPE:
-		/* hi byte = network type, lo byte = network vendor (Netware = 0x03) [15 types] */
+		/* hi byte = network type, 
+                   lo byte = network vendor (Netware = 0x03) [15 types] */
 		return WNNC_NET_MultiNet | WNNC_SUBNET_WinWorkgroups;
 
 		case WNNC_DRIVER_VERSION:
@@ -219,7 +212,8 @@
 		return	WNNC_ERR_GetError|WNNC_ERR_GetErrorText;
 
 		case WNNC_PRINTMGREXT:
-		/* returns the Print Manager version in major and minor format if Print Manager functions are available */
+		/* returns the Print Manager version in major and 
+                   minor format if Print Manager functions are available */
 		return 0x30e; /* printman version of WfW 3.11 */
 
 		case 0xffff:
@@ -238,7 +232,7 @@
  */
 int WINAPI WNetDeviceMode(HWND16 hWndOwner)
 {
-	printf("EMPTY STUB !!! WNetDeviceMode(%04x)\n",hWndOwner);
+	FIXME(wnet, "(%04x): stub\n",hWndOwner);
 	return WN_NO_NETWORK;
 }
 
@@ -247,8 +241,7 @@
  */
 int WINAPI WNetBrowseDialog(HWND16 hParent,WORD nType,LPSTR szPath)
 {
-	printf("EMPTY STUB !!! WNetBrowseDialog(%04x,%x,'%s')\n",
-		hParent,nType,szPath);
+	FIXME(wnet, "(%04x,%x,'%s'): stub\n",hParent,nType,szPath);
 	return WN_NO_NETWORK;
 }
 
@@ -257,8 +250,7 @@
  */
 UINT16 WINAPI WNetGetUser(LPSTR lpLocalName, LPSTR lpUserName, DWORD *lpSize)
 {
-	printf("EMPTY STUB !!! WNetGetUser(%p, %p, %p);\n", 
-							lpLocalName, lpUserName, lpSize);
+	FIXME(wnet, "(%p, %p, %p): stub\n", lpLocalName, lpUserName, lpSize);
 	return WN_NO_NETWORK;
 }
 
@@ -268,8 +260,8 @@
 UINT16 WINAPI WNetAddConnection(LPSTR lpNetPath, LPSTR lpPassWord,
                                 LPSTR lpLocalName)
 {
-	printf("EMPTY STUB !!! WNetAddConnection('%s', %p, '%s');\n",
-							lpNetPath, lpPassWord, lpLocalName);
+	FIXME(wnet, "('%s', %p, '%s'): stub\n",
+	      lpNetPath,lpPassWord,lpLocalName);
 	return WN_NO_NETWORK;
 }
 
@@ -279,8 +271,7 @@
  */
 UINT16 WINAPI WNetCancelConnection(LPSTR lpName, BOOL16 bForce)
 {
-    printf("EMPTY STUB !!! WNetCancelConnection('%s', %04X);\n",
-           lpName, bForce);
+    FIXME(wnet, "('%s', %04X): stub\n", lpName, bForce);
     return WN_NO_NETWORK;
 }
 
@@ -289,7 +280,7 @@
  */
 int WINAPI WNetGetError(LPWORD nError)
 {
-	printf("EMPTY STUB !!! WNetGetError(%p)\n",nError);
+	FIXME(wnet, "(%p): stub\n",nError);
 	return WN_NO_NETWORK;
 }
 
@@ -298,8 +289,7 @@
  */
 int WINAPI WNetGetErrorText(WORD nError, LPSTR lpBuffer, LPWORD nBufferSize)
 {
-	printf("EMPTY STUB !!! WNetGetErrorText(%x,%p,%p)\n",
-		nError,lpBuffer,nBufferSize);
+	FIXME(wnet, "(%x,%p,%p): stub\n",nError,lpBuffer,nBufferSize);
 	return WN_NET_ERROR;
 }
 
@@ -308,8 +298,7 @@
  */
 int WINAPI WNetRestoreConnection(HWND16 hwndOwner,LPSTR lpszDevice)
 {
-	printf("EMPTY STUB !!! WNetRestoreConnection(%04x,'%s')\n",
-		hwndOwner,lpszDevice);
+	FIXME(wnet, "(%04x,'%s'): stub\n",hwndOwner,lpszDevice);
 	return WN_NO_NETWORK;
 }
 
@@ -318,8 +307,7 @@
  */
 int WINAPI WNetWriteJob(HANDLE16 hJob,void *lpData,LPWORD lpcbData)
 {
-	printf("EMPTY STUB !!! WNetWriteJob(%04x,%p,%p)\n",
-		hJob,lpData,lpcbData);
+	FIXME(wnet, "(%04x,%p,%p): stub\n",hJob,lpData,lpcbData);
 	return WN_NO_NETWORK;
 }
 
@@ -328,7 +316,7 @@
  */
 UINT16 WINAPI WNetConnectDialog(HWND16 hWndParent, WORD iType)
 {
-	printf("EMPTY STUB !!! WNetConnectDialog(%04x, %4X)\n", hWndParent, iType);
+	FIXME(wnet, "(%04x, %4X): stub\n", hWndParent, iType);
 	return WN_SUCCESS;
 }
 
@@ -337,8 +325,7 @@
  */
 int WINAPI WNetDisconnectDialog(HWND16 hwndOwner, WORD iType)
 {
-	printf("EMPTY STUB !!! WNetDisconnectDialog(%04x,%x)\n",
-		hwndOwner,iType);
+	FIXME(wnet, "(%04x,%x): stub\n",hwndOwner,iType);
 	return WN_NO_NETWORK;
 }
 
@@ -347,8 +334,7 @@
  */
 UINT16 WINAPI WNetConnectionDialog(HWND16 hWndParent, WORD iType)
 {
-	printf("EMPTY STUB !!! WNetConnectionDialog(%04x, %4X)\n", 
-		hWndParent, iType);
+	FIXME(wnet, "(%04x, %4X): stub\n", hWndParent, iType);
 	return WN_SUCCESS;
 }
 
@@ -357,8 +343,7 @@
  */
 int WINAPI WNetViewQueueDialog(HWND16 hwndOwner,LPSTR lpszQueue)
 {
-	printf("EMPTY STUB !!! WNetViewQueueDialog(%04x,'%s')\n",
-		hwndOwner,lpszQueue);
+	FIXME(wnet, "(%04x,'%s'): stub\n",hwndOwner,lpszQueue);
 	return WN_NO_NETWORK;
 }
 
@@ -368,8 +353,8 @@
 int WINAPI WNetPropertyDialog(HWND16 hwndParent,WORD iButton,
                               WORD nPropSel,LPSTR lpszName,WORD nType)
 {
-	printf("EMPTY STUB !!! WNetPropertyDialog(%04x,%x,%x,'%s',%x)\n",
-		hwndParent,iButton,nPropSel,lpszName,nType);
+	FIXME(wnet, "(%04x,%x,%x,'%s',%x): stub\n",
+	      hwndParent,iButton,nPropSel,lpszName,nType);
 	return WN_NO_NETWORK;
 }
 
@@ -378,8 +363,7 @@
  */
 int WINAPI WNetGetDirectoryType(LPSTR lpName,void *lpType)
 {
-	printf("EMPTY STUB !!! WNetGetDirectoryType('%s',%p)\n",
-		lpName,lpType);
+	FIXME(wnet, "('%s',%p): stub\n",lpName,lpType);
 	return WN_NO_NETWORK;
 }
 
@@ -388,8 +372,7 @@
  */
 int WINAPI WNetDirectoryNotify(HWND16 hwndOwner,void *lpDir,WORD wOper)
 {
-	printf("EMPTY STUB !!! WNetDirectoryNotify(%04x,%p,%x)\n",
-		hwndOwner,lpDir,wOper);
+	FIXME(wnet, "(%04x,%p,%x): stub\n",hwndOwner,lpDir,wOper);
 	return WN_NO_NETWORK;
 }
 
@@ -399,8 +382,8 @@
 int WINAPI WNetGetPropertyText(HWND16 hwndParent,WORD iButton,WORD nPropSel,
                                LPSTR lpszName,WORD nType)
 {
-	printf("EMPTY STUB !!! WNetGetPropertyText(%04x,%x,%x,'%s',%x)\n",
-		hwndParent,iButton,nPropSel,lpszName,nType);
+	FIXME(wnet, "(%04x,%x,%x,'%s',%x): stub\n",
+	      hwndParent,iButton,nPropSel,lpszName,nType);
 	return WN_NO_NETWORK;
 }
 
@@ -410,8 +393,8 @@
 UINT16 WINAPI WNetAddConnection2(LPSTR lpNetPath, LPSTR lpPassWord, 
                                  LPSTR lpLocalName, LPSTR lpUserName)
 {
-	printf("EMPTY STUB !!! WNetAddConnection2('%s', %p, '%s', '%s');\n",
-					lpNetPath, lpPassWord, lpLocalName, lpUserName);
+	FIXME(wnet, "('%s', %p, '%s', '%s'): stub\n",
+	      lpNetPath, lpPassWord, lpLocalName, lpUserName);
 	return WN_NO_NETWORK;
 }
 
@@ -420,7 +403,7 @@
  */
 UINT16 WINAPI WNetCloseEnum(HANDLE16 hEnum)
 {
-	printf("EMPTY STUB !!! WNetCloseEnum(%04x);\n", hEnum);
+	FIXME(wnet, "(%04x): stub\n", hEnum);
 	return WN_NO_NETWORK;
 }
 
@@ -430,8 +413,8 @@
 UINT16 WINAPI WNetEnumResource(HANDLE16 hEnum, DWORD cRequ, 
                                DWORD *lpCount, LPVOID lpBuf)
 {
-	printf("EMPTY STUB !!! WNetEnumResource(%04x, %08lX, %p, %p);\n", 
-							hEnum, cRequ, lpCount, lpBuf);
+	FIXME(wnet, "(%04x, %08lX, %p, %p): stub\n", 
+	      hEnum, cRequ, lpCount, lpBuf);
 	return WN_NO_NETWORK;
 }
 
@@ -441,8 +424,8 @@
 UINT16 WINAPI WNetOpenEnum16(DWORD dwScope, DWORD dwType, 
                              LPNETRESOURCE16 lpNet, HANDLE16 *lphEnum)
 {
-	printf("EMPTY STUB !!! WNetOpenEnum(%08lX, %08lX, %p, %p);\n",
-               dwScope, dwType, lpNet, lphEnum);
+	FIXME(wnet, "(%08lX, %08lX, %p, %p): stub\n",
+	      dwScope, dwType, lpNet, lphEnum);
 	return WN_NO_NETWORK;
 }
 
@@ -452,8 +435,8 @@
 UINT32 WINAPI WNetOpenEnum32A(DWORD dwScope, DWORD dwType, 
                               LPNETRESOURCE32A lpNet, HANDLE32 *lphEnum)
 {
-	printf("EMPTY STUB !!! WNetOpenEnumA(%08lX, %08lX, %p, %p);\n",
-               dwScope, dwType, lpNet, lphEnum);
+	FIXME(wnet, "(%08lX, %08lX, %p, %p): stub\n",
+	      dwScope, dwType, lpNet, lphEnum);
 	return WN_NO_NETWORK;
 }
 
@@ -473,8 +456,6 @@
 WNetGetResourceInformation32A(
 	LPNETRESOURCE32A netres,LPVOID buf,LPDWORD buflen,LPSTR systemstr
 ) {
-	fprintf(stderr,"WNetGetResourceInformationA(%p,%p,%p,%p),stub!\n",
-		netres,buf,buflen,systemstr
-	);
+	FIXME(wnet,"(%p,%p,%p,%p): stub!\n",netres,buf,buflen,systemstr);
 	return WN_NO_NETWORK;
 }
diff --git a/misc/ntdll.c b/misc/ntdll.c
index f48f370..e52e201 100644
--- a/misc/ntdll.c
+++ b/misc/ntdll.c
@@ -201,7 +201,7 @@
  */
 LPVOID WINAPI RtlNormalizeProcessParams(LPVOID x)
 {
-    fprintf(stdnimp,"RtlNormalizeProcessParams(%p), stub.\n",x);
+    FIXME(ntdll,"(%p), stub.\n",x);
     return x;
 }
 
@@ -490,9 +490,7 @@
 {
 	LPSTR	fromA = HEAP_strdupWtoA(GetProcessHeap(),0,from);
 
-	fprintf(stderr,"RtlDosPathNameToNtPathName_U(%s,%p,%08lx,%08lx)\n",
-		fromA,us,x2,x3
-	);
+	FIXME(ntdll,"(%s,%p,%08lx,%08lx)\n",fromA,us,x2,x3);
 	if (us)
 		RtlInitUnicodeString(us,HEAP_strdupW(GetProcessHeap(),0,from));
 	return TRUE;
@@ -503,9 +501,8 @@
  */
 DWORD WINAPI NtOpenFile(DWORD x1,DWORD flags,DWORD x3,DWORD x4,DWORD alignment,DWORD x6)
 {
-	fprintf(stderr,"NtOpenFile(%08lx,%08lx,%08lx,%08lx,%08lx,%08lx)\n",
-		x1,flags,x3,x4,alignment,x6
-	);
+	FIXME(ntdll,"(%08lx,%08lx,%08lx,%08lx,%08lx,%08lx)\n",
+	      x1,flags,x3,x4,alignment,x6);
 	/* returns file io completion status */
 	return 0;
 }
diff --git a/misc/printdrv.c b/misc/printdrv.c
index 3c73581..2466010 100644
--- a/misc/printdrv.c
+++ b/misc/printdrv.c
@@ -11,20 +11,20 @@
 #include "windows.h"
 #include "win.h"
 #include "winerror.h"
-
+#include "debug.h"
 
 INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
 {
   INT16 retVal;
-  printf("In startdoc16(%p)\n", lpdoc );
-  printf("In StartDoc16 %d 0x%lx:0x%p 0x%lx:0x%p\n",lpdoc->cbSize,
-	 lpdoc->lpszDocName,PTR_SEG_TO_LIN(lpdoc->lpszDocName),
-	 lpdoc->lpszOutput,PTR_SEG_TO_LIN(lpdoc->lpszOutput));
-  printf("In StartDoc16 %d %s %s\n",lpdoc->cbSize,
-	 (LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszDocName),
-	 (LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszOutput));
+  TRACE(print,"(%p)\n", lpdoc );
+  TRACE(print,"%d 0x%lx:0x%p 0x%lx:0x%p\n",lpdoc->cbSize,
+	lpdoc->lpszDocName,PTR_SEG_TO_LIN(lpdoc->lpszDocName),
+	lpdoc->lpszOutput,PTR_SEG_TO_LIN(lpdoc->lpszOutput));
+  TRACE(print, "%d %s %s\n",lpdoc->cbSize,
+	(LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszDocName),
+	(LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszOutput));
   retVal =  Escape16(hdc, STARTDOC, sizeof(DOCINFO16), lpdoc->lpszDocName, 0);
-  printf("Escape16 returned %d\n",retVal);
+  TRACE(print,"Escape16 returned %d\n",retVal);
   return retVal;
 }
 
diff --git a/misc/shell.c b/misc/shell.c
index a7ae4c0..545ecdc 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -23,7 +23,6 @@
 #include "sysmetrics.h"
 #include "shlobj.h"
 #include "debug.h"
-#include "debugstr.h"
 #include "winreg.h"
 
 static const char * const SHELL_People[] =
@@ -1406,12 +1405,6 @@
     return CallNextHookEx16( WH_SHELL, code, wParam, lParam );
 }
 
-LRESULT WINAPI FUNC004(INT16 code, WPARAM16 wParam, /*LPARAM*/WORD lParam)
-{
-	FIXME(reg,"(%d,%d,%d),STUB!\n",code,wParam,lParam);
-	return ShellHookProc(code,wParam,(DWORD)lParam);
-}
-
 /*************************************************************************
  *				RegisterShellHook	[SHELL.102]
  */
@@ -1460,9 +1453,8 @@
                               SHFILEINFO32A *psfi, UINT32 sizeofpsfi,
                               UINT32 flags )
 {
-	fprintf(stdnimp,"SHGetFileInfo32A(%s,0x%08lx,%p,%d,0x%08x)\n",
-		path,dwFileAttributes,psfi,sizeofpsfi,flags
-	);
+	FIXME(shell,"(%s,0x%08lx,%p,%d,0x%08x): stub\n",
+	      path,dwFileAttributes,psfi,sizeofpsfi,flags);
 	return TRUE;
 }
 
@@ -1471,7 +1463,7 @@
  */
 UINT32 WINAPI SHAppBarMessage32(DWORD msg, PAPPBARDATA data)
 {
-    fprintf(stdnimp,"SHAppBarMessage32(0x%08lx,%p)\n", msg, data);
+    FIXME(shell,"(0x%08lx,%p): stub\n", msg, data);
 #if 0
     switch (msg) {
         case ABM_ACTIVATE:
@@ -1549,8 +1541,7 @@
 void WINAPI Control_RunDLL (HWND32 hwnd, LPCVOID code, LPCSTR cmd, DWORD arg4)
 {
   TRACE(exec, "(%08x, %p, \"%s\", %08lx)\n",
-		hwnd, code ? code : "(null)",
-		cmd ? cmd : "(null)", arg4);
+	hwnd, code ? code : "(null)", cmd ? cmd : "(null)", arg4);
 }
 
 /*************************************************************************
@@ -1558,7 +1549,7 @@
 
 void WINAPI FreeIconList( DWORD dw )
 {
-    fprintf( stdnimp, "FreeIconList: empty stub\n" );
+    FIXME(reg, "empty stub\n" );
 }
 
 /*************************************************************************
@@ -1574,7 +1565,7 @@
 
     WINE_StringFromCLSID((LPCLSID)rclsid,xclsid);
     WINE_StringFromCLSID((LPCLSID)iid,xiid);
-    fprintf(stderr,"SHELL32_DllGetClassObject(%s,%s,%p)\n",xclsid,xiid,ppv);
+    TRACE(shell,"(%s,%s,%p)\n",xclsid,xiid,ppv);
 
     *ppv = NULL;
 /* SDK example code looks like this:
@@ -1595,13 +1586,13 @@
  */
   
     if (!memcmp(rclsid,&CLSID_ShellDesktop,sizeof(CLSID_ShellDesktop))) {
-    	fprintf(stderr,"	requested CLSID_ShellDesktop, creating it.\n");
+    	TRACE(shell,"   requested CLSID_ShellDesktop, creating it.\n");
 	*ppv = IShellFolder_Constructor();
-	/* FIXME: Initialize this folder to be the shell desktop folder */
+	FIXME(shell,"Initialize this folder to be the shell desktop folder\n");
 	return 0;
     }
 
-    fprintf (stdnimp, "	-> clsid not found. returning E_OUTOFMEMORY.\n");
+    FIXME(shell, "   -> clsid not found. returning E_OUTOFMEMORY.\n");
     return hres;
 }
 
@@ -1633,7 +1624,7 @@
  * heap (ProcessHeap).
  */
 DWORD WINAPI SHGetMalloc(LPMALLOC32 *lpmal) {
-	fprintf(stderr,"SHGetMalloc()\n");
+	TRACE(shell,"(%p)\n", lpmal);
 	return CoGetMalloc32(0,lpmal);
 }
 
@@ -1644,11 +1635,9 @@
  * nFolder is a CSIDL_xxxxx.
  */
 HRESULT WINAPI SHGetSpecialFolderLocation(HWND32 hwndOwner, INT32 nFolder, LPITEMIDLIST * ppidl) {
-	fprintf(stderr,"SHGetSpecialFolderLocation(%04x,%d,%p),stub!\n",
-		hwndOwner,nFolder,ppidl
-	);
+	FIXME(shell,"(%04x,%d,%p),stub!\n", hwndOwner,nFolder,ppidl);
 	*ppidl = (LPITEMIDLIST)HeapAlloc(GetProcessHeap(),0,2*sizeof(ITEMIDLIST));
-	/* FIXME: we return only the empty ITEMIDLIST currently. */
+	FIXME(shell, "we return only the empty ITEMIDLIST currently.\n");
 	(*ppidl)->mkid.cb = 0;
 	return NOERROR;
 }
@@ -1658,8 +1647,12 @@
  * returns the path from a passed PIDL.
  */
 BOOL32 WINAPI SHGetPathFromIDList(LPCITEMIDLIST pidl,LPSTR pszPath) {
-	fprintf(stderr,"SHGetPathFromIDList(%p,%p),stub!\n",pidl,pszPath);
+	FIXME(shell,"(%p,%p),stub!\n",pidl,pszPath);
 	lstrcpy32A(pszPath,"E:\\"); /* FIXME */
 	return NOERROR;
 }
 
+
+
+
+
diff --git a/misc/shellord.c b/misc/shellord.c
index edaa2d7..8cbfa40 100644
--- a/misc/shellord.c
+++ b/misc/shellord.c
@@ -365,7 +365,7 @@
  * unknown
  */
 void WINAPI SHELL32_175(DWORD x1,DWORD x2,DWORD x3,DWORD x4) {
-    fprintf(stdnimp,"SHELL32_175(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",
+    fprintf(stderr,"SHELL32_175(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",
     	x1,x2,x3,x4
     );
 }
diff --git a/misc/sound.c b/misc/sound.c
index 452a6f7..9de81f0 100644
--- a/misc/sound.c
+++ b/misc/sound.c
@@ -6,98 +6,99 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include "windows.h"
+#include "debug.h"
 
 INT16 WINAPI OpenSound16(void)
 {
-  printf("OpenSound16()\n");
+  FIXME(sound, "(void): stub\n");
   return -1;
 }
 
 void WINAPI OpenSound32(void)
 {
-  printf("OpenSound32()\n");
+  FIXME(sound, "(void): stub\n");
 }
 
 void WINAPI CloseSound(void)
 {
-  printf("CloseSound()\n");
+  FIXME(sound, "(void): stub\n");
 }
 
 INT16 WINAPI SetVoiceQueueSize16(INT16 nVoice, INT16 nBytes)
 {
-  printf("SetVoiceQueueSize16 (%d,%d)\n",nVoice,nBytes);
+  FIXME(sound, "(%d,%d): stub\n",nVoice,nBytes);
   return 0;
 }
 
 DWORD WINAPI SetVoiceQueueSize32(DWORD nVoice, DWORD nBytes)
 {
-  printf("SetVoiceQueueSize32 (%ld,%ld)\n",nVoice,nBytes);
+  FIXME(sound, "(%ld,%ld): stub\n",nVoice,nBytes);
   return 0;
 }
 
 INT16 WINAPI SetVoiceNote16(INT16 nVoice, INT16 nValue, INT16 nLength,
                             INT16 nCdots)
 {
-  printf("SetVoiceNote16 (%d,%d,%d,%d)\n",nVoice,nValue,nLength,nCdots);
+  FIXME(sound, "(%d,%d,%d,%d): stub\n",nVoice,nValue,nLength,nCdots);
   return 0;
 }
 
 DWORD WINAPI SetVoiceNote32(DWORD nVoice, DWORD nValue, DWORD nLength,
                             DWORD nCdots)
 {
-  printf("SetVoiceNote32 (%ld,%ld,%ld,%ld)\n",nVoice,nValue,nLength,nCdots);
+  FIXME(sound, "(%ld,%ld,%ld,%ld): stub\n",nVoice,nValue,nLength,nCdots);
   return 0;
 }
 
 INT16 WINAPI SetVoiceAccent16(INT16 nVoice, INT16 nTempo, INT16 nVolume,
                               INT16 nMode, INT16 nPitch)
 {
-  printf("SetVoiceAccent16(%d,%d,%d,%d,%d)\n", nVoice, nTempo, 
-	 nVolume, nMode, nPitch);
+  FIXME(sound, "(%d,%d,%d,%d,%d): stub\n", nVoice, nTempo, 
+	nVolume, nMode, nPitch);
   return 0;
 }
 
 DWORD WINAPI SetVoiceAccent32(DWORD nVoice, DWORD nTempo, DWORD nVolume,
                               DWORD nMode, DWORD nPitch)
 {
-  printf("SetVoiceAccent32(%ld,%ld,%ld,%ld,%ld)\n", nVoice, nTempo, 
-	 nVolume, nMode, nPitch);
+  FIXME(sound, "(%ld,%ld,%ld,%ld,%ld): stub\n", nVoice, nTempo, 
+	nVolume, nMode, nPitch);
   return 0;
 }
 
 INT16 WINAPI SetVoiceEnvelope16(INT16 nVoice, INT16 nShape, INT16 nRepeat)
 {
-  printf("SetVoiceEnvelope16(%d,%d,%d)\n",nVoice,nShape,nRepeat);
+  FIXME(sound, "(%d,%d,%d): stub\n",nVoice,nShape,nRepeat);
   return 0;
 }
 
 DWORD WINAPI SetVoiceEnvelope32(DWORD nVoice, DWORD nShape, DWORD nRepeat)
 {
-  printf("SetVoiceEnvelope32(%ld,%ld,%ld)\n",nVoice,nShape,nRepeat);
+  FIXME(sound, "(%ld,%ld,%ld): stub\n",nVoice,nShape,nRepeat);
   return 0;
 }
 
 INT16 WINAPI SetSoundNoise16(INT16 nSource, INT16 nDuration)
 {
-  printf("SetSoundNoise16(%d,%d)\n",nSource,nDuration);
+  FIXME(sound, "(%d,%d): stub\n",nSource,nDuration);
   return 0;
 }
 
 DWORD WINAPI SetSoundNoise32(DWORD nSource, DWORD nDuration)
 {
-  printf("SetSoundNoise32(%ld,%ld)\n",nSource,nDuration);
+  FIXME(sound, "(%ld,%ld): stub\n",nSource,nDuration);
   return 0;
 }
 
 INT16 WINAPI SetVoiceSound16(INT16 nVoice, DWORD lFrequency, INT16 nDuration)
 {
-  printf("SetVoiceSound16(%d, %ld, %d)\n",nVoice,lFrequency, nDuration);
+  FIXME(sound, "(%d, %ld, %d): stub\n",nVoice,lFrequency, nDuration);
   return 0;
 }
 
 DWORD WINAPI SetVoiceSound32(DWORD nVoice, DWORD lFrequency, DWORD nDuration)
 {
-  printf("SetVoiceSound32(%ld, %ld, %ld)\n",nVoice,lFrequency, nDuration);
+  FIXME(sound, "(%ld, %ld, %ld): stub\n",nVoice,lFrequency, nDuration);
   return 0;
 }
 
@@ -113,77 +114,81 @@
 
 INT16 WINAPI WaitSoundState16(INT16 x)
 {
-    fprintf(stderr, "WaitSoundState16(%d)\n", x);
+    FIXME(sound, "(%d): stub\n", x);
     return 0;
 }
 
 DWORD WINAPI WaitSoundState32(DWORD x)
 {
-    fprintf(stderr, "WaitSoundState32(%ld)\n", x);
+    FIXME(sound, "(%ld): stub\n", x);
     return 0;
 }
 
 INT16 WINAPI SyncAllVoices16(void)
 {
-    fprintf(stderr, "SyncAllVoices16()\n");
+    FIXME(sound, "(void): stub\n");
     return 0;
 }
 
 DWORD WINAPI SyncAllVoices32(void)
 {
-    fprintf(stderr, "SyncAllVoices32()\n");
+    FIXME(sound, "(void): stub\n");
     return 0;
 }
 
 INT16 WINAPI CountVoiceNotes16(INT16 x)
 {
-    fprintf(stderr, "CountVoiceNotes16(%d)\n", x);
+    FIXME(sound, "(%d): stub\n", x);
     return 0;
 }
 
 DWORD WINAPI CountVoiceNotes32(DWORD x)
 {
-    fprintf(stderr, "CountVoiceNotes32(%ld)\n", x);
+    FIXME(sound, "(%ld): stub\n", x);
     return 0;
 }
 
 LPINT16 WINAPI GetThresholdEvent16(void)
 {
-    fprintf(stderr, "GetThresholdEvent16()\n");
+    FIXME(sound, "(void): stub\n");
     return NULL;
 }
 
 LPDWORD WINAPI GetThresholdEvent32(void)
 {
-    fprintf(stderr, "GetThresholdEvent32()\n");
+    FIXME(sound, "(void): stub\n");
     return NULL;
 }
 
 INT16 WINAPI GetThresholdStatus16(void)
 {
-    fprintf(stderr, "GetThresholdStatus16()\n");
+    FIXME(sound, "(void): stub\n");
     return 0;
 }
 
 DWORD WINAPI GetThresholdStatus32(void)
 {
-    fprintf(stderr, "GetThresholdStatus32()\n");
+    FIXME(sound, "(void): stub\n");
     return 0;
 }
 
 INT16 WINAPI SetVoiceThreshold16(INT16 a, INT16 b)
 {
-	fprintf(stderr, "SetVoiceThreshold16(%d,%d)\n", a, b);
-        return 0;
+    FIXME(sound, "(%d,%d): stub\n", a, b);
+    return 0;
 }
 
 DWORD WINAPI SetVoiceThreshold32(DWORD a, DWORD b)
 {
-    fprintf(stderr, "SetVoiceThreshold32(%ld,%ld)\n", a, b);
+    FIXME(sound, "(%ld,%ld): stub\n", a, b);
     return 0;
 }
 
 void WINAPI DoBeep(void)
 {
-	fprintf(stderr, "BEEP!\n");
+    FIXME(sound, "(void): stub!\n");
 }
+
+
+
+
diff --git a/misc/version.c b/misc/version.c
index 971e758..77c7986 100644
--- a/misc/version.c
+++ b/misc/version.c
@@ -11,6 +11,7 @@
 #include "winbase.h"
 #include "process.h"
 #include "options.h"
+#include "debug.h"
 
 typedef enum
 {
@@ -98,11 +99,11 @@
             return;
         }
     }
-    fprintf( stderr, "Invalid winver value '%s' specified.\n", arg );
-    fprintf( stderr, "Valid versions are:" );
+    MSG("Invalid winver value '%s' specified.\n", arg );
+    MSG("Valid versions are:" );
     for (i = 0; i < NB_VERSIONS; i++)
-        fprintf( stderr, " '%s'%c", VersionNames[i],
-                 (i == NB_VERSIONS - 1) ? '\n' : ',' );
+        MSG(" '%s'%c", VersionNames[i],
+	    (i == NB_VERSIONS - 1) ? '\n' : ',' );
 }
 
 
@@ -134,9 +135,9 @@
         /* NT 3.51 */
         if (peheader->OptionalHeader.MinorSubsystemVersion == 51) return NT351;
     }
-    fprintf(stderr,"VERSION_GetVersion: unknown subsystem version: %04x.%04x, please report.\n",
-            peheader->OptionalHeader.MajorSubsystemVersion,
-            peheader->OptionalHeader.MinorSubsystemVersion );
+    ERR(ver,"unknown subsystem version: %04x.%04x, please report.\n",
+	peheader->OptionalHeader.MajorSubsystemVersion,
+	peheader->OptionalHeader.MinorSubsystemVersion );
     return defaultVersion;
 }
 
@@ -169,7 +170,7 @@
     VERSION ver = VERSION_GetVersion();
     if (v->dwOSVersionInfoSize != sizeof(OSVERSIONINFO32A))
     {
-        fprintf(stderr,"wrong OSVERSIONINFO size from app");
+        WARN(ver,"wrong OSVERSIONINFO size from app");
         return FALSE;
     }
     v->dwMajorVersion = VersionData[ver].getVersionEx.dwMajorVersion;
@@ -189,7 +190,7 @@
     VERSION ver = VERSION_GetVersion();
     if (v->dwOSVersionInfoSize!=sizeof(OSVERSIONINFO32W))
     {
-        fprintf(stderr,"wrong OSVERSIONINFO size from app");
+        WARN(ver,"wrong OSVERSIONINFO size from app");
         return FALSE;
     }
     v->dwMajorVersion = VersionData[ver].getVersionEx.dwMajorVersion;
@@ -228,7 +229,7 @@
       break;
 
   default:
-      fprintf(stderr, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
+      ERR(ver, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
       break;
   }
   if (si.wProcessorLevel >= 4) result |= WF_HASCPUID;
@@ -245,8 +246,8 @@
  */
 BOOL16 WINAPI GetWinDebugInfo(WINDEBUGINFO *lpwdi, UINT16 flags)
 {
-    printf("GetWinDebugInfo(%8lx,%d) stub returning 0\n",
-           (unsigned long)lpwdi, flags);
+    FIXME(ver, "(%8lx,%d): stub returning 0\n",
+	  (unsigned long)lpwdi, flags);
     /* 0 means not in debugging mode/version */
     /* Can this type of debugging be used in wine ? */
     /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
@@ -259,7 +260,7 @@
  */
 BOOL16 WINAPI SetWinDebugInfo(WINDEBUGINFO *lpwdi)
 {
-    printf("SetWinDebugInfo(%8lx) stub returning 0\n", (unsigned long)lpwdi);
+    FIXME(ver, "(%8lx): stub returning 0\n", (unsigned long)lpwdi);
     /* 0 means not in debugging mode/version */
     /* Can this type of debugging be used in wine ? */
     /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
@@ -296,5 +297,6 @@
  */
 void WINAPI DiagOutput(LPCSTR str)
 {
-	fprintf(stderr,"DIAGOUTPUT:%s\n",str);
+        /* FIXME */
+	DPRINTF("DIAGOUTPUT:%s\n",str);
 }
diff --git a/misc/w32sys.c b/misc/w32sys.c
index 427b47e..fbf3940 100644
--- a/misc/w32sys.c
+++ b/misc/w32sys.c
@@ -8,12 +8,14 @@
 #include "windows.h"
 #include "w32sys.h"
 
-
 /***********************************************************************
  *           GetWin32sInfo   (W32SYS.12)
+ * RETURNS
+ *  0 on success, 1 on failure
  */
-WORD WINAPI GetWin32sInfo( LPWIN32SINFO lpInfo)
-{
+WORD WINAPI GetWin32sInfo(
+	LPWIN32SINFO lpInfo	/* [out] Win32S special information */
+) {
     lpInfo->bMajor = 1;
     lpInfo->bMinor = 3;
     lpInfo->wBuildNumber = 0;
@@ -21,3 +23,15 @@
 
     return 0;
 }
+
+/***********************************************************************
+ *           GetPEResourceTable   (W32SYS.7)
+ * retrieves the resourcetable from the passed filedescriptor
+ * RETURNS
+ *	dunno what.
+ */
+WORD WINAPI GetPEResourceTable(
+	HFILE16 hf		/* [in] filedescriptor to opened executeable */
+) {
+	return 0;
+}
diff --git a/misc/windebug.c b/misc/windebug.c
index 3f17f9b..9e54dfc 100644
--- a/misc/windebug.c
+++ b/misc/windebug.c
@@ -11,7 +11,7 @@
 #include "module.h"
 
 /***********************************************************************
- *           WinNotify       (WINDEBUG.1)
+ *           WinNotify       (WINDEBUG.3)
  *  written without _any_ docu
  */
 void WinNotify(CONTEXT *context)
diff --git a/misc/winsock.c b/misc/winsock.c
index ec78b4b..9f9fdcf 100644
--- a/misc/winsock.c
+++ b/misc/winsock.c
@@ -1704,7 +1704,7 @@
 
   if( pwsi )
     return __WSAsyncDBQuery(pwsi, hWnd, uMsg, type, addr, len,
-                            NULL, (void*)sbuf, buflen, WSMSG_ASYNC_HOSTBYADDR | WSMSG_ASYNC_WIN32);
+                            NULL, (void*)sbuf, buflen, WSMSG_ASYNC_HOSTBYADDR | WSMSG_WIN32_AOP);
   return 0;
 }
 
@@ -1738,7 +1738,7 @@
 	       (name)?name:NULL_STRING, (int)buflen );
   if( pwsi )
     return __WSAsyncDBQuery(pwsi, hWnd, uMsg, 0, name, 0,
- 			    NULL, (void*)sbuf, buflen, WSMSG_ASYNC_HOSTBYNAME | WSMSG_ASYNC_WIN32);
+ 			    NULL, (void*)sbuf, buflen, WSMSG_ASYNC_HOSTBYNAME | WSMSG_WIN32_AOP);
   return 0;
 }                     
 
@@ -1773,7 +1773,7 @@
 
   if( pwsi )
     return __WSAsyncDBQuery(pwsi, hWnd, uMsg, 0, name, 0,
-                            NULL, (void*)sbuf, buflen, WSMSG_ASYNC_PROTOBYNAME | WSMSG_ASYNC_WIN32);
+                            NULL, (void*)sbuf, buflen, WSMSG_ASYNC_PROTOBYNAME | WSMSG_WIN32_AOP);
   return 0;
 }
 
@@ -1808,7 +1808,7 @@
 
   if( pwsi )
     return __WSAsyncDBQuery(pwsi, hWnd, uMsg, number, NULL, 0,
-                            NULL, (void*)sbuf, buflen, WSMSG_ASYNC_PROTOBYNUM | WSMSG_ASYNC_WIN32);
+                            NULL, (void*)sbuf, buflen, WSMSG_ASYNC_PROTOBYNUM | WSMSG_WIN32_AOP);
   return 0;
 }
 
@@ -1853,7 +1853,7 @@
 
       if( i )
           return __WSAsyncDBQuery(pwsi, hWnd, uMsg, 0, pwsi->buffer, 0,
-                 pwsi->buffer + i, (void*)sbuf, buflen, WSMSG_ASYNC_SERVBYNAME | WSMSG_ASYNC_WIN32);
+                 pwsi->buffer + i, (void*)sbuf, buflen, WSMSG_ASYNC_SERVBYNAME | WSMSG_WIN32_AOP);
   }
   return 0;
 }
@@ -1898,7 +1898,7 @@
 
       if( i )
 	  return __WSAsyncDBQuery(pwsi, hWnd, uMsg, port, pwsi->buffer, 0,
-		 NULL, (void*)sbuf, buflen, WSMSG_ASYNC_SERVBYPORT | WSMSG_ASYNC_WIN32);
+		 NULL, (void*)sbuf, buflen, WSMSG_ASYNC_SERVBYPORT | WSMSG_WIN32_AOP);
   }
   return 0;
 }
@@ -2377,13 +2377,12 @@
       char type= *(unsigned char*)(inbuf+15); /* 0x2: don't fragment*/
 #endif      
       
-      fprintf(stdnimp,"WsControl(ICMP_ECHO) to 0x%08x stub \n",
-	      addr);
+      FIXME(winsock,"(ICMP_ECHO) to 0x%08x stub \n", addr);
       break;
     }
   default:
-    fprintf(stdnimp,"WsControl(%lx,%lx,%p,%p,%p,%p) stub\n",
-	    protocoll,action,inbuf,inbuflen,outbuf,outbuflen);
+    FIXME(winsock,"(%lx,%lx,%p,%p,%p,%p) stub\n",
+	  protocoll,action,inbuf,inbuflen,outbuf,outbuflen);
   }
   return FALSE;
 }
@@ -2392,8 +2391,8 @@
  */
 void WINAPI WS_s_perror(LPCSTR message)
 {
-    fprintf(stdnimp,"s_perror %s stub\n",message);
-	return;
+    FIXME(winsock,"(%s): stub\n",message);
+    return;
 }
 
 
@@ -2607,6 +2606,7 @@
 	case ENETUNREACH:	return WSAENETUNREACH;
 	case ENETRESET:		return WSAENETRESET;
 	case ECONNABORTED:	return WSAECONNABORTED;
+	case EPIPE:
 	case ECONNRESET:	return WSAECONNRESET;
 	case ENOBUFS:		return WSAENOBUFS;
 	case EISCONN:		return WSAEISCONN;
diff --git a/misc/winsock_dns.c b/misc/winsock_dns.c
index b00b4ef..8a42a79 100644
--- a/misc/winsock_dns.c
+++ b/misc/winsock_dns.c
@@ -43,8 +43,6 @@
 #define FASYNC FIOASYNC
 #endif
 
-#define __WS_ASYNC_DEBUG	0
-
 typedef struct          /* async DNS op control struct */
 {
   ws_async_op*  ws_aop;
@@ -135,7 +133,7 @@
 {
     /* SIGIO safe, hTask == 0 cancels all outstanding async ops */
 
-    int num = 0;
+    int num = 0, num_dead = 0;
     ws_async_op*   p, *next;
 
     TRACE(winsock," cancelling async DNS requests... \n");
@@ -149,13 +147,16 @@
 	next = p->next;
 	if(!hTask || !hWndTask || (hTask == hWndTask))
 	{
+	    num++;
+	    if( p->flags & WSMSG_DEAD_AOP )
+		num_dead++;
+
 	    WINSOCK_cancel_async_op(p);
 	    if( __opfree ) __opfree(p);
-	    num++;
 	}
     }
     SIGNAL_MaskAsyncEvents( FALSE );
-    TRACE(winsock," -> %i total\n", num );
+    TRACE(winsock," -> %i total (%i active)\n", num, num - num_dead );
 }
 
 void WINSOCK_link_async_op(ws_async_op* p_aop)
@@ -278,11 +279,11 @@
     {
 	if( (int)LOWORD(lLength) <= p_aop->buflen )
 	{
-            char* buffer = (p_aop->flags & WSMSG_ASYNC_WIN32)
+            char* buffer = (p_aop->flags & WSMSG_WIN32_AOP)
 		  ? p_aop->b.lin_base : (char*)PTR_SEG_TO_LIN(p_aop->b.seg_base);
 
             read(p_aop->fd[0], buffer, LOWORD(lLength));
-            switch( p_aop->flags )
+            switch( p_aop->flags & WSMSG_ASYNC_RQMASK )
             {
 		case WSMSG_ASYNC_HOSTBYNAME:
 		case WSMSG_ASYNC_HOSTBYADDR:
@@ -301,10 +302,10 @@
         else lLength =  ((UINT32)LOWORD(lLength)) | ((unsigned)WSAENOBUFS << 16);
     } /* failure */
 
-#if __WS_ASYNC_DEBUG
-    printf("DNS aop completed: hWnd [%04x], uMsg [%04x], aop [%04x], event [%08x]\n",
-         p_aop->hWnd, p_aop->uMsg, __ws_gethandle(p_aop), (LPARAM)lLength);
-#endif
+     /* was a __WS_ASYNC_DEBUG statement */
+     TRACE(winsock, "DNS aop completed: hWnd [%04x], uMsg [%04x], "
+ 	  "aop [%04x], event [%08lx]\n",
+ 	  p_aop->hWnd, p_aop->uMsg, __ws_gethandle(p_aop), (LPARAM)lLength);
 
     /* FIXME: update num_async_rq */
     EVENT_DeleteIO( p_aop->fd[0], EVENT_IO_READ );
@@ -366,7 +367,7 @@
 		/* child process */
 
 		close(async_ctl.ws_aop->fd[0]);  /* read endpoint */
-		switch( flag )
+		switch( flag & WSMSG_ASYNC_RQMASK )
 		{
 		    case WSMSG_ASYNC_HOSTBYADDR:
 		    case WSMSG_ASYNC_HOSTBYNAME:
@@ -403,9 +404,9 @@
     kill(getppid(), SIGIO);    /* simulate async I/O */
 #endif
 
-#if __WS_ASYNC_DEBUG
-    printf("handler - notify aop [%d, buf %d]\n", async_ctl.ilength, async_ctl.ws_aop->buflen);
-#endif
+    /* was a __WS_ASYNC_DEBUG statement */
+    TRACE(winsock, "handler - notify aop [%d, buf %d]\n", 
+	  async_ctl.ilength, async_ctl.ws_aop->buflen);
     return 1;
 }
 
@@ -421,9 +422,9 @@
      kill(getppid(), SIGIO);    /* simulate async I/O */
 #endif
 
-#if __WS_ASYNC_DEBUG
-    printf("handler - failed aop [%d, buf %d]\n", async_ctl.ilength, async_ctl.ws_aop->buflen);
-#endif
+    /* was a __WS_ASYNC_DEBUG statement */
+    TRACE(winsock, "handler - failed aop [%d, buf %d]\n", 
+	  async_ctl.ilength, async_ctl.ws_aop->buflen);
 }
 
 void dump_ws_hostent_offset(struct ws_hostent* wshe)
@@ -432,16 +433,16 @@
   char*		base = (char*)wshe;
   unsigned*	ptr;
 
-  printf("h_name = %08x\t[%s]\n", (unsigned)wshe->h_name, base + (unsigned)wshe->h_name);
-  printf("h_aliases = %08x\t[%08x]\n", (unsigned)wshe->h_aliases, 
-				       (unsigned)(base + (unsigned)wshe->h_aliases));
+  DUMP("h_name = %08x\t[%s]\n", 
+       (unsigned)wshe->h_name, base + (unsigned)wshe->h_name);
+  DUMP("h_aliases = %08x\t[%08x]\n", 
+       (unsigned)wshe->h_aliases, (unsigned)(base+(unsigned)wshe->h_aliases));
   ptr = (unsigned*)(base + (unsigned)wshe->h_aliases);
   for(i = 0; ptr[i]; i++ )
   {
-	printf("%i - %08x ", i + 1, ptr[i]);
-	printf(" [%s]\n", ((char*)base) + ptr[i]);
+	DUMP("%i - %08x [%s]\n", i + 1, ptr[i], ((char*)base) + ptr[i]);
   }
-  printf("h_length = %i\n", wshe->h_length);
+  DUMP("h_length = %i\n", wshe->h_length);
 }
 
 void WS_do_async_gethost(LPWSINFO pwsi, unsigned flag )
@@ -460,7 +461,7 @@
 
   if( p_he ) /* convert to the Winsock format with internal pointers as offsets */
       size = WS_dup_he(pwsi, p_he, WS_DUP_OFFSET | 
-		     ((flag & WSMSG_ASYNC_WIN32) ? WS_DUP_LINEAR : WS_DUP_SEGPTR) );
+		     ((flag & WSMSG_WIN32_AOP) ? WS_DUP_LINEAR : WS_DUP_SEGPTR) );
   if( size )
   {
       async_ctl.buffer = pwsi->buffer;
@@ -484,7 +485,7 @@
 
   if( p_pe ) /* convert to the Winsock format with internal pointers as offsets */
       size = WS_dup_pe(pwsi, p_pe, WS_DUP_OFFSET |
-		     ((flag & WSMSG_ASYNC_WIN32) ? WS_DUP_LINEAR : WS_DUP_SEGPTR) );
+		     ((flag & WSMSG_WIN32_AOP) ? WS_DUP_LINEAR : WS_DUP_SEGPTR) );
   if( size )
   {
       async_ctl.buffer = pwsi->buffer;
@@ -506,7 +507,7 @@
 
   if( p_se ) /* convert to the Winsock format with internal pointers as offsets */
       size = WS_dup_se(pwsi, p_se, WS_DUP_OFFSET |
-		      ((flag & WSMSG_ASYNC_WIN32) ? WS_DUP_LINEAR : WS_DUP_SEGPTR) );
+		      ((flag & WSMSG_WIN32_AOP) ? WS_DUP_LINEAR : WS_DUP_SEGPTR) );
   if( size )
   {
       async_ctl.buffer = pwsi->buffer;
@@ -518,14 +519,14 @@
 
 /* ----------------------------------- helper functions -
  *
- * Raw results from pipe contain internal pointers stored as
+ * Raw results from the pipe contain internal pointers stored as
  * offsets relative to the beginning of the buffer and we need
  * to apply a fixup before passing them to applications.
  *
  * NOTE: It is possible to exploit the fact that fork() doesn't 
  * change the buffer address by storing fixed up pointers right 
  * in the handler. However, this will get in the way if we ever 
- * get around to implementing DNS helper daemon a-la Netscape.
+ * get around to implementing DNS helper daemon a-la Netscape 4.x.
  */
 
 void fixup_wshe(struct ws_hostent* p_wshe, void* base)
diff --git a/msdos/dpmi.c b/msdos/dpmi.c
index 91466c1..5aea153 100644
--- a/msdos/dpmi.c
+++ b/msdos/dpmi.c
@@ -213,14 +213,12 @@
     }
 
     if (EFL_reg(context)&1)
-        fprintf(stdnimp,
-                "RealModeInt %02x: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n"
-                "                ESI=%08lx EDI=%08lx DS=%04lx ES=%04lx\n",
-                BL_reg(context), EAX_reg(&realmode_ctx),
-                EBX_reg(&realmode_ctx), ECX_reg(&realmode_ctx),
-                EDX_reg(&realmode_ctx), ESI_reg(&realmode_ctx),
-                EDI_reg(&realmode_ctx), DS_reg(&realmode_ctx),
-                ES_reg(&realmode_ctx) );
+      FIXME(int31,"%02x: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n",
+	    BL_reg(context), EAX_reg(&realmode_ctx), EBX_reg(&realmode_ctx), 
+	    ECX_reg(&realmode_ctx), EDX_reg(&realmode_ctx));
+      FIXME(int31,"      ESI=%08lx EDI=%08lx DS=%04lx ES=%04lx\n",
+	    ESI_reg(&realmode_ctx), EDI_reg(&realmode_ctx), 
+	    DS_reg(&realmode_ctx), ES_reg(&realmode_ctx) );
     INT_SetRealModeContext( call, &realmode_ctx );
 }
 
@@ -359,17 +357,12 @@
         SET_CFLAG(context);
         break;
     case 0x0200: /* get real mode interrupt vector */
-	fprintf(stdnimp,
-		"int31: get realmode interupt vector(0x%02x) unimplemented.\n",
-		BL_reg(context)
-	);
+	FIXME(int31,"get realmode interupt vector(0x%02x) unimplemented.\n",
+	      BL_reg(context));
     	SET_CFLAG(context);
         break;
     case 0x0201: /* set real mode interrupt vector */
-	fprintf(stdnimp,
-		"int31: set realmode interupt vector(0x%02x,0x%04x:0x%04x) unimplemented\n",
-		BL_reg(context),CX_reg(context),DX_reg(context)
-	);
+	FIXME(int31, "set realmode interupt vector(0x%02x,0x%04x:0x%04x) unimplemented\n", BL_reg(context),CX_reg(context),DX_reg(context));
     	SET_CFLAG(context);
         break;
     case 0x0204:  /* Get protected mode interrupt vector */
@@ -391,11 +384,10 @@
     case 0x0301:  /* Call real mode procedure with far return */
         {
             REALMODECALL *p = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( ES_reg(context), DI_reg(context) );
-            fprintf(stdnimp,
-                    "RealModeCall: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n"
-                    "              ESI=%08lx EDI=%08lx ES=%04x DS=%04x CS:IP=%04x:%04x\n",
-                    p->eax, p->ebx, p->ecx, p->edx,
-                    p->esi, p->edi, p->es, p->ds, p->cs, p->ip );
+            FIXME(int31, "RealModeCall: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n",
+		p->eax, p->ebx, p->ecx, p->edx);
+            FIXME(int31, "              ESI=%08lx EDI=%08lx ES=%04x DS=%04x CS:IP=%04x:%04x\n",
+		p->esi, p->edi, p->es, p->ds, p->cs, p->ip );
             SET_CFLAG(context);
         }
         break;
@@ -403,11 +395,8 @@
     case 0x0302:  /* Call real mode procedure with interrupt return */
         {
             REALMODECALL *p = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( ES_reg(context), DI_reg(context) );
-            fprintf(stdnimp,
-                    "RealModeCallIret: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n"
-                    "                  ESI=%08lx EDI=%08lx ES=%04x DS=%04x CS:IP=%04x:%04x\n",
-                    p->eax, p->ebx, p->ecx, p->edx,
-                    p->esi, p->edi, p->es, p->ds, p->cs, p->ip );
+            FIXME(int31, "RealModeCallIret: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n", p->eax, p->ebx, p->ecx, p->edx);
+            FIXME(int31, "                  ESI=%08lx EDI=%08lx ES=%04x DS=%04x CS:IP=%04x:%04x\n", p->esi, p->edi, p->es, p->ds, p->cs, p->ip );
             SET_CFLAG(context);
         }
         break;
@@ -415,22 +404,18 @@
     case 0x0303:  /* Allocate Real Mode Callback Address */
         {
             REALMODECALL *p = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( ES_reg(context), DI_reg(context) );
-            fprintf(stdnimp,
-                    "AllocRMCB: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n"
-                    "           ESI=%08lx EDI=%08lx ES=%04x DS=%04x CS:IP=%04x:%04x\n"
-		    "	Function to call: %04x:%04x\n",
-                    p->eax, p->ebx, p->ecx, p->edx,
-                    p->esi, p->edi, p->es, p->ds, p->cs, p->ip,
-		    (WORD)DS_reg(context), SI_reg(context) );
+            FIXME(int31, "AllocRMCB: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n", p->eax, p->ebx, p->ecx, p->edx);
+	    FIXME(int31, "           ESI=%08lx EDI=%08lx ES=%04x DS=%04x CS:IP=%04x:%04x\n", p->esi, p->edi, p->es, p->ds, p->cs, p->ip);
+	    FIXME(int31, "           Function to call: %04x:%04x\n",
+		(WORD)DS_reg(context), SI_reg(context) );
             SET_CFLAG(context);
         }
         break;
 
     case 0x0304:  /* Free Real Mode Callback Address */
 	{
-	    fprintf(stdnimp,
-		    "FreeRMCB: callback address: %04x:%04x\n",
-		    CX_reg(context), DX_reg(context));
+	    FIXME(int31, "FreeRMCB: callback address: %04x:%04x\n",
+		  CX_reg(context), DX_reg(context));
 	    SET_CFLAG(context);
 	}
 	break;
diff --git a/msdos/int21.c b/msdos/int21.c
index ce1b51c..e226cc1 100644
--- a/msdos/int21.c
+++ b/msdos/int21.c
@@ -209,7 +209,8 @@
     TRACE(int21, "(%d)\n", BX_reg(context));
     
     curr_drive = DRIVE_GetCurrentDrive();
-    DX_reg(context) = 0x0140 + curr_drive + ((curr_drive > 1) ? 0x0800 : 0); /* no floppy */
+    DX_reg(context) = 0x0140 + curr_drive + ((curr_drive > 1) ? 0x0800 : 0); 
+    /* no floppy */
     /* bits 0-5 are current drive
      * bit 6 - file has NOT been written..FIXME: correct?
      * bit 8 - generate int24 if no diskspace on write/ read past end of file
@@ -305,6 +306,22 @@
     DX_reg(context) = (systime.wSecond << 8) | (systime.wMilliseconds / 10);
 }
 
+/* Many calls translate a drive argument like this:
+   drive number (00h = default, 01h = A:, etc)
+   */  
+static char drivestring[]="default";
+
+char *INT21_DriveName(int drive)
+{
+
+    if(drive >0)
+      {
+	drivestring[0]= (unsigned char)drive + '@';
+	drivestring[1]=':';
+	drivestring[2]=0;
+      }
+    return drivestring;
+}
 static BOOL32 INT21_CreateFile( CONTEXT *context )
 {
     AX_reg(context) = _lcreat16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
@@ -356,7 +373,7 @@
 	  int result,retries=sharing_retries;
 	  {
 #if defined(__svr4__) || defined(_SCO_DS)
-              printf("Should call flock and needs porting to lockf\n");
+              ERR(int21, "Should call flock and needs porting to lockf\n");
               result = 0;
               retries = 0;
 #else
@@ -760,12 +777,12 @@
 
 static void DeleteFileFCB( CONTEXT *context )
 {
-    fprintf( stderr, "DeleteFileFCB: not implemented yet\n" );
+    FIXME(int21, "(%p): not implemented yet\n", context);
 }
 
 static void RenameFileFCB( CONTEXT *context )
 {
-    fprintf( stderr, "RenameFileFCB: not implemented yet\n" );
+    FIXME(int21, "(%p): not implemented yet\n", context);
 }
 
 
@@ -776,6 +793,10 @@
     switch ( AX_reg(context) & 0xff )
     {
         case 0x00: /* LOCK */
+	  TRACE(int21,"lock handle %d offset %ld length %ld\n",
+		BX_reg(context),
+		MAKELONG(DX_reg(context),CX_reg(context)),
+		MAKELONG(DI_reg(context),SI_reg(context))) ;
 	  if (!LockFile(BX_reg(context),
                         MAKELONG(DX_reg(context),CX_reg(context)), 0,
                         MAKELONG(DI_reg(context),SI_reg(context)), 0)) {
@@ -785,6 +806,10 @@
           break;
 
 	case 0x01: /* UNLOCK */
+	  TRACE(int21,"unlock handle %d offset %ld length %ld\n",
+		BX_reg(context),
+		MAKELONG(DX_reg(context),CX_reg(context)),
+		MAKELONG(DI_reg(context),SI_reg(context))) ;
 	  if (!UnlockFile(BX_reg(context),
                           MAKELONG(DX_reg(context),CX_reg(context)), 0,
                           MAKELONG(DI_reg(context),SI_reg(context)), 0)) {
@@ -866,15 +891,17 @@
 {
     BOOL32	bSetDOSExtendedError = FALSE;
 
-    TRACE(int21, "AX=%04x BX=%04x CX=%04x DX=%04x "
+    /*    TRACE(int21, "AX=%04x BX=%04x CX=%04x DX=%04x "
                  "SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
                  AX_reg(context), BX_reg(context), CX_reg(context),
                  DX_reg(context), SI_reg(context), DI_reg(context),
                  (WORD)DS_reg(context), (WORD)ES_reg(context),
                  EFL_reg(context) );
-
+		 */
     if (AH_reg(context) == 0x59)  /* Get extended error info */
     {
+        TRACE(int21, "GET EXTENDED ERROR code 0x%02x class 0x%02x action 0x%02x locus %02x\n",
+	      DOS_ExtendedError, DOS_ErrorClass, DOS_ErrorAction, DOS_ErrorLocus);
         AX_reg(context) = DOS_ExtendedError;
         BH_reg(context) = DOS_ErrorClass;
         BL_reg(context) = DOS_ErrorAction;
@@ -888,6 +915,7 @@
     switch(AH_reg(context)) 
     {
     case 0x00: /* TERMINATE PROGRAM */
+        TRACE(int21,"TERMINATE PROGRAM\n");
         TASK_KillCurrentTask( 0 );
         break;
 
@@ -920,9 +948,13 @@
                   "SWITCHAR" - SET SWITCH CHARACTER
                   "AVAILDEV" - SPECIFY \DEV\ PREFIX USE */
     case 0x54: /* GET VERIFY FLAG */
+    case 0x48: /* ALLOCATE MEMORY */
+    case 0x49: /* FREE MEMORY */
+    case 0x4a: /* RESIZE MEMORY BLOCK */
         INT_BARF( context, 0x21 );
         break;
     case 0x2e: /* SET VERIFY FLAG */
+        TRACE(int21,"SET VERIFY FLAG ignored\n");
     	/* we cannot change the behaviour anyway, so just ignore it */
     	break;
 
@@ -939,15 +971,19 @@
         break;
 
     case 0x0d: /* DISK BUFFER FLUSH */
+	TRACE(int21,"DISK BUFFER FLUSH ignored\n");
         RESET_CFLAG(context); /* dos 6+ only */
         break;
 
     case 0x0e: /* SELECT DEFAULT DRIVE */
+	TRACE(int21,"SELECT DEFAULT DRIVE %d\n", DL_reg(context));
         DRIVE_SetCurrentDrive( DL_reg(context) );
         AL_reg(context) = MAX_DOS_DRIVES;
         break;
 
     case 0x11: /* FIND FIRST MATCHING FILE USING FCB */
+	TRACE(int21,"FIND FIRST MATCHING FILE USING FCB %p\n", 
+	      PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context)));
         if (!INT21_FindFirstFCB(context))
         {
             AL_reg(context) = 0xff;
@@ -1003,8 +1039,8 @@
         break;
 
     case 0x2b: /* SET SYSTEM DATE */
-        fprintf( stdnimp, "SetSystemDate(%02d/%02d/%04d): not allowed\n",
-                 DL_reg(context), DH_reg(context), CX_reg(context) );
+        FIXME(int21, "SetSystemDate(%02d/%02d/%04d): not allowed\n",
+	      DL_reg(context), DH_reg(context), CX_reg(context) );
         AL_reg(context) = 0;  /* Let's pretend we succeeded */
         break;
 
@@ -1013,13 +1049,14 @@
         break;
 
     case 0x2d: /* SET SYSTEM TIME */
-        fprintf( stdnimp, "SetSystemTime(%02d:%02d:%02d.%02d): not allowed\n",
-                 CH_reg(context), CL_reg(context),
-                 DH_reg(context), DL_reg(context) );
+        FIXME(int21, "SetSystemTime(%02d:%02d:%02d.%02d): not allowed\n",
+	      CH_reg(context), CL_reg(context),
+	      DH_reg(context), DL_reg(context) );
         AL_reg(context) = 0;  /* Let's pretend we succeeded */
         break;
 
     case 0x2f: /* GET DISK TRANSFER AREA ADDRESS */
+        TRACE(int21,"GET DISK TRANSFER AREA ADDRESS\n");
         {
             TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
             ES_reg(context) = SELECTOROF( pTask->dta );
@@ -1028,6 +1065,8 @@
         break;
             
     case 0x30: /* GET DOS VERSION */
+        TRACE(int21,"GET DOS VERSION %s requested\n",
+	      (AL_reg(context) == 0x00)?"OEM number":"version flag");
         AX_reg(context) = (HIWORD(GetVersion16()) >> 8) |
                           (HIWORD(GetVersion16()) << 8);
         BX_reg(context) = 0x0012;     /* 0x123456 is Wine's serial # */
@@ -1035,10 +1074,13 @@
         break;
 
     case 0x31: /* TERMINATE AND STAY RESIDENT */
+        TRACE(int21,"TERMINATE AND STAY RESIDENT stub\n");
         INT_BARF( context, 0x21 );
         break;
 
     case 0x32: /* GET DOS DRIVE PARAMETER BLOCK FOR SPECIFIC DRIVE */
+        TRACE(int21,"GET DOS DRIVE PARAMETER BLOCK FOR DRIVE %s\n",
+	      INT21_DriveName( DL_reg(context)));
         GetDrivePB(context, DOS_GET_DRIVE( DL_reg(context) ) );
         break;
 
@@ -1046,22 +1088,27 @@
         switch (AL_reg(context))
         {
 	      case 0x00: /* GET CURRENT EXTENDED BREAK STATE */
+		TRACE(int21,"GET CURRENT EXTENDED BREAK STATE stub\n");
                 DL_reg(context) = 0;
 		break;
 
 	      case 0x01: /* SET EXTENDED BREAK STATE */
+		TRACE(int21,"SET CURRENT EXTENDED BREAK STATE stub\n");
 		break;		
 		
 	      case 0x02: /* GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE*/
+		TRACE(int21,"GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE stub\n");
 		DL_reg(context) = 0;
 		break;
 
 	      case 0x05: /* GET BOOT DRIVE */
+		TRACE(int21,"GET BOOT DRIVE\n");
 		DL_reg(context) = 3;
 		/* c: is Wine's bootdrive (a: is 1)*/
 		break;
 				
 	      case 0x06: /* GET TRUE VERSION NUMBER */
+		TRACE(int21,"GET TRUE VERSION NUMBER\n");
 		BX_reg(context) = (HIWORD(GetVersion16() >> 8)) |
                                   (HIWORD(GetVersion16() << 8));
 		DX_reg(context) = 0x00;
@@ -1074,12 +1121,14 @@
         break;	
 	    
     case 0x34: /* GET ADDRESS OF INDOS FLAG */
+        TRACE(int21,"GET ADDRESS OF INDOS FLAG\n");
         if (!heap) INT21_CreateHeap();
         ES_reg(context) = DosHeapHandle;
         BX_reg(context) = (int)&heap->InDosFlag - (int)heap;
         break;
 
     case 0x35: /* GET INTERRUPT VECTOR */
+        TRACE(int21,"GET INTERRUPT VECTOR 0x%02x\n",AL_reg(context));
         {
             FARPROC16 addr = INT_GetHandler( AL_reg(context) );
             ES_reg(context) = SELECTOROF(addr);
@@ -1088,43 +1137,60 @@
         break;
 
     case 0x36: /* GET FREE DISK SPACE */
+	TRACE(int21,"GET FREE DISK SPACE FOR DRIVE %s\n",
+	      INT21_DriveName( DL_reg(context)));
         if (!INT21_GetFreeDiskSpace(context)) AX_reg(context) = 0xffff;
         break;
 
     case 0x38: /* GET COUNTRY-SPECIFIC INFORMATION */
+	TRACE(int21,"GET COUNTRY-SPECIFIC INFORMATION for country 0x%02x\n",
+	      AL_reg(context));
         AX_reg(context) = 0x02; /* no country support available */
         SET_CFLAG(context);
         break;
 
     case 0x39: /* "MKDIR" - CREATE SUBDIRECTORY */
+        TRACE(int21,"MKDIR %s\n",
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
         bSetDOSExtendedError = (!CreateDirectory16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
                                                            DX_reg(context) ), NULL));
         break;
 	
     case 0x3a: /* "RMDIR" - REMOVE SUBDIRECTORY */
+        TRACE(int21,"RMDIR %s\n",
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
         bSetDOSExtendedError = (!RemoveDirectory16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
                                                                  DX_reg(context) )));
         break;
 
     case 0x3b: /* "CHDIR" - SET CURRENT DIRECTORY */
+        TRACE(int21,"CHDIR %s\n",
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
         bSetDOSExtendedError = !INT21_ChangeDir(context);
         break;
 	
     case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
+        TRACE(int21,"CREAT flag 0x%02x %s\n",CX_reg(context),
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
         AX_reg(context) = _lcreat16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
                                     DX_reg(context) ), CX_reg(context) );
         bSetDOSExtendedError = (AX_reg(context) == (WORD)HFILE_ERROR16);
         break;
 
     case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
+        TRACE(int21,"OPEN mode 0x%02x %s\n",AL_reg(context),
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
         OpenExistingFile(context);
         break;
 
     case 0x3e: /* "CLOSE" - CLOSE FILE */
+        TRACE(int21,"CLOSE handle %d\n",BX_reg(context));
         bSetDOSExtendedError = ((AX_reg(context) = _lclose16( BX_reg(context) )) != 0);
         break;
 
     case 0x3f: /* "READ" - READ FROM FILE OR DEVICE */
+        TRACE(int21,"READ from %d to %ld for %d byte\n",BX_reg(context),
+	      PTR_SEG_OFF_TO_SEGPTR( DS_reg(context),DX_reg(context)),CX_reg(context) );
         {
             LONG result = WIN16_hread( BX_reg(context),
                                        PTR_SEG_OFF_TO_SEGPTR( DS_reg(context),
@@ -1136,6 +1202,9 @@
         break;
 
     case 0x40: /* "WRITE" - WRITE TO FILE OR DEVICE */
+        TRACE(int21,"WRITE from %ld to handle %d for %d byte\n",
+	      PTR_SEG_OFF_TO_SEGPTR( DS_reg(context),DX_reg(context)),
+	      BX_reg(context),CX_reg(context) );
         {
             LONG result = _hwrite16( BX_reg(context),
                                      PTR_SEG_OFF_TO_LIN( DS_reg(context),
@@ -1147,11 +1216,17 @@
         break;
 
     case 0x41: /* "UNLINK" - DELETE FILE */
+        TRACE(int21,"UNLINK%s\n",
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
         bSetDOSExtendedError = (!DeleteFile32A( PTR_SEG_OFF_TO_LIN( DS_reg(context),
                                                              DX_reg(context) )));
         break;
 
     case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */
+        TRACE(int21,"LSEEK handle %d offset %ld from %s\n",
+	      BX_reg(context), MAKELONG(DX_reg(context),CX_reg(context)),
+	      (AL_reg(context)==0)?"start of file":(AL_reg(context)==1)?
+	      "current file position":"end of file");
         {
             LONG status = _llseek16( BX_reg(context),
                                      MAKELONG(DX_reg(context),CX_reg(context)),
@@ -1169,6 +1244,8 @@
         switch (AL_reg(context))
         {
         case 0x00:
+            TRACE(int21,"GET FILE ATTRIBUTES for %s\n", 
+		  (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
             AX_reg(context) = (WORD)GetFileAttributes32A(
                                           PTR_SEG_OFF_TO_LIN(DS_reg(context),
                                                              DX_reg(context)));
@@ -1177,11 +1254,16 @@
             break;
 
         case 0x01:
+            TRACE(int21,"SET FILE ATTRIBUTES 0x%02x for %s\n", CX_reg(context),
+		  (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
             bSetDOSExtendedError = 
 		(!SetFileAttributes32A( PTR_SEG_OFF_TO_LIN(DS_reg(context), 
 							   DX_reg(context)),
                                        			   CX_reg(context) ));
             break;
+        case 0x02:
+            TRACE(int21,"GET COMPRESSED FILE SIZE for %s stub\n",
+		  (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
         }
         break;
 	
@@ -1196,17 +1278,18 @@
             break;
 	case 0x05:{	/* IOCTL - WRITE TO BLOCK DEVICE CONTROL CHANNEL */
 	    BYTE *dataptr = PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context));
-	    int	i;
 	    int	drive = DOS_GET_DRIVE(BL_reg(context));
 
-	    fprintf(stdnimp,"program tried to write to block device control channel of drive %d:\n",drive);
-	    for (i=0;i<CX_reg(context);i++)
+	    FIXME(int21,"program tried to write to block device control channel of drive %d:\n",drive);
+	    /* for (i=0;i<CX_reg(context);i++)
 	    	fprintf(stdnimp,"%02x ",dataptr[i]);
-	    fprintf(stdnimp,"\n");
+	    fprintf(stdnimp,"\n");*/
 	    AX_reg(context)=CX_reg(context);
 	    break;
 	}
         case 0x08:   /* Check if drive is removable. */
+            TRACE(int21,"IOCTL - CHECK IF BLOCK DEVICE REMOVABLE for drive %s\n",
+		 INT21_DriveName( BL_reg(context)));
             switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) )))
             {
             case DRIVE_CANNOTDETERMINE:
@@ -1224,6 +1307,8 @@
             break;
 
         case 0x09:   /* CHECK IF BLOCK DEVICE REMOTE */
+            TRACE(int21,"IOCTL - CHECK IF BLOCK DEVICE REMOTE for drive %s\n",
+		 INT21_DriveName( BL_reg(context))); 
             switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) )))
             {
             case DRIVE_CANNOTDETERMINE:
@@ -1241,6 +1326,7 @@
             break;
 
         case 0x0a: /* check if handle (BX) is remote */
+            TRACE(int21,"IOCTL - CHECK IF HANDLE %d IS REMOTE\n",BX_reg(context));
             /* returns DX, bit 15 set if remote, bit 14 set if date/time
              * not set on close
              */
@@ -1248,6 +1334,8 @@
             break;
 
         case 0x0b:   /* SET SHARING RETRY COUNT */
+            TRACE(int21,"IOCTL - SET SHARING RETRY COUNT pause %d retries %d\n",
+		 CX_reg(context), DX_reg(context));
             if (!CX_reg(context))
             { 
                 AX_reg(context) = 1;
@@ -1261,16 +1349,22 @@
             break;
 
         case 0x0d:
+            TRACE(int21,"IOCTL - GENERIC BLOCK DEVICE REQUEST %s\n",
+		  INT21_DriveName( BL_reg(context)));
             bSetDOSExtendedError = ioctlGenericBlkDevReq(context);
             break;
 
 	case 0x0e: /* get logical drive mapping */
+            TRACE(int21,"IOCTL - GET LOGICAL DRIVE MAP for drive %s\n",
+		  INT21_DriveName( BL_reg(context)));
 	    AL_reg(context) = 0; /* drive has no mapping - FIXME: may be wrong*/
 	    break;
 
         case 0x0F:   /* Set logical drive mapping */
 	    {
 	    int drive;
+            TRACE(int21,"IOCTL - SET LOGICAL DRIVE MAP for drive %s\n",
+		  INT21_DriveName( BL_reg(context))); 
 	    drive = DOS_GET_DRIVE ( BL_reg(context) );
 	    if ( ! DRIVE_SetLogicalMapping ( drive, drive+1 ) )
 	    {
@@ -1287,24 +1381,25 @@
         break;
 
     case 0x45: /* "DUP" - DUPLICATE FILE HANDLE */
+        TRACE(int21,"DUP - DUPLICATE FILE HANDLE %d\n",BX_reg(context));
         bSetDOSExtendedError = ((AX_reg(context) = FILE_Dup(BX_reg(context))) == (WORD)HFILE_ERROR16);
         break;
 
     case 0x46: /* "DUP2", "FORCEDUP" - FORCE DUPLICATE FILE HANDLE */
+        TRACE(int21,"FORCEDUP - FORCE DUPLICATE FILE HANDLE %d to %d\n",
+	      BX_reg(context),CX_reg(context));
         bSetDOSExtendedError = (FILE_Dup2( BX_reg(context), CX_reg(context) ) == HFILE_ERROR32);
         break;
 
     case 0x47: /* "CWD" - GET CURRENT DIRECTORY */
+        TRACE(int21,"CWD - GET CURRENT DIRECTORY for drive %s\n",
+	      INT21_DriveName( DL_reg(context)));
         bSetDOSExtendedError = !INT21_GetCurrentDirectory(context);
         break;
 
-    case 0x48: /* ALLOCATE MEMORY */
-    case 0x49: /* FREE MEMORY */
-    case 0x4a: /* RESIZE MEMORY BLOCK */
-        INT_BARF( context, 0x21 );
-        break;
-	
     case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */
+        TRACE(int21,"EXEC %s\n",
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context),DX_reg(context) ));
         AX_reg(context) = WinExec16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
                                                          DX_reg(context) ),
                                      SW_NORMAL );
@@ -1312,18 +1407,23 @@
         break;		
 	
     case 0x4c: /* "EXIT" - TERMINATE WITH RETURN CODE */
+        TRACE(int21,"EXIT with return code %d\n",AL_reg(context));
         TASK_KillCurrentTask( AL_reg(context) );
         break;
 
     case 0x4d: /* GET RETURN CODE */
+        TRACE(int21,"GET RETURN CODE (ERRORLEVEL)\n");
         AX_reg(context) = 0; /* normal exit */
         break;
 
     case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */
+        TRACE(int21,"FINDFIRST mask 0x%04x spec %s\n",CX_reg(context),
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
         if (!INT21_FindFirst(context)) break;
         /* fall through */
 
     case 0x4f: /* "FINDNEXT" - FIND NEXT MATCHING FILE */
+        TRACE(int21,"FINDNEXT\n");
         if (!INT21_FindNext(context))
         {
             DOS_ERROR( ER_NoMoreFiles, EC_MediaError, SA_Abort, EL_Disk );
@@ -1334,13 +1434,20 @@
         break;
 
     case 0x51: /* GET PSP ADDRESS */
+        TRACE(int21,"GET CURRENT PROCESS ID (GET PSP ADDRESS)\n");
+        /* FIXME: should we return the original DOS PSP upon */
+        /*        Windows startup ? */
+        BX_reg(context) = GetCurrentPDB();
+        break;
     case 0x62: /* GET PSP ADDRESS */
+        TRACE(int21,"GET CURRENT PSP ADDRESS\n");
         /* FIXME: should we return the original DOS PSP upon */
         /*        Windows startup ? */
         BX_reg(context) = GetCurrentPDB();
         break;
 
     case 0x52: /* "SYSVARS" - GET LIST OF LISTS */
+        TRACE(int21,"SYSVARS - GET LIST OF LISTS\n");
         {
                 SEGPTR lol;
                 lol = INT21_GetListOfLists();
@@ -1350,6 +1457,9 @@
         break;
 
     case 0x56: /* "RENAME" - RENAME FILE */
+        TRACE(int21,"RENAME %s to %s\n",
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)),
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN(ES_reg(context),DI_reg(context)));
         bSetDOSExtendedError = 
 		(!MoveFile32A( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)),
 			       PTR_SEG_OFF_TO_LIN(ES_reg(context),DI_reg(context))));
@@ -1361,6 +1471,8 @@
         case 0x00:  /* Get */
             {
                 FILETIME filetime;
+                TRACE(int21,"GET FILE DATE AND TIME for handle %d\n",
+		      BX_reg(context));
                 if (!GetFileTime( BX_reg(context), NULL, NULL, &filetime ))
 		     bSetDOSExtendedError = TRUE;
                 else FileTimeToDosDateTime( &filetime, &DX_reg(context),
@@ -1371,6 +1483,8 @@
         case 0x01:  /* Set */
             {
                 FILETIME filetime;
+                TRACE(int21,"SET FILE DATE AND TIME for handle %d\n",
+		      BX_reg(context));
                 DosDateTimeToFileTime( DX_reg(context), CX_reg(context),
                                        &filetime );
                 bSetDOSExtendedError = 
@@ -1381,6 +1495,8 @@
         break;
 
     case 0x58: /* GET OR SET MEMORY/UMB ALLOCATION STRATEGY */
+	TRACE(int21,"GET OR SET MEMORY/UMB ALLOCATION STRATEGY subfunction %d\n",
+	      AL_reg(context));
         switch (AL_reg(context))
         {
         case 0x00:
@@ -1397,10 +1513,13 @@
         break;
 
     case 0x5a: /* CREATE TEMPORARY FILE */
+        TRACE(int21,"CREATE TEMPORARY FILE\n");
         bSetDOSExtendedError = !INT21_CreateTempFile(context);
         break;
 
     case 0x5b: /* CREATE NEW FILE */
+        TRACE(int21,"CREATE NEW FILE 0x%02x for %s\n", CX_reg(context),
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)));
         bSetDOSExtendedError = ((AX_reg(context) = 
 		_lcreat_uniq( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)), 0 )) 
 								== (WORD)HFILE_ERROR16);
@@ -1408,6 +1527,7 @@
 
     case 0x5d: /* NETWORK */
     case 0x5e:
+        TRACE(int21,"Network function AX=%04x\n",AX_reg(context));
         /* network software not installed */
         DOS_ERROR( ER_NoNetwork, EC_NotFound, SA_Abort, EL_Network );
 	bSetDOSExtendedError = TRUE;
@@ -1417,6 +1537,7 @@
         switch (AL_reg(context))
         {
         case 0x07: /* ENABLE DRIVE */
+            TRACE(int21,"ENABLE DRIVE %c:\n",(DL_reg(context)+'A'));
             if (!DRIVE_Enable( DL_reg(context) ))
             {
                 DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
@@ -1425,6 +1546,7 @@
             break;
 
         case 0x08: /* DISABLE DRIVE */
+            TRACE(int21,"DISABLE DRIVE %c:\n",(DL_reg(context)+'A'));
             if (!DRIVE_Disable( DL_reg(context) ))
             {
                 DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
@@ -1434,6 +1556,7 @@
 
         default:
             /* network software not installed */
+            TRACE(int21,"NETWORK function AX=%04x not implemented\n",AX_reg(context));
             DOS_ERROR( ER_NoNetwork, EC_NotFound, SA_Abort, EL_Network );
 	    bSetDOSExtendedError = TRUE;
             break;
@@ -1441,6 +1564,8 @@
         break;
 
     case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */
+        TRACE(int21,"TRUENAME %s\n",
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN(DS_reg(context),SI_reg(context)));
         {
             if (!GetFullPathName32A( PTR_SEG_OFF_TO_LIN(DS_reg(context),
                                                         SI_reg(context)), 128,
@@ -1460,20 +1585,25 @@
 
     case 0x65:{/* GET EXTENDED COUNTRY INFORMATION */
     	extern WORD WINE_LanguageId;
-	BYTE    *dataptr=PTR_SEG_OFF_TO_LIN(ES_reg(context),DI_reg(context));;
+	BYTE    *dataptr=PTR_SEG_OFF_TO_LIN(ES_reg(context),DI_reg(context));
+	TRACE(int21,"GET EXTENDED COUNTRY INFORMATION code page %d country %d\n",
+	      BX_reg(context), DX_reg(context));
     	switch (AL_reg(context)) {
 	case 0x01:
+	    TRACE(int21,"\tget general internationalization info\n");
 	    dataptr[0] = 0x1;
 	    *(WORD*)(dataptr+1) = 41;
 	    *(WORD*)(dataptr+3) = WINE_LanguageId;
 	    *(WORD*)(dataptr+5) = CodePage;
 	    break;
 	case 0x06:
+	    TRACE(int21,"\tget pointer to collating sequence table\n");
 	    dataptr[0] = 0x06;
 	    *(DWORD*)(dataptr+1) = MAKELONG(DOSMEM_CollateTable & 0xFFFF,DOSMEM_AllocSelector(DOSMEM_CollateTable>>16));
 	    CX_reg(context)         = 258;/*FIXME: size of table?*/
 	    break;
 	default:
+	    TRACE(int21,"\tunimplemented function %d\n",AL_reg(context));
             INT_BARF( context, 0x21 );
             SET_CFLAG(context);
     	    break;
@@ -1484,10 +1614,13 @@
         switch (AL_reg(context))
         {
         case 0x01:
+	    TRACE(int21,"GET GLOBAL CODE PAGE TABLE\n");
             DX_reg(context) = BX_reg(context) = CodePage;
             RESET_CFLAG(context);
             break;			
         case 0x02: 
+	    TRACE(int21,"SET GLOBAL CODE PAGE TABLE active page %d system page %d\n",
+		  BX_reg(context),DX_reg(context));
             CodePage = BX_reg(context);
             RESET_CFLAG(context);
             break;
@@ -1495,12 +1628,14 @@
         break;
 
     case 0x67: /* SET HANDLE COUNT */
+        TRACE(int21,"SET HANDLE COUNT to %d\n",BX_reg(context) );
         SetHandleCount16( BX_reg(context) );
         if (DOS_ExtendedError) bSetDOSExtendedError = TRUE;
         break;
 
     case 0x68: /* "FFLUSH" - COMMIT FILE */
     case 0x6a: /* COMMIT FILE */
+        TRACE(int21,"FFLUSH/COMMIT handle %d\n",BX_reg(context));
         bSetDOSExtendedError = (!FlushFileBuffers( BX_reg(context) ));
         break;		
 	
@@ -1508,11 +1643,15 @@
         switch (AL_reg(context))
         {
         case 0x00:
+	    TRACE(int21,"GET DISK SERIAL NUMBER for drive %s\n",
+		  INT21_DriveName(BL_reg(context)));
             if (!INT21_GetDiskSerialNumber(context)) bSetDOSExtendedError = TRUE;
             else AX_reg(context) = 0;
             break;
 
         case 0x01:
+	    TRACE(int21,"SET DISK SERIAL NUMBER for drive %s\n",
+		  INT21_DriveName(BL_reg(context)));
             if (!INT21_SetDiskSerialNumber(context)) bSetDOSExtendedError = TRUE;
             else AX_reg(context) = 1;
             break;
@@ -1520,6 +1659,8 @@
         break;
     
     case 0x6C: /* Extended Open/Create*/
+        TRACE(int21,"EXTENDED OPEN/CREATE %s\n",
+	      (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DI_reg(context)));
         bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context);
         break;
 	
@@ -1527,33 +1668,40 @@
         switch(AL_reg(context))
         {
         case 0x39:  /* Create directory */
+	    TRACE(int21,"LONG FILENAME - MAKE DIRECTORY %s\n",
+		  (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context),DX_reg(context)));
             bSetDOSExtendedError = (!CreateDirectory32A( 
 					PTR_SEG_OFF_TO_LIN( DS_reg(context),
                                                   DX_reg(context) ), NULL));
             break;
         case 0x3a:  /* Remove directory */
+	    TRACE(int21,"LONG FILENAME - REMOVE DIRECTORY %s\n",
+		  (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context),DX_reg(context)));
             bSetDOSExtendedError = (!RemoveDirectory32A( 
 					PTR_SEG_OFF_TO_LIN( DS_reg(context),
                                                         DX_reg(context) )));
             break;
         case 0x43:  /* Get/Set file attributes */
+	  TRACE(int21,"LONG FILENAME -EXTENDED GET/SET FILE ATTRIBUTES %s\n",
+		(LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context),DX_reg(context)));
         switch (BL_reg(context))
         {
         case 0x00: /* Get file attributes */
+            TRACE(int21,"\tretrieve attributes\n");
             CX_reg(context) = (WORD)GetFileAttributes32A(
                                           PTR_SEG_OFF_TO_LIN(DS_reg(context),
                                                              DX_reg(context)));
             if (CX_reg(context) == 0xffff) bSetDOSExtendedError = TRUE;
             break;
         case 0x01:
+            TRACE(int21,"\tset attributes 0x%04x\n",CX_reg(context));
             bSetDOSExtendedError = (!SetFileAttributes32A( 
 				  	PTR_SEG_OFF_TO_LIN(DS_reg(context),
                                                            DX_reg(context)),
                                         CX_reg(context)  ) );
             break;
 	default:
-	  fprintf( stderr, 
-		   "Unimplemented int21 long file name function:\n");
+	  FIXME(int21, "Unimplemented long file name function:\n");
 	  INT_BARF( context, 0x21 );
 	  SET_CFLAG(context);
 	  AL_reg(context) = 0;
@@ -1561,10 +1709,14 @@
 	}
 	break;
         case 0x47:  /* Get current directory */
+	    TRACE(int21," LONG FILENAME - GET CURRENT DIRECTORY for drive %s\n",
+		  INT21_DriveName(DL_reg(context)));
 	    bSetDOSExtendedError = !INT21_GetCurrentDirectory(context);
             break;
 
         case 0x4e:  /* Find first file */
+	    TRACE(int21," LONG FILENAME - FIND FIRST MATCHING FILE for %s\n",
+		  (LPCSTR)PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)));
             /* FIXME: use attributes in CX */
             if ((AX_reg(context) = FindFirstFile16(
                    PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)),
@@ -1574,15 +1726,21 @@
 		bSetDOSExtendedError = TRUE;
             break;
         case 0x4f:  /* Find next file */
+	    TRACE(int21,"LONG FILENAME - FIND NEXT MATCHING FILE for handle %d\n",
+		  BX_reg(context));
             if (!FindNextFile16( BX_reg(context),
                     (WIN32_FIND_DATA32A *)PTR_SEG_OFF_TO_LIN(ES_reg(context),
                                                              DI_reg(context))))
 		bSetDOSExtendedError = TRUE;
             break;
         case 0xa1:  /* Find close */
+	    TRACE(int21,"LONG FILENAME - FINDCLOSE for handle %d\n",
+		  BX_reg(context));
             bSetDOSExtendedError = (!FindClose16( BX_reg(context) ));
             break;
 	case 0xa0:
+	    TRACE(int21,"LONG FILENAME - GET VOLUME INFORMATION for drive %s stub\n",
+		  (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context),DX_reg(context)));
 	    break;
         case 0x60:  
 	  switch(CL_reg(context))
@@ -1597,8 +1755,7 @@
 	      else AX_reg(context) = 0;
 	      break;
 	    default:
-	      fprintf( stderr, 
-		       "Unimplemented int21 long file name function:\n");
+	      FIXME(int21, "Unimplemented long file name function:\n");
 	      INT_BARF( context, 0x21 );
 	      SET_CFLAG(context);
 	      AL_reg(context) = 0;
@@ -1606,11 +1763,15 @@
 	  }
 	    break;
         case 0x6c:  /* Create or open file */
+            TRACE(int21,"LONG FILENAME - CREATE OR OPEN FILE %s\n",
+		 (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), SI_reg(context))); 
 	  /* translate Dos 7 action to Dos 6 action */
 	    bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context);
 	    break;
 
         case 0x3b:  /* Change directory */
+            TRACE(int21,"LONG FILENAME - CHANGE DIRECTORY %s\n",
+		 (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context))); 
 	    if (!SetCurrentDirectory32A(PTR_SEG_OFF_TO_LIN(
 	    					DS_reg(context),
 				        	DX_reg(context)
@@ -1621,6 +1782,8 @@
 	    }
 	    break;
         case 0x41:  /* Delete file */
+            TRACE(int21,"LONG FILENAME - DELETE FILE %s\n",
+		 (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context))); 
 	    if (!DeleteFile32A(PTR_SEG_OFF_TO_LIN(
 	    				DS_reg(context),
 					DX_reg(context))
@@ -1630,8 +1793,11 @@
 	    }
 	    break;
         case 0x56:  /* Move (rename) file */
+            TRACE(int21,"LONG FILENAME - RENAME FILE %s to %s stub\n",
+		  (LPCSTR)PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context)),
+		  (LPCSTR)PTR_SEG_OFF_TO_LIN( ES_reg(context), DI_reg(context))); 
         default:
-            fprintf( stderr, "Unimplemented int21 long file name function:\n");
+            FIXME(int21, "Unimplemented long file name function:\n");
             INT_BARF( context, 0x21 );
             SET_CFLAG(context);
             AL_reg(context) = 0;
@@ -1665,6 +1831,10 @@
 	SET_CFLAG(context);
     }
 
+    if ((EFL_reg(context) & 0x0001))
+      TRACE(int21, "failed, errorcode 0x%02x class 0x%02x action 0x%02x locus %02x\n",
+	  DOS_ExtendedError, DOS_ErrorClass, DOS_ErrorAction, DOS_ErrorLocus);
+ 
     TRACE(int21, "returning: AX=%04x BX=%04x CX=%04x DX=%04x "
                  "SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
                  AX_reg(context), BX_reg(context), CX_reg(context),
@@ -1675,6 +1845,6 @@
 
 FARPROC16 WINAPI GetSetKernelDOSProc(FARPROC16 DosProc)
 {
-	fprintf(stderr, "GetSetKernelDOSProc(DosProc: %08x);\n", (UINT32)DosProc);
+	FIXME(int21, "(DosProc=%08x);\n", (UINT32)DosProc);
 	return NULL;
 }
diff --git a/msdos/int5c.c b/msdos/int5c.c
index e5cce57..0a32808 100644
--- a/msdos/int5c.c
+++ b/msdos/int5c.c
@@ -18,7 +18,7 @@
 {
     BYTE* ptr;
     ptr = (BYTE*) PTR_SEG_OFF_TO_LIN(ES_reg(context),BX_reg(context));
-    fprintf(stdnimp,"NetBIOSCall: command code %02x (ignored)\n",*ptr);
+    FIXME(int,"(%p): command code %02x (ignored)\n",context, *ptr);
     AL_reg(context) = *(ptr+0x01) = 0xFB; /* NetBIOS emulator not found */
 }
 
diff --git a/multimedia/Makefile.in b/multimedia/Makefile.in
index cc7446d..a04cb55 100644
--- a/multimedia/Makefile.in
+++ b/multimedia/Makefile.in
@@ -8,6 +8,7 @@
 C_SRCS = \
 	audio.c \
 	dsound.c \
+	init.c \
 	joystick.c \
 	mcianim.c \
 	mcicda.c \
diff --git a/multimedia/init.c b/multimedia/init.c
new file mode 100644
index 0000000..dc31efb
--- /dev/null
+++ b/multimedia/init.c
@@ -0,0 +1,181 @@
+/*
+ * Initialization procedures for multimedia
+ *
+ * Copyright 1998 Luiz Otavio L. Zorzella
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include "windows.h"
+#include "multimedia.h"
+#include "mmsystem.h"
+#include "xmalloc.h"
+#include "debug.h"
+
+#if defined (__HAS_SOUNDCARD_H__)
+
+extern int MODM_NUMDEVS;
+extern LPMIDIOUTCAPS16 midiDevices[MAX_MIDIOUTDRV];
+
+#endif
+
+/**************************************************************************
+ * 			unixToWindowsDeviceType  		[internal]
+ *
+ * return the Windows equivalent to a Unix Device Type
+ *
+ */
+#if defined (__HAS_SOUNDCARD_H__)
+int unixToWindowsDeviceType(int type)
+{
+  /* MOD_MIDIPORT     output port 
+   * MOD_SYNTH        generic internal synth 
+   * MOD_SQSYNTH      square wave internal synth 
+   * MOD_FMSYNTH      FM internal synth 
+   * MOD_MAPPER       MIDI mapper
+   */
+
+  /* FIXME Is this really the correct equivalence from UNIX to Windows Sound type */
+
+  switch (type) {
+  case SYNTH_TYPE_FM:     return MOD_FMSYNTH;
+  case SYNTH_TYPE_SAMPLE: return MOD_SYNTH;
+  case SYNTH_TYPE_MIDI:   return MOD_MIDIPORT;
+  default:
+    ERR(midi, "Cannot determine the type of this midi device. Assuming FM Synth\n");
+    return MOD_FMSYNTH;
+  }
+}
+#endif
+
+/**************************************************************************
+ * 			MultimediaInit				[internal]
+ *
+ * Initializes the MIDI devices information variables
+ *
+ */
+BOOL32 MULTIMEDIA_Init (void)
+{
+#if defined (__HAS_SOUNDCARD_H__)
+  int i, status, numsynthdevs, nummididevs;
+  struct synth_info sinfo;
+  struct midi_info minfo;
+  int fd;        /* file descriptor for MIDI_DEV */
+  LPMIDIOUTCAPS16 tmplpCaps = NULL;
+
+  TRACE (midi, "Initializing the MIDI variables.\n");
+  /* try to open device */
+  fd = open(MIDI_DEV, O_WRONLY);
+  if (fd == -1) {
+    TRACE (midi, "No soundcards founds: unable to open `%s'.\n", MIDI_DEV);
+    return TRUE;
+  }
+
+  /* find how many Synth devices are there in the system */
+  status = ioctl(fd, SNDCTL_SEQ_NRSYNTHS, &numsynthdevs);
+
+  if (numsynthdevs > MAX_MIDIOUTDRV) {
+    ERR (midi, "MAX_MIDIOUTDRV was enough for the number of devices. Some FM devices will not be available.\n");
+    numsynthdevs = MAX_MIDIOUTDRV;
+  }
+  
+  if (status == -1) {
+    ERR (midi, "ioctl failed.\n");
+    return TRUE;
+  }
+
+  for (i = 0 ; i < numsynthdevs ; i++) {
+    sinfo.device = i;
+    status = ioctl(fd, SNDCTL_SYNTH_INFO, &sinfo);
+    if (status == -1) {
+      ERR(midi, "ioctl failed.\n");
+      return TRUE;
+    }
+
+    tmplpCaps = xmalloc (sizeof (MIDIOUTCAPS16));
+    /* We also have the information sinfo.synth_subtype, not used here
+     */
+    
+    /* Manufac ID. We do not have access to this with soundcard.h
+     * Does not seem to be a problem, because in mmsystem.h only
+     * Microsoft's ID is listed.
+     */
+    tmplpCaps->wMid = 0x00FF; 
+    tmplpCaps->wPid = 0x0001; 	/* FIXME Product ID  */
+    tmplpCaps->vDriverVersion = 0x001; /* Product Version. We simply say "1" */
+    strcpy(tmplpCaps->szPname, sinfo.name);
+
+    tmplpCaps->wTechnology = unixToWindowsDeviceType (sinfo.synth_type);
+    tmplpCaps->wVoices     = sinfo.nr_voices;
+
+    /* FIXME Is it possible to know the maximum
+     * number of simultaneous notes of a soundcard ?
+     * I beleive we don't have this information, but
+     * it's probably equal or more than wVoices
+     */
+    tmplpCaps->wNotes      = sinfo.nr_voices;  
+
+    /* FIXME Do we have this information?
+     * Assuming the soundcards can handle
+     * MIDICAPS_VOLUME and MIDICAPS_LRVOLUME but
+     * not MIDICAPS_CACHE.
+     */
+    tmplpCaps->dwSupport   = MIDICAPS_VOLUME|MIDICAPS_LRVOLUME;
+    
+    midiDevices[i] = tmplpCaps;
+    
+    TRACE(midi,"techn = %d voices=%d notes = %d support = %ld\n",tmplpCaps->wTechnology,tmplpCaps->wVoices,tmplpCaps->wNotes,tmplpCaps->dwSupport);
+  }
+  
+  /* find how many MIDI devices are there in the system */
+  status = ioctl(fd, SNDCTL_SEQ_NRMIDIS, &nummididevs);
+  if (status == -1) {
+    ERR(midi, "ioctl failed.\n");
+    return TRUE;
+  }
+
+  if (numsynthdevs + nummididevs > MAX_MIDIOUTDRV) {
+    ERR(midi, "MAX_MIDIOUTDRV was enough for the number of devices. Some MIDI devices will not be available.\n");
+    nummididevs = MAX_MIDIOUTDRV - numsynthdevs;
+  }
+
+  /* windows does not seem to diferentiate Synth from MIDI devices */
+  MODM_NUMDEVS = numsynthdevs + nummididevs;
+  
+  for (i = 0 ; i < nummididevs ; i++) {
+    minfo.device = i;
+    status = ioctl(fd, SNDCTL_MIDI_INFO, &minfo);
+    if (status == -1) {
+      ERR(midi, "ioctl failed.\n");
+      return TRUE;
+    }
+    /* This whole part is somewhat obscure to me. I'll keep trying to dig
+       info about it. If you happen to know, please tell us. The very descritive
+       minfo.dev_type was not used here.
+     */
+    tmplpCaps->wMid = 0x00FF; 	/* Manufac ID. We do not have access to this with soundcard.h
+				   Does not seem to be a problem, because in mmsystem.h only
+				   Microsoft's ID is listed */
+    tmplpCaps->wPid = 0x0001; 	/* FIXME Product ID */
+    tmplpCaps->vDriverVersion = 0x001; /* Product Version. We simply say "1" */
+    strcpy(tmplpCaps->szPname, minfo.name);
+
+    tmplpCaps->wTechnology =  MOD_MIDIPORT; /* FIXME Is this right? */
+    tmplpCaps->wVoices     = 16;            /* Does it make any difference? */
+    tmplpCaps->wNotes      = 16;            /* Does it make any difference? */
+    tmplpCaps->dwSupport   = MIDICAPS_VOLUME|MIDICAPS_LRVOLUME; /* FIXME Does it make any difference? */
+
+    midiDevices[numsynthdevs + i] = tmplpCaps;
+
+    TRACE(midi,"techn = %d voices=%d notes = %d support = %ld\n",tmplpCaps->wTechnology,tmplpCaps->wVoices,tmplpCaps->wNotes,tmplpCaps->dwSupport);
+  }
+  
+  /* close file and exit */
+  close(fd);
+
+#endif /* __HAS_SOUNDCARD_H__ */
+  
+  return TRUE;
+  
+}
diff --git a/multimedia/mcianim.c b/multimedia/mcianim.c
index 80d8970..7b9379b 100644
--- a/multimedia/mcianim.c
+++ b/multimedia/mcianim.c
@@ -542,8 +542,7 @@
 static DWORD ANIM_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
 {
 #if defined(linux) || defined(__FreeBSD__)
-	TRACE(mcianim,"(%u, %08lX, %p);\n", 
-		wDevID, dwFlags, lpParms);
+	TRACE(mcianim,"(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
 	if (lpParms == NULL) return MCIERR_INTERNAL;
 /*
 	printf("ANIM_mciSet // dwTimeFormat=%08lX\n", lpParms->dwTimeFormat);
diff --git a/multimedia/mcicda.c b/multimedia/mcicda.c
index a3fa04f..39a1f09 100644
--- a/multimedia/mcicda.c
+++ b/multimedia/mcicda.c
@@ -933,8 +933,7 @@
 static DWORD CDAUDIO_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
 {
 #if defined(linux) || defined(__FreeBSD__)
-    	TRACE(cdaudio,"(%04X, %08lX, %p);\n", 
-		wDevID, dwFlags, lpParms);
+    	TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
 	if (lpParms == NULL) return MCIERR_INTERNAL;
 /*
 	printf("CDAUDIO_mciSet // dwTimeFormat=%08lX\n", lpParms->dwTimeFormat);
diff --git a/multimedia/mcistring.c b/multimedia/mcistring.c
index 62f4cf7..3318d65 100644
--- a/multimedia/mcistring.c
+++ b/multimedia/mcistring.c
@@ -129,7 +129,7 @@
 		);
 		break;
 	default:
-		fprintf(stdnimp,__FILE__":MCISTR_Status:missing timeformat for %ld, report.\n",timef);
+		FIXME(mci, "missing timeformat for %ld, report.\n",timef);
 		strcpy(buf,"0"); /* hmm */
 		break;
 	}
@@ -165,7 +165,7 @@
 		case MCI_SEQ_SMPTE:_MCI_STR("smpte");break;
 		case MCI_SEQ_FILE:_MCI_STR("file");break;
 		case MCI_SEQ_MIDI:_MCI_STR("midi");break;
-		default:fprintf(stdnimp,__FILE__":MCISTR_Status:missing sequencer mode %ld\n",dwReturn);
+		default:FIXME(mci,"missing sequencer mode %ld\n",dwReturn);
 		}
 		break;
 	case _MCISTR_mode:
@@ -208,7 +208,7 @@
 		case MCI_FORMAT_MSF:_MCI_STR("msf");break;
 		case MCI_FORMAT_TMSF:_MCI_STR("tmsf");break;
 		default:
-			fprintf(stdnimp,__FILE__":MCISTR_Status:missing timeformat for %d, report.\n",timef);
+			FIXME(mci,"missing timefmt for %d, report.\n",timef);
 			break;
 		}
 		break;
@@ -233,11 +233,12 @@
 		case MCI_DEVTYPE_OTHER:_MCI_STR("other");break;
 		case MCI_DEVTYPE_WAVEFORM_AUDIO:_MCI_STR("waveform audio");break;
 		case MCI_DEVTYPE_SEQUENCER:_MCI_STR("sequencer");break;
-		default:fprintf(stdnimp,__FILE__":_MCISTR_convreturn:unknown device type %ld, report.\n",dwReturn);break;
+		default:FIXME(mci,"unknown device type %ld, report.\n",
+			      dwReturn);break;
 		}
 		break;
 	default:
-		fprintf(stdnimp,__FILE__":_MCISTR_convreturn:unknown resulttype %d, report.\n",type);
+		FIXME(mci,"unknown resulttype %d, report.\n",type);
 		break;
 	}
 }
@@ -388,7 +389,7 @@
 				} else if (sscanf(keywords[i+1],"%ld",&st)) {
 					pU->animopenParams.dwStyle |= st; 
 				} else
-					fprintf(stdnimp,__FILE__":MCISTR_Open:unknown 'style' keyword %s, please report.\n",keywords[i+1]);
+					FIXME(mci,"unknown 'style' keyword %s, please report.\n",keywords[i+1]);
 				i+=2;
 				continue;
 			}
@@ -420,13 +421,14 @@
 				} else if (sscanf(keywords[i+1],"%ld",&st)) {
 					pU->ovlyopenParams.dwStyle |= st; 
 				} else
-					fprintf(stdnimp,__FILE__":MCISTR_Open:unknown 'style' keyword %s, please report.\n",keywords[i+1]);
+					FIXME(mci,"unknown 'style' keyword %s, please report.\n",keywords[i+1]);
 				i+=2;
 				continue;
 			}
 			break;
 		}
-		fprintf(stdnimp,__FILE__":MCISTR_Open:unknown parameter passed %s, please report.\n",keywords[i]);
+		FIXME(mci,"unknown parameter passed %s, please report.\n",
+		      keywords[i]);
 		i++;
 	}
 	_MCI_CALL_DRIVER( MCI_OPEN, SEGPTR_GET(pU) );
@@ -619,7 +621,7 @@
 			ITEM1("level",MCI_WAVE_STATUS_LEVEL,_MCISTR_int);
 			break;
 		}
-		fprintf(stdnimp,__FILE__":MCISTR_Status:unknown keyword '%s'\n",keywords[i]);
+		FIXME(mci,"unknown keyword '%s'\n",keywords[i]);
 		i++;
 	}
 	if (!statusParams->dwItem) 
@@ -1058,7 +1060,7 @@
 		parsestr="%d:%d:%d:%d";
 		nrargs=4;
 		break;
-	default:fprintf(stdnimp,"mciSendString:PLAY:unknown timeformat %d, please report.\n",timef);
+	default:FIXME(mci,"unknown timeformat %d, please report.\n",timef);
 		parsestr="%d";
 		nrargs=1;
 		break;
@@ -1147,7 +1149,7 @@
 		parsestr="%d:%d:%d:%d";
 		nrargs=4;
 		break;
-	default:fprintf(stdnimp,"mciSendString:PLAY:unknown timeformat %d, please report.\n",timef);
+	default:FIXME(mci,"unknown timeformat %d, please report.\n",timef);
 		parsestr="%d";
 		nrargs=1;
 		break;
@@ -1244,7 +1246,7 @@
 		parsestr="%d:%d:%d:%d";
 		nrargs=4;
 		break;
-	default:fprintf(stdnimp,"mciSendString:SEEK:unknown timeformat %d, please report.\n",timef);
+	default:FIXME(mci,"unknown timeformat %d, please report.\n",timef);
 		parsestr="%d";
 		nrargs=1;
 		break;
@@ -1529,7 +1531,7 @@
 		parsestr="%d:%d:%d:%d";
 		nrargs=4;
 		break;
-	default:fprintf(stdnimp,"mciSendString:DELETE:unknown timeformat %d, please report.\n",timef);
+	default:FIXME(mci,"unknown timeformat %d, please report.\n",timef);
 		parsestr="%d";
 		nrargs=1;
 		break;
@@ -2204,9 +2206,8 @@
  		free(keywords);free(cmd);
  		return	res;
  	}
-	fprintf(stdnimp,"mciSendString('%s', %p, %u, %X) // unimplemented, please report.\n", lpstrCommand, 
-		lpstrReturnString, uReturnLength, hwndCallback
-	);
+	FIXME(mci,"('%s', %p, %u, %X): unimplemented, please report.\n", 
+	      lpstrCommand, lpstrReturnString, uReturnLength, hwndCallback);
 	free(keywords);free(cmd);
 	return MCIERR_MISSING_COMMAND_STRING;
 }
diff --git a/multimedia/midi.c b/multimedia/midi.c
index f253d56..0a2f897 100644
--- a/multimedia/midi.c
+++ b/multimedia/midi.c
@@ -14,74 +14,28 @@
 #include <sys/ioctl.h>
 #include "windows.h"
 #include "ldt.h"
+#include "multimedia.h"
 #include "user.h"
 #include "driver.h"
 #include "mmsystem.h"
 #include "xmalloc.h"
 #include "debug.h"
 
-#ifdef linux
-#include <linux/soundcard.h>
-#elif __FreeBSD__
-#include <machine/soundcard.h>
-#include <sys/errno.h>
-#endif
-
-#if defined(linux) || defined(__FreeBSD__)
-#define MIDI_DEV "/dev/sequencer"
-
-#ifdef SOUND_VERSION
-#define IOCTL(a,b,c)		ioctl(a,b,&c)
-#else
-#define IOCTL(a,b,c)		(c = ioctl(a,b,c) )
-#endif
-
-#define MAX_MIDIINDRV 	(1)
-#define MAX_MIDIOUTDRV 	(1)
-#define MAX_MCIMIDIDRV 	(1)
-
-typedef struct {
-	int		unixdev;
-	int		state;
-	DWORD		bufsize;
-	MIDIOPENDESC	midiDesc;
-	WORD		wFlags;
-	LPMIDIHDR 	lpQueueHdr;
-	DWORD		dwTotalPlayed;
-} LINUX_MIDIIN;
-
-typedef struct {
-	int		unixdev;
-	int		state;
-	DWORD		bufsize;
-	MIDIOPENDESC	midiDesc;
-	WORD		wFlags;
-	LPMIDIHDR 	lpQueueHdr;
-	DWORD		dwTotalPlayed;
-} LINUX_MIDIOUT;
-
-typedef struct {
-	int	nUseCount;          /* Incremented for each shared open */
-	BOOL16	fShareable;         /* TRUE if first open was shareable */
-	WORD	wNotifyDeviceID;    /* MCI device ID with a pending notification */
-	HANDLE16 hCallback;         /* Callback handle for pending notification */
-	HMMIO16	hFile;				/* mmio file handle open as Element		*/
-	DWORD	dwBeginData;
-	DWORD	dwTotalLen;
-	WORD	wFormat;
-	WORD	nTracks;
-	WORD	nTempo;
-	MCI_OPEN_PARMS16 openParms;
-/* 	MIDIHDR	MidiHdr; */
-	HLOCAL16	hMidiHdr;
-	WORD	dwStatus;
-} LINUX_MCIMIDI;
+#if defined (__HAS_SOUNDCARD_H__)
 
 static LINUX_MIDIIN	MidiInDev[MAX_MIDIINDRV];
 static LINUX_MIDIOUT	MidiOutDev[MAX_MIDIOUTDRV];
 static LINUX_MCIMIDI	MCIMidiDev[MAX_MCIMIDIDRV];
+
 #endif
 
+/* this is the total number of MIDI devices found */
+int MODM_NUMDEVS = 0;
+
+/* this structure holds pointers with information for each MIDI
+ * device found.
+ */
+LPMIDIOUTCAPS16 midiDevices[MAX_MIDIOUTDRV];
 
 /**************************************************************************
  * 			MIDI_NotifyClient			[internal]
@@ -835,12 +789,13 @@
 #endif
 }
 
+
 /**************************************************************************
  * 				MIDI_mciInfo			[internal]
  */
 static DWORD MIDI_mciInfo(UINT16 wDevID, DWORD dwFlags, LPMCI_INFO_PARMS16 lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+# if defined(__FreeBSD__) || defined (linux)
 	TRACE(midi, "(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
 	if (lpParms == NULL) return MCIERR_INTERNAL;
 	lpParms->lpstrReturn = NULL;
@@ -1047,35 +1002,42 @@
 	return MMSYSERR_NOTSUPPORTED;
 }
 
-
-
 /*-----------------------------------------------------------------------*/
 
-
 /**************************************************************************
  * 				modGetDevCaps			[internal]
  */
 static DWORD modGetDevCaps(WORD wDevID, LPMIDIOUTCAPS16 lpCaps, DWORD dwSize)
 {
+  LPMIDIOUTCAPS16 tmplpCaps;
+
 	TRACE(midi, "(%04X, %p, %08lX);\n", wDevID, lpCaps, dwSize);
+  if (wDevID == (WORD) MIDI_MAPPER) { 
 	lpCaps->wMid = 0x00FF; 	/* Manufac ID */
 	lpCaps->wPid = 0x0001; 	/* Product ID */
 	lpCaps->vDriverVersion = 0x001; /* Product Version */
-	strcpy(lpCaps->szPname, "Linux MIDIOUT Driver v0.01");
-/* FIXME
-   Values are the same as I get with Borland TC 4.5
+    strcpy(lpCaps->szPname, "MIDI Maper (not functional yet)");
+    lpCaps->wTechnology = MOD_FMSYNTH; /* FIXME Does it make any difference ? */
+    lpCaps->wVoices     = 14;       /* FIXME */
+    lpCaps->wNotes      = 14;       /* FIXME */
+    lpCaps->dwSupport   = MIDICAPS_VOLUME|MIDICAPS_LRVOLUME; /* FIXME Does it make any difference ? */
+  } else {
+    /* FIXME There is a way to do it so easily, but I'm too
+     * sleepy to think and I want to test
 */
-
-	lpCaps->wTechnology = MOD_FMSYNTH;
-	lpCaps->wVoices     = 14;       /* make it ioctl */
-	lpCaps->wNotes      = 14;       /* make it ioctl */
-	lpCaps->dwSupport   = MIDICAPS_VOLUME|MIDICAPS_LRVOLUME;
-	TRACE(midi,"techn = %d voices=%d notes = %d support = %ld\n",lpCaps->wTechnology,lpCaps->wVoices,lpCaps->wNotes,lpCaps->dwSupport);
-
+    tmplpCaps = midiDevices [wDevID];
+    lpCaps->wMid = tmplpCaps->wMid;  
+    lpCaps->wPid = tmplpCaps->wPid;  
+    lpCaps->vDriverVersion = tmplpCaps->vDriverVersion;  
+    strcpy(lpCaps->szPname, tmplpCaps->szPname);    
+    lpCaps->wTechnology = tmplpCaps->wTechnology;
+    lpCaps->wVoices = tmplpCaps->wVoices;  
+    lpCaps->wNotes = tmplpCaps->wNotes;  
+    lpCaps->dwSupport = tmplpCaps->dwSupport;  
+  }
 	return MMSYSERR_NOERROR;
 }
 
-
 /**************************************************************************
  * 			modOpen					[internal]
  */
@@ -1091,7 +1053,7 @@
 	}
 	if (wDevID>= MAX_MIDIOUTDRV) {
 		TRACE(midi,"MAX_MIDIOUTDRV reached !\n");
-		return MMSYSERR_ALLOCATED;
+		return MMSYSERR_ALLOCATED; /* FIXME isn't MMSYSERR_BADDEVICEID the right answer ? */
 	}
 	MidiOutDev[wDevID].unixdev = 0;
 	midi = open (MIDI_DEV, O_WRONLY, 0);
@@ -1311,7 +1273,7 @@
 	case MODM_GETDEVCAPS:
 		return modGetDevCaps(wDevID,(LPMIDIOUTCAPS16)dwParam1,dwParam2);
 	case MODM_GETNUMDEVS:
-		return 1;
+		return MODM_NUMDEVS;
 	case MODM_GETVOLUME:
 		return 0;
 	case MODM_SETVOLUME:
diff --git a/multimedia/mmio.c b/multimedia/mmio.c
index 87f9b1e..c7117a0 100644
--- a/multimedia/mmio.c
+++ b/multimedia/mmio.c
@@ -455,8 +455,7 @@
 				 fccIOProc, pIOProc, dwFlags);
 
 	if (dwFlags & MMIO_GLOBALPROC) {
-		fprintf(stdnimp, "mmioInstallIOProc: global procedures not "
-				"implemented\n");
+		FIXME(mmio, " global procedures not implemented\n");
 	}
 
 	/* just handle the known procedures for now */
diff --git a/multimedia/mmsystem.c b/multimedia/mmsystem.c
index 12e55d7..f13aefa 100644
--- a/multimedia/mmsystem.c
+++ b/multimedia/mmsystem.c
@@ -96,7 +96,8 @@
 int WINAPI MMSYSTEM_WEP(HINSTANCE16 hInstance, WORD wDataSeg,
                         WORD cbHeapSize, LPSTR lpCmdLine)
 {
-	fprintf(stderr, "STUB: Unloading MMSystem DLL ... hInst=%04X \n", hInstance);
+	FIXME(mmsys, "STUB: Unloading MMSystem DLL ... hInst=%04X \n",
+	      hInstance);
 	return(TRUE);
 }
 
@@ -122,9 +123,9 @@
 BOOL32 WINAPI PlaySound32A(LPCSTR pszSound, HMODULE32 hmod, DWORD fdwSound)
 {
   TRACE(mmsys, "pszSound='%p' hmod=%04X fdwSound=%08lX\n",
-	       pszSound, hmod, fdwSound);
+	pszSound, hmod, fdwSound);
   if(hmod != 0 || !(fdwSound & SND_FILENAME)) {
-    fprintf(stderr, "PlaySoundA: only disk sound files are supported\n");
+    FIXME(mmsys, "only disk sound files are supported\n");
     return FALSE;
   } else
     return  sndPlaySound(pszSound, (UINT16) fdwSound);
@@ -406,7 +407,7 @@
  */
 UINT16 WINAPI mixerGetDevCaps16(UINT16 devid,LPMIXERCAPS16 mixcaps,UINT16 size) 
 {
-	fprintf(stderr,"mixerGetDevCaps!\n");
+	FIXME(mmsys,"should this be a fixme?\n");
 	return mixMessage(devid,MXDM_GETDEVCAPS,0L,(DWORD)mixcaps,(DWORD)size);
 }
 
@@ -419,9 +420,8 @@
 	HMIXER16	hmix16;
 	UINT32		ret;
 
-	fprintf(stderr,"mixerOpen32(%p,%d,%08lx,%08lx,%08lx)\n",
-		lphmix,uDeviceID,dwCallback,dwInstance,fdwOpen
-	);
+	FIXME(mmsys,"(%p,%d,%08lx,%08lx,%08lx): semi stub?\n",
+	      lphmix,uDeviceID,dwCallback,dwInstance,fdwOpen);
 	ret = mixerOpen16(&hmix16,uDeviceID,dwCallback,dwInstance,fdwOpen);
 	if (lphmix) *lphmix = hmix16;
 	return ret;
@@ -438,9 +438,8 @@
 	BOOL32		mapperflag = (uDeviceID==0);
 	DWORD		dwRet;
 
-	fprintf(stderr,"mixerOpen(%p,%d,%08lx,%08lx,%08lx)\n",
-		lphmix,uDeviceID,dwCallback,dwInstance,fdwOpen
-	);
+	TRACE(mmsys,"(%p,%d,%08lx,%08lx,%08lx)\n",
+	      lphmix,uDeviceID,dwCallback,dwInstance,fdwOpen);
 	hmix = USER_HEAP_ALLOC(sizeof(MIXEROPENDESC));
 	if (lphmix) *lphmix = hmix;
 	lpmod = (LPMIXEROPENDESC)USER_HEAP_LIN_ADDR(hmix);
@@ -472,7 +471,7 @@
 UINT16 WINAPI mixerClose16(HMIXER16 hmix) {
 	LPMIXEROPENDESC	lpmod;
 
-	fprintf(stderr,"mixerClose(%04x)\n",hmix);
+	FIXME(mmsys,"(%04x): semi-stub?\n",hmix);
 	lpmod = (LPMIXEROPENDESC)USER_HEAP_LIN_ADDR(hmix);
 	return mixMessage(lpmod->uDeviceID,MXDM_CLOSE,lpmod->dwInstance,0L,0L);
 }
@@ -492,7 +491,7 @@
  * 				mixerGetID
  */
 UINT16 WINAPI mixerGetID16(HMIXEROBJ16 hmix,LPUINT16 lpid,DWORD fdwID) {
-	fprintf(stderr,"mixerGetID(%04x)\n",hmix);
+	FIXME(mmsys,"(%04x): semi-stub\n",hmix);
 	return _get_mixerID_from_handle(hmix,fdwID);
 }
 
@@ -500,9 +499,7 @@
  * 				mixerGetControlDetailsA	[WINMM.99]
  */
 UINT32 mixerGetControlDetails32A(HMIXEROBJ32 hmix,LPMIXERCONTROLDETAILS32 lpmcd,DWORD fdwDetails) {
-	fprintf(stderr,"mixerGetControlDetails(%04x,%p,%08lx),stub!\n",
-		hmix,lpmcd,fdwDetails
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmcd,fdwDetails);
 	return MMSYSERR_NOTENABLED;
 }
 
@@ -510,9 +507,7 @@
  * 				mixerGetControlDetailsW	[WINMM.100]
  */
 UINT32 mixerGetControlDetails32W(HMIXEROBJ32 hmix,LPMIXERCONTROLDETAILS32 lpmcd,DWORD fdwDetails) {
-	fprintf(stderr,"mixerGetControlDetails(%04x,%p,%08lx),stub!\n",
-		hmix,lpmcd,fdwDetails
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",	hmix,lpmcd,fdwDetails);
 	return MMSYSERR_NOTENABLED;
 }
 
@@ -520,9 +515,7 @@
  * 				mixerGetControlDetails	[MMSYSTEM.808]
  */
 UINT16 mixerGetControlDetails16(HMIXEROBJ16 hmix,LPMIXERCONTROLDETAILS16 lpmcd,DWORD fdwDetails) {
-	fprintf(stderr,"mixerGetControlDetails(%04x,%p,%08lx),stub!\n",
-		hmix,lpmcd,fdwDetails
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmcd,fdwDetails);
 	return MMSYSERR_NOTENABLED;
 }
 
@@ -530,9 +523,7 @@
  * 				mixerGetLineControlsA	[WINMM.104]
  */
 UINT32 WINAPI mixerGetLineControls32A(HMIXEROBJ32 hmix,LPMIXERLINECONTROLS32A lpmlc,DWORD fdwControls) {
-	fprintf(stderr,"mixerGetLineControlsA(%04x,%p,%08lx),stub!\n",
-		hmix,lpmlc,fdwControls
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmlc,fdwControls);
 	return MMSYSERR_NOTENABLED;
 }
 
@@ -540,9 +531,7 @@
  * 				mixerGetLineControlsW	[WINMM.105]
  */
 UINT32 WINAPI mixerGetLineControls32W(HMIXEROBJ32 hmix,LPMIXERLINECONTROLS32W lpmlc,DWORD fdwControls) {
-	fprintf(stderr,"mixerGetLineControlsA(%04x,%p,%08lx),stub!\n",
-		hmix,lpmlc,fdwControls
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmlc,fdwControls);
 	return MMSYSERR_NOTENABLED;
 }
 
@@ -550,9 +539,7 @@
  * 				mixerGetLineControls	[MMSYSTEM.807]
  */
 UINT16 WINAPI mixerGetLineControls16(HMIXEROBJ16 hmix,LPMIXERLINECONTROLS16 lpmlc,DWORD fdwControls) {
-	fprintf(stderr,"mixerGetLineControls(%04x,%p,%08lx),stub!\n",
-		hmix,lpmlc,fdwControls
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmlc,fdwControls);
 	return MMSYSERR_NOTENABLED;
 }
 
@@ -564,9 +551,7 @@
 	UINT32		ret;
 
 	ml16.dwDestination = lpml->dwDestination;
-	fprintf(stderr,"mixerGetLineInfoA(%04x,%p,%08lx),stub!\n",
-		hmix,lpml,fdwInfo
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpml,fdwInfo);
 	ret = mixerGetLineInfo16(hmix,&ml16,fdwInfo);
 	lpml->cbStruct = sizeof(*lpml);
 	lpml->dwSource = ml16.dwSource;
@@ -596,9 +581,7 @@
 	UINT32		ret;
 
 	ml16.dwDestination = lpml->dwDestination;
-	fprintf(stderr,"mixerGetLineInfoW(%04x,%p,%08lx),stub!\n",
-		hmix,lpml,fdwInfo
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpml,fdwInfo);
 	ret = mixerGetLineInfo16(hmix,&ml16,fdwInfo);
 	lpml->cbStruct = sizeof(*lpml);
 	lpml->dwSource = ml16.dwSource;
@@ -626,9 +609,8 @@
 UINT16 WINAPI mixerGetLineInfo16(HMIXEROBJ16 hmix,LPMIXERLINE16 lpml,DWORD fdwInfo) {
 	UINT16 devid =  _get_mixerID_from_handle(hmix,fdwInfo);
 
-	fprintf(stderr,"mixerGetLineInfo16(%04x,%p[line %08lx],%08lx)\n",
-		hmix,lpml,lpml->dwDestination,fdwInfo
-	);
+	FIXME(mmsys,"(%04x,%p[line %08lx],%08lx) - semi-stub?\n",
+	      hmix,lpml,lpml->dwDestination,fdwInfo);
 	return mixMessage(devid,MXDM_GETLINEINFO,0,(DWORD)lpml,fdwInfo);
 }
 
@@ -636,9 +618,7 @@
  * 				mixerSetControlDetails	[WINMM.111]
  */
 UINT32 WINAPI mixerSetControlDetails32(HMIXEROBJ32 hmix,LPMIXERCONTROLDETAILS32 lpmcd,DWORD fdwDetails) {
-	fprintf(stderr,"mixerSetControlDetails32(%04x,%p,%08lx),stub!\n",
-		hmix,lpmcd,fdwDetails
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmcd,fdwDetails);
 	return MMSYSERR_NOTENABLED;
 }
 
@@ -646,9 +626,7 @@
  * 				mixerSetControlDetails	[MMSYSTEM.809]
  */
 UINT16 WINAPI mixerSetControlDetails16(HMIXEROBJ16 hmix,LPMIXERCONTROLDETAILS16 lpmcd,DWORD fdwDetails) {
-	fprintf(stderr,"mixerSetControlDetails16(%04x,%p,%08lx),stub!\n",
-		hmix,lpmcd,fdwDetails
-	);
+	FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmcd,fdwDetails);
 	return MMSYSERR_NOTENABLED;
 }
 
@@ -664,7 +642,8 @@
 		uDeviceID = lpmod->uDeviceID;
 	else
 		uDeviceID = 0;
-	fprintf(stderr,"mixerMessage(%04lx,%d,%08lx,%08lx)\n",(DWORD)hmix,uMsg,dwParam1,dwParam2);
+	FIXME(mmsys,"(%04lx,%d,%08lx,%08lx): semi-stub?\n",
+	      (DWORD)hmix,uMsg,dwParam1,dwParam2);
 	return mixMessage(uDeviceID,uMsg,0L,dwParam1,dwParam2);
 }
 
@@ -680,7 +659,8 @@
 		uDeviceID = lpmod->uDeviceID;
 	else
 		uDeviceID = 0;
-	fprintf(stderr,"mixerMessage(%04x,%d,%08lx,%08lx)\n",hmix,uMsg,dwParam1,dwParam2);
+	FIXME(mmsys,"(%04x,%d,%08lx,%08lx) - semi-stub?\n",
+	      hmix,uMsg,dwParam1,dwParam2);
 	return mixMessage(uDeviceID,uMsg,0L,dwParam1,dwParam2);
 }
 
@@ -797,9 +777,8 @@
 	case AUXDM_GETDEVCAPS:
 		return auxGetDevCaps32A(uDeviceID,(LPAUXCAPS32A)dw1,dw2);
 	default:
-		fprintf(stderr,"unhandled auxMessage32(%04x,%04x,%08lx,%08lx)\n",
-			uDeviceID,uMessage,dw1,dw2
-		);
+		ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
+		    uDeviceID,uMessage,dw1,dw2);
 		break;
 	}
 	return auxMessage(uDeviceID,uMessage,0L,dw1,dw2);
@@ -822,9 +801,8 @@
 	case AUXDM_GETDEVCAPS:
 		return auxGetDevCaps16(uDeviceID,(LPAUXCAPS16)PTR_SEG_TO_LIN(dw1),dw2);
 	default:
-		fprintf(stderr,"unhandled auxMessage32(%04x,%04x,%08lx,%08lx)\n",
-			uDeviceID,uMessage,dw1,dw2
-		);
+		ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
+		    uDeviceID,uMessage,dw1,dw2);
 		break;
 	}
 	return auxMessage(uDeviceID, uMessage, 0L, dw1, dw2);
@@ -1254,7 +1232,7 @@
 			} else {
 #if testing16
 				HDRVR16 hdrv;
-				fprintf(stderr,"trying to load driver...\n");
+				TRACE(mmsys,"trying to load driver...\n");
 				hdrv = OpenDriver(str,"mci",NULL);
 				if (hdrv) {
 					HMODULE16	hmod;
@@ -1317,7 +1295,7 @@
  * 			mciGetDriverData			[MMSYSTEM.708]
  */
 DWORD WINAPI mciGetDriverData16(HDRVR16 hdrv) {
-	fprintf(stderr,"mciGetDriverData(%04x),stub!\n",hdrv);
+        FIXME(mmsys,"(%04x): stub!\n",hdrv);
 	return 0x42;
 }
 
@@ -1325,7 +1303,7 @@
  * 			mciSetDriverData			[MMSYSTEM.707]
  */
 DWORD WINAPI mciSetDriverData16(HDRVR16 hdrv,DWORD data) {
-	fprintf(stderr,"mciSetDriverData(%04x,%08lx),stub!\n",hdrv,data);
+	FIXME(mmsys,"(%04x,%08lx): stub!\n",hdrv,data);
 	return 0;
 }
 
@@ -1436,11 +1414,9 @@
       LPBYTE          lmem;
       static          mcidevtype = 0;
 
-      fprintf(stderr,"mciLoadCommandResource16(%04x,%s,%d),stub!\n",
-              hinst,resname,type
-      );
+      FIXME(mmsys,"(%04x,%s,%d): stub!\n",hinst,resname,type);
       if (!lstrcmpi32A(resname,"core")) {
-              fprintf(stderr,"mciLoadCommandResource(...,\"core\",...), have to use internal tables... (not there yet)\n");
+              FIXME(mmsys,"(...,\"core\",...), have to use internal tables... (not there yet)\n");
               return 0;
       }
       /* if file exists "resname.mci", then load resource "resname" from it
@@ -1457,22 +1433,22 @@
       hrsrc = FindResource16(hinst,SEGPTR_GET(segstr),type);
       SEGPTR_FREE(segstr);
       if (!hrsrc) {
-              fprintf(stderr,"mciLoadCommandResource:no special commandlist found in resource\n");
+              WARN(mmsys,"no special commandlist found in resource\n");
               return MCI_NO_COMMAND_TABLE;
       }
       hmem = LoadResource16(hinst,hrsrc);
       if (!hmem) {
-              fprintf(stderr,"mciLoadCommandResource:couldn't load resource??\n");
+              WARN(mmsys,"couldn't load resource??\n");
               return MCI_NO_COMMAND_TABLE;
       }
       xmem = WIN16_LockResource16(hmem);
       if (!xmem) {
-              fprintf(stderr,"mciLoadCommandResource:couldn't lock resource??\n");
+              WARN(mmsys,"couldn't lock resource??\n");
               FreeResource16(hmem);
               return MCI_NO_COMMAND_TABLE;
       }
       lmem = PTR_SEG_TO_LIN(xmem);
-      fprintf(stderr,"first resource entry is %s\n",(char*)lmem);
+      TRACE(mmsys,"first resource entry is %s\n",(char*)lmem);
       /* parse resource, register stuff, return unique id */
       return ++mcidevtype;
 }
@@ -1543,16 +1519,15 @@
 DWORD WINAPI mciSendCommand32A(UINT32 wDevID, UINT32 wMsg, DWORD dwParam1,
                             DWORD dwParam2)
 {
-    fprintf(stderr,"mciSendCommand32A(%08x,%s,%08lx,%08lx),stub!\n",
-	    wDevID,_mciCommandToString(wMsg),dwParam1,dwParam2
-    );
+    FIXME(mmsys,"(%08x,%s,%08lx,%08lx): stub!\n",
+	  wDevID,_mciCommandToString(wMsg),dwParam1,dwParam2);
     switch (wMsg) {
     case MCI_OPEN: {
     	LPMCI_OPEN_PARMS32A	lpmop = (LPMCI_OPEN_PARMS32A)dwParam2;
-    	fprintf(stderr,"	MCI_OPEN(%s,%s,%s)\n",
-		(dwParam1&MCI_OPEN_TYPE)   ?lpmop->lpstrDeviceType:"<null>",
-		(dwParam1&MCI_OPEN_ELEMENT)?(HIWORD(lpmop->lpstrElementName)?lpmop->lpstrElementName:"<id>"):"<null>",
-		(dwParam1&MCI_OPEN_ALIAS)  ?lpmop->lpstrAlias:"<null>"
+    	TRACE(mmsys,"	MCI_OPEN(%s,%s,%s)\n",
+	      (dwParam1&MCI_OPEN_TYPE)   ?lpmop->lpstrDeviceType:"<null>",
+	      (dwParam1&MCI_OPEN_ELEMENT)?(HIWORD(lpmop->lpstrElementName)?lpmop->lpstrElementName:"<id>"):"<null>",
+	      (dwParam1&MCI_OPEN_ALIAS)  ?lpmop->lpstrAlias:"<null>"
 	);
 	break;
     }
@@ -2043,7 +2018,7 @@
                                     WORD * lpwPatchArray, UINT16 uFlags)
 {
         /* not really necessary to support this */
-	fprintf(stdnimp, "midiOutCachePatches: not supported yet\n");
+	FIXME(mmsys, "not supported yet\n");
 	return MMSYSERR_NOTSUPPORTED;
 }
 
@@ -2062,7 +2037,7 @@
 UINT16 WINAPI midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut, UINT16 uPatch,
                                         WORD * lpwKeyArray, UINT16 uFlags)
 {
-	fprintf(stdnimp, "midiOutCacheDrumPatchesi: not supported yet\n");
+	FIXME(mmsys, "not supported yet\n");
 	return MMSYSERR_NOTSUPPORTED;
 }
 
@@ -2102,7 +2077,7 @@
 	if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
 	switch (uMessage) {
 	case MODM_OPEN:
-		fprintf(stderr,"midiOutMessage32: can't handle MODM_OPEN!\n");
+		FIXME(mmsys,"can't handle MODM_OPEN!\n");
 		return 0;
 	case MODM_GETDEVCAPS:
 		return midiOutGetDevCaps32A(hMidiOut,(LPMIDIOUTCAPS32A)dwParam1,dwParam2);
@@ -2117,9 +2092,8 @@
 		/* no argument conversion needed */
 		break;
 	default:
-		fprintf(stderr,"unhandled midiOutMessage32(%04x,%04x,%08lx,%08lx)\n",
-			hMidiOut,uMessage,dwParam1,dwParam2
-		);
+	        ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
+		    hMidiOut,uMessage,dwParam1,dwParam2);
 		break;
 	}
 	return modMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
@@ -2139,7 +2113,7 @@
 	if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
 	switch (uMessage) {
 	case MODM_OPEN:
-		fprintf(stderr,"midiOutMessage16: can't handle MODM_OPEN!\n");
+		FIXME(mmsys,"can't handle MODM_OPEN!\n");
 		return 0;
 	case MODM_GETNUMDEVS:
 	case MODM_RESET:
@@ -2156,9 +2130,8 @@
 	case MODM_UNPREPARE:
 		return midiOutUnprepareHeader16(hMidiOut,(LPMIDIHDR)PTR_SEG_TO_LIN(dwParam1),dwParam2);
 	default:
-		fprintf(stderr,"unhandled midiOutMessage16(%04x,%04x,%08lx,%08lx)\n",
-			hMidiOut,uMessage,dwParam1,dwParam2
-		);
+		ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
+		    hMidiOut,uMessage,dwParam1,dwParam2);
 		break;
 	}
 	return modMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
@@ -2474,7 +2447,7 @@
 	if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
 	switch (uMessage) {
 	case MIDM_OPEN:
-		fprintf(stderr,"midiInMessage32: can't handle MIDM_OPEN!\n");
+		FIXME(mmsys,"can't handle MIDM_OPEN!\n");
 		return 0;
 	case MIDM_GETDEVCAPS:
 		return midiInGetDevCaps32A(hMidiIn,(LPMIDIINCAPS32A)dwParam1,dwParam2);
@@ -2492,9 +2465,8 @@
 	case MIDM_ADDBUFFER:
 		return midiInAddBuffer32(hMidiIn,(LPMIDIHDR)dwParam1,dwParam2);
 	default:
-		fprintf(stderr,"unhandled midiInMessage32(%04x,%04x,%08lx,%08lx)\n",
-			hMidiIn,uMessage,dwParam1,dwParam2
-		);
+		ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
+		    hMidiIn,uMessage,dwParam1,dwParam2);
 		break;
 	}
 	return midMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
@@ -2513,7 +2485,7 @@
 	if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
 	switch (uMessage) {
 	case MIDM_OPEN:
-		fprintf(stderr,"midiInMessage16: can't handle MIDM_OPEN!\n");
+		WARN(mmsys,"can't handle MIDM_OPEN!\n");
 		return 0;
 	case MIDM_GETDEVCAPS:
 		return midiInGetDevCaps16(hMidiIn,(LPMIDIINCAPS16)PTR_SEG_TO_LIN(dwParam1),dwParam2);
@@ -2531,9 +2503,8 @@
 	case MIDM_ADDBUFFER:
 		return midiInAddBuffer16(hMidiIn,(LPMIDIHDR)PTR_SEG_TO_LIN(dwParam1),dwParam2);
 	default:
-		fprintf(stderr,"unhandled midiInMessage16(%04x,%04x,%08lx,%08lx)\n",
-			hMidiIn,uMessage,dwParam1,dwParam2
-		);
+		ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
+		    hMidiIn,uMessage,dwParam1,dwParam2);
 		break;
 	}
 	return midMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
@@ -3094,12 +3065,11 @@
 		/* FIXME: UNICODE/ANSI? */
 		return waveOutGetDevCaps32A(hWaveOut,(LPWAVEOUTCAPS32A)dwParam1,dwParam2);
 	case WODM_OPEN:
-		fprintf(stderr,"waveOutMessage32 can't handle WODM_OPEN, please report.\n");
+		FIXME(mmsys,"can't handle WODM_OPEN, please report.\n");
 		break;
 	default:
-		fprintf(stderr,"unhandled waveOutMessage32(0x%04x,0x%04x,%08lx,%08lx)\n",
-			hWaveOut,uMessage,dwParam1,dwParam2
-		);
+		ERR(mmsys,"(0x%04x,0x%04x,%08lx,%08lx): unhandled message\n",
+		    hWaveOut,uMessage,dwParam1,dwParam2);
 		break;
 	}
 	return wodMessage( lpDesc->uDeviceID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
@@ -3143,12 +3113,11 @@
 	case WODM_WRITE:
 		return waveOutWrite16(hWaveOut,(LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1),dwParam2);
 	case WODM_OPEN:
-		fprintf(stderr,"waveOutMessage16 can't handle WODM_OPEN, please report.\n");
+		FIXME(mmsys,"can't handle WODM_OPEN, please report.\n");
 		break;
 	default:
-		fprintf(stderr,"unhandled waveOutMessage16(0x%04x,0x%04x,%08lx,%08lx)\n",
-			hWaveOut,uMessage,dwParam1,dwParam2
-		);
+		ERR(mmsys,"(0x%04x,0x%04x,%08lx,%08lx): unhandled message\n",
+		    hWaveOut,uMessage,dwParam1,dwParam2);
 	}
 	return wodMessage( lpDesc->uDeviceID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
 }
@@ -3589,13 +3558,13 @@
 {
 	LPWAVEOPENDESC	lpDesc;
 
-	fprintf(stderr, "waveInMessage32(%04X, %04X, %08lX, %08lX),FIXME!\n", 
-			hWaveIn, uMessage, dwParam1, dwParam2);
+	FIXME(mmsys, "(%04X, %04X, %08lX, %08lX),FIXME!\n", 
+	      hWaveIn, uMessage, dwParam1, dwParam2);
 	lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
 	if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
 	switch (uMessage) {
 	case WIDM_OPEN:
-		fprintf(stderr,"waveInMessage32: cannot handle WIDM_OPEN, please report.\n");
+		FIXME(mmsys, "cannot handle WIDM_OPEN, please report.\n");
 		break;
 	case WIDM_GETNUMDEVS:
 	case WIDM_GETPOS:
@@ -3613,7 +3582,8 @@
 		/*FIXME: ANSI/UNICODE */
 		return waveInGetDevCaps32A(hWaveIn,(LPWAVEINCAPS32A)dwParam1,dwParam2);
 	default:
-		fprintf(stderr,"unhandled waveInMessage32(%04x,%04x,%08lx,%08lx)\n",hWaveIn,uMessage,dwParam1,dwParam2);
+		ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
+		    hWaveIn,uMessage,dwParam1,dwParam2);
 		break;
 	}
 	return widMessage(lpDesc->uDeviceID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
@@ -3627,13 +3597,13 @@
 {
 	LPWAVEOPENDESC	lpDesc;
 
-	fprintf(stderr, "waveInMessage(%04X, %04X, %08lX, %08lX),FIXME!\n", 
-			hWaveIn, uMessage, dwParam1, dwParam2);
+	FIXME(mmsys, "(%04X, %04X, %08lX, %08lX),FIXME!\n", 
+	      hWaveIn, uMessage, dwParam1, dwParam2);
 	lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
 	if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
 	switch (uMessage) {
 	case WIDM_OPEN:
-		fprintf(stderr,"waveInMessage16: cannot handle WIDM_OPEN, please report.\n");
+		FIXME(mmsys,"cannot handle WIDM_OPEN, please report.\n");
 		break;
 	case WIDM_GETNUMDEVS:
 	case WIDM_CLOSE:
@@ -3654,7 +3624,8 @@
 	case WIDM_ADDBUFFER:
 		return waveInAddBuffer16(hWaveIn,(LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1),dwParam2);
 	default:
-		fprintf(stderr,"unhandled waveInMessage16(%04x,%04x,%08lx,%08lx)\n",hWaveIn,uMessage,dwParam1,dwParam2);
+		ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
+		    hWaveIn,uMessage,dwParam1,dwParam2);
 		break;
 	}
 	return widMessage(lpDesc->uDeviceID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
@@ -3716,9 +3687,7 @@
  * 				mmThreadCreate		[MMSYSTEM.1120]
  */
 LRESULT WINAPI mmThreadCreate16(LPVOID x1, LPWORD x2, DWORD x3, DWORD x4) {
-	fprintf(stderr,"mmThreadCreate16(%p,%p,%08lx,%08lx),stub!\n",
-		x1,x2,x3,x4
-	);
+	FIXME(mmsys,"(%p,%p,%08lx,%08lx): stub!\n",x1,x2,x3,x4);
 	*x2 = 0xbabe;
 	return 0;
 }
@@ -3727,7 +3696,7 @@
  * 				mmThreadGetTask		[MMSYSTEM.1125]
  */
 LRESULT WINAPI mmThreadGetTask16(WORD hnd) {
-	fprintf(stderr,"mmThreadGetTask16(%04x),stub!\n",hnd);
+	FIXME(mmsys,"(%04x): stub!\n",hnd);
 	return GetCurrentTask();
 }
 
@@ -3735,7 +3704,7 @@
  * 				mmThreadSignal		[MMSYSTEM.1121]
  */
 LRESULT WINAPI mmThreadSignal16(WORD hnd) {
-	fprintf(stderr,"mmThreadSignal16(%04x), stub!\n",hnd);
+	FIXME(mmsys,"(%04x): stub!\n",hnd);
 	return 0;
 }
 
@@ -3743,7 +3712,7 @@
  * 				mmTaskCreate		[MMSYSTEM.900]
  */
 LRESULT WINAPI mmTaskCreate16(LPWORD lphnd,DWORD x1,DWORD x2) {
-	fprintf(stderr,"mmTaskCreate16(%p,%08lx,%08lx),stub!\n",lphnd,x1,x2);
+	FIXME(mmsys,"(%p,%08lx,%08lx): stub!\n",lphnd,x1,x2);
 	*lphnd = 0xcafe;
 	return 0;
 }
@@ -3752,7 +3721,7 @@
  * 				mmTaskSignal		[MMSYSTEM.903]
  */
 LRESULT WINAPI mmTaskSignal16(HTASK16 ht) {
-	fprintf(stderr,"mmTaskSignal(%04x),stub!\n",ht);
+	FIXME(mmsys,"(%04x): stub!\n",ht);
 	return PostAppMessage16(ht,0x400,0,0);
 }
 
@@ -3760,7 +3729,7 @@
  * 				mciDriverYield		[MMSYSTEM.710]
  */
 LRESULT WINAPI mciDriverYield16(HANDLE16 hnd) {
-	fprintf(stderr,"mciDriverYield16(%04x),stub!\n",hnd);
+	FIXME(mmsys,"(%04x): stub!\n",hnd);
 	return 0;
 }
 
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index f1bb32b..c25333f 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -294,7 +294,7 @@
                                   bIcon ? "icon" : "cursor", cFlag ? "mono" : "" );
     if (dwVersion == 0x00020000)
     {
-	fprintf(stdnimp,"\t2.xx resources are not supported\n");
+	FIXME(cursor,"\t2.xx resources are not supported\n");
 	return 0;
     }
 
@@ -313,7 +313,7 @@
 	 (bmi->bmiHeader.biSize != sizeof(BITMAPINFOHEADER)  ||
 	  bmi->bmiHeader.biCompression != BI_RGB) )
     {
-          fprintf(stderr,"\tinvalid resource bitmap header.\n");
+          WARN(cursor,"\tinvalid resource bitmap header.\n");
           return 0;
     }
 
@@ -380,7 +380,7 @@
 
     if( !hXorBits || !hAndBits ) 
     {
-	fprintf(stderr,"\tunable to create an icon bitmap.\n");
+	WARN(cursor,"\tunable to create an icon bitmap.\n");
 	return 0;
     }
 
@@ -996,7 +996,7 @@
         if (!(ptr = (CURSORICONINFO*)GlobalLock16( hCursor ))) return FALSE;
         if (ptr->bPlanes * ptr->bBitsPerPixel != 1)
         {
-            fprintf( stderr, "Cursor %04x has more than 1 bpp!\n", hCursor );
+            WARN(cursor, "Cursor %04x has more than 1 bpp!\n", hCursor );
             return FALSE;
         }
 
@@ -1374,7 +1374,7 @@
 	     return (WORD)LookupIconIdFromDirectoryEx16( lpDir, TRUE,
 			  SYSMETRICS_CXICON, SYSMETRICS_CYICON, 0 );
 	default:
-	     fprintf( stderr, "GetIconID: invalid res type %ld\n", resType );
+	     WARN(cursor, "invalid res type %ld\n", resType );
     }
     return 0;
 }
@@ -1386,7 +1386,8 @@
  */
 HGLOBAL16 WINAPI LoadCursorIconHandler( HGLOBAL16 hResource, HMODULE16 hModule, HRSRC16 hRsrc )
 {
-    fprintf(stderr,"hModule[%04x]: old 2.x resources are not supported!\n", hModule);
+    FIXME(cursor,"(%04x,%04x,%04x): old 2.x resources are not supported!\n", 
+	  hResource, hModule, hRsrc);
     return (HGLOBAL16)0;
 }
 
diff --git a/objects/enhmetafile.c b/objects/enhmetafile.c
index 34c1700..8266275 100644
--- a/objects/enhmetafile.c
+++ b/objects/enhmetafile.c
@@ -6,8 +6,10 @@
 #include <stdio.h>
 #include <string.h>
 #include "windows.h"
+#include "gdi.h"
 #include "winbase.h"
 #include "winnt.h"
+#include "debug.h"
 
 /*****************************************************************************
  *          GetEnhMetaFile32A (GDI32.174)
@@ -18,20 +20,20 @@
 	     LPCSTR lpszMetaFile  /* filename of enhanced metafile */
     )
 {
-  HENHMETAFILE32 hmf = NULL;
+  HENHMETAFILE32 hmf = 0;
   ENHMETAHEADER h;
   char *p;
   DWORD read;
   HFILE32 hf = CreateFile32A(lpszMetaFile, GENERIC_READ, 0, 0, 
-			     OPEN_EXISTING, 0, NULL);
+			     OPEN_EXISTING, 0, 0);
   if (!ReadFile(hf, &h, sizeof(ENHMETAHEADER), &read, NULL)) 
-    return NULL;
-  if (read!=sizeof(ENHMETAHEADER)) return NULL;
+    return 0;
+  if (read!=sizeof(ENHMETAHEADER)) return 0;
   SetFilePointer(hf, 0, NULL, FILE_BEGIN); 
   /*  hmf = CreateFileMapping32A( hf, NULL, NULL, NULL, NULL, "temp"); */
   hmf = GlobalAlloc32(GHND, h.nBytes);
   p = GlobalLock32(hmf);
-  if (!ReadFile(hf, p, h.nBytes, &read, NULL)) return NULL;
+  if (!ReadFile(hf, p, h.nBytes, &read, NULL)) return 0;
   GlobalUnlock32(hmf);
   return hmf;
 }
@@ -68,7 +70,7 @@
 UINT32 GetEnhMetaFileDescription32A( 
        HENHMETAFILE32 hmf, /* enhanced metafile */
        UINT32 size, /* size of buf */ 
-       LPCSTR buf /* buffer to receive description */
+       LPSTR buf /* buffer to receive description */
     )
 {
   LPENHMETAHEADER p = GlobalLock32(hmf);
@@ -87,39 +89,242 @@
  *  RETURNS
  *    TRUE on success, FALSE on error.
  *  BUGS
- *    Unimplemented
+ *    Many unimplemented records.
  */
 BOOL32 PlayEnhMetaFileRecord32( 
      HDC32 hdc, 
      /* device context in which to render EMF record */
-     LPHANDLETABLE32 lpHandletable, 
+     LPHANDLETABLE32 handletable, 
      /* array of handles to be used in rendering record */
-     const ENHMETARECORD *lpEnhMetaRecord, /* EMF record to render */
-     UINT32 nHandles  /* size of handle array */
+     const ENHMETARECORD *mr, /* EMF record to render */
+     UINT32 handles  /* size of handle array */
      ) 
 {
   int type;
-  fprintf(stdout, 
-  "PlayEnhMetaFileRecord(hdc = %08x, handletable = %p, record = %p, numHandles = %d\n", 
-	  hdc, lpHandletable, lpEnhMetaRecord, nHandles);
-  /*  SetLastError(E_NOTIMPL); */
-  if (!lpEnhMetaRecord) return FALSE;
+  TRACE(metafile, 
+	"hdc = %08x, handletable = %p, record = %p, numHandles = %d\n", 
+	  hdc, handletable, mr, handles);
+  if (!mr) return FALSE;
 
-  type = lpEnhMetaRecord->iType;
+  type = mr->iType;
 
+  TRACE(metafile, " type=%d\n", type);
   switch(type) 
     {
     case EMR_HEADER:
-      printf("Header ok!\n");
-      return TRUE;
-      break;
+      {
+	ENHMETAHEADER *h = (LPENHMETAHEADER) mr;
+	break;
+      }
     case EMR_EOF:
-      printf("Eof ok!\n");
-      return TRUE;
+      break;
+
+    case EMR_GDICOMMENT:
+      /* application defined and processed */
+      break;
+
+    case EMR_SETMAPMODE:
+      {
+	DWORD mode = mr->dParm[0];
+	SetMapMode32(hdc, mode);
+	break;
+      }
+    case EMR_SETBKMODE:
+      {
+	DWORD mode = mr->dParm[0];
+	SetBkMode32(hdc, mode);
+	break;
+      }
+    case EMR_SETBKCOLOR:
+      {
+	DWORD mode = mr->dParm[0];
+	SetBkColor32(hdc, mode);
+	break;
+      }
+    case EMR_SETPOLYFILLMODE:
+      {
+	DWORD mode = mr->dParm[0];
+	SetPolyFillMode32(hdc, mode);
+	break;
+      }
+    case EMR_SETROP2:
+      {
+	DWORD mode = mr->dParm[0];
+	SetROP232(hdc, mode);
+	break;
+      }
+    case EMR_SETSTRETCHBLTMODE:
+      {
+	DWORD mode = mr->dParm[0];
+	SetStretchBltMode32(hdc, mode);
+	break;
+      }
+    case EMR_SETTEXTALIGN:
+      {
+	DWORD align = mr->dParm[0];
+	SetTextAlign32(hdc, align);
+	break;
+      }
+    case EMR_SETTEXTCOLOR:
+      {
+	DWORD color = mr->dParm[0];
+	SetTextColor32(hdc, color);
+	break;
+      }
+    case EMR_SAVEDC:
+      {
+	SaveDC32(hdc);
+	break;
+      }
+    case EMR_RESTOREDC:
+      {
+	RestoreDC32(hdc, mr->dParm[0]);
+	break;
+      }
+    case EMR_INTERSECTCLIPRECT:
+      {
+	INT32 left = mr->dParm[0], top = mr->dParm[1], right = mr->dParm[2],
+	      bottom = mr->dParm[3];
+	IntersectClipRect32(hdc, left, top, right, bottom);
+	break;
+      }
+
+    case EMR_SELECTOBJECT:
+      {
+	DWORD obj = mr->dParm[0];
+	SelectObject32(hdc, (handletable->objectHandle)[obj]);
+	break;
+      }
+    case EMR_DELETEOBJECT:
+      {
+	DWORD obj = mr->dParm[0];
+	DeleteObject32( (handletable->objectHandle)[obj]);
+	(handletable->objectHandle)[obj] = 0;
+	break;
+      }
+
+    case EMR_SETWINDOWORGEX:
+      {
+	DWORD x = mr->dParm[0], y = mr->dParm[1];
+	SetWindowOrgEx32(hdc, x, y, NULL);
+	break;
+      }
+    case EMR_SETWINDOWEXTEX:
+      {
+	DWORD x = mr->dParm[0], y = mr->dParm[1];
+	SetWindowExtEx32(hdc, x, y, NULL);
+	break;
+      }
+    case EMR_SETVIEWPORTORGEX:
+      {
+	DWORD x = mr->dParm[0], y = mr->dParm[1];
+	SetViewportOrgEx32(hdc, x, y, NULL);
+	break;
+      }
+    case EMR_SETVIEWPORTEXTEX:
+      {
+	DWORD x = mr->dParm[0], y = mr->dParm[1];
+	SetViewportExtEx32(hdc, x, y, NULL);
+	break;
+      }
+
+    case EMR_CREATEPEN:
+      {
+	DWORD obj = mr->dParm[0];
+	(handletable->objectHandle)[obj] = 
+	  CreatePenIndirect32((LOGPEN32 *) &(mr->dParm[1]));
+	break;
+      }
+    case EMR_EXTCREATEPEN:
+      {
+	DWORD obj = mr->dParm[0];
+	DWORD style = mr->dParm[1], brush = mr->dParm[2];
+	LOGBRUSH32 *b = (LOGBRUSH32 *) &mr->dParm[3];
+	/* FIXME: other args not handled */
+	(handletable->objectHandle)[obj] = 
+	  ExtCreatePen32(style, brush, b, 0, NULL);
+	break;
+      }
+    case EMR_CREATEBRUSHINDIRECT:
+      {
+	DWORD obj = mr->dParm[0];
+	(handletable->objectHandle)[obj] = 
+	  CreateBrushIndirect32((LOGBRUSH32 *) &(mr->dParm[1]));
+	break;
+      }
+    case EMR_EXTCREATEFONTINDIRECTW:
+	{
+	DWORD obj = mr->dParm[0];
+	(handletable->objectHandle)[obj] = 
+	  CreateFontIndirect32W((LOGFONT32W *) &(mr->dParm[1]));
+	break;
+	}
+
+    case EMR_MOVETOEX:
+      {
+	DWORD x = mr->dParm[0], y = mr->dParm[1];
+	MoveToEx32(hdc, x, y, NULL);
+	break;
+      }
+    case EMR_LINETO:
+      {
+	DWORD x = mr->dParm[0], y = mr->dParm[1];
+        LineTo32(hdc, x, y);
+	break;
+      }
+    case EMR_RECTANGLE:
+      {
+	INT32 left = mr->dParm[0], top = mr->dParm[1], right = mr->dParm[2],
+	      bottom = mr->dParm[3];
+	Rectangle32(hdc, left, top, right, bottom);
+	break;
+      }
+    case EMR_ELLIPSE:
+      {
+	INT32 left = mr->dParm[0], top = mr->dParm[1], right = mr->dParm[2],
+	      bottom = mr->dParm[3];
+	Ellipse32(hdc, left, top, right, bottom);
+	break;
+      }
+
+    case EMR_POLYGON16:
+      {
+	/* FIXME: 0-3 : a bounding rectangle? */
+	INT32 count = mr->dParm[4];
+	Polygon16(hdc, (POINT16 *)&mr->dParm[5], count);
+	break;
+      }
+#if 0
+    case EMR_POLYPOLYGON16:
+      {
+	INT32 polygons = mr->dParm[z];
+	LPPOINT16 pts = (LPPOINT16) &mr->dParm[x];
+	LPINT16 counts = (LPINT16) &mr->dParm[y];
+	PolyPolygon16(hdc, pts, counts, polygons);
+	break;
+      }
+#endif
+    case EMR_EXTTEXTOUTW:
+      {
+	/* 0-3: ??? */
+	DWORD flags = mr->dParm[4];
+	/* 5, 6: ??? */
+	DWORD x = mr->dParm[7], y = mr->dParm[8];
+	DWORD count = mr->dParm[9];
+	/* 10-16: ??? */
+	LPWSTR str = (LPWSTR)& mr->dParm[17];
+	/* trailing info: dx array? */
+	ExtTextOut32W(hdc, x, y, flags, /* lpRect */ NULL, 
+		      str, count, /* lpDx */ NULL); 
+	break;
+      }
+
+    default:
+      FIXME(metafile, "type %d is unimplemented\n", type);
+      /*  SetLastError(E_NOTIMPL); */
       break;
     }
-  printf("I dunno %d\n", type);
-  return FALSE;
+  return TRUE;
 }
 
 
@@ -138,7 +343,7 @@
  *  returns FALSE.
  *
  * BUGS
- *   Doesn't free objects, ignores rect.
+ *   Ignores rect.
  */
 BOOL32 EnumEnhMetaFile32( 
      HDC32 hdc, /* device context to pass to _EnhMetaFunc_ */
@@ -154,11 +359,12 @@
   HANDLETABLE32 *ht = (HANDLETABLE32 *)GlobalAlloc32(GPTR, sizeof(HANDLETABLE32)*count);
   ht->objectHandle[0] = hmf;
   while (ret) {
-    /*   printf("EnumEnhMetaFile: type = %ld size = %ld\n", p->iType, p->nSize);*/
     ret = (*callback)(hdc, ht, p, count, data); 
     if (p->iType == EMR_EOF) break;
     p = (void *) p + p->nSize;
   }
+  GlobalFree32(ht);
+  GlobalUnlock32(hmf);
   return ret;
 }
 
@@ -181,7 +387,8 @@
 {
   LPENHMETARECORD p = GlobalLock32(hmf);
   INT32 count = ((LPENHMETAHEADER) p)->nHandles;
-  HANDLETABLE32 *ht = (HANDLETABLE32 *)GlobalAlloc32(GPTR, sizeof(HANDLETABLE32)*count);
+  HANDLETABLE32 *ht = (HANDLETABLE32 *)GlobalAlloc32(GPTR, 
+				    sizeof(HANDLETABLE32)*count);
   ht->objectHandle[0] = hmf;
   while (1) {
     PlayEnhMetaFileRecord32(hdc, ht, p, count);
@@ -191,35 +398,18 @@
   return FALSE;
 }
 
-/*
-  need wide version as well
-*/
-HDC32 CreateEnhMetaFile32A( 
-    HDC32 hdcRef, /* optional reference DC */
-    LPCSTR lpFilename, /* optional filename for disk metafiles */
-    const RECT32 *lpRect, /* optional bounding rectangle */
-    LPCSTR lpDescription /* optional description */ 
-    )
-{
-  return NULL;
-}
-
-HENHMETAFILE32 CloseEnhMetaFile32( 
-               HDC32 hdc  /* metafile DC */
-	       )
-{
-  return NULL;
-}
-
-
 /*****************************************************************************
  *  DeleteEnhMetaFile32 (GDI32.68)
  */
 BOOL32 DeleteEnhMetaFile32(HENHMETAFILE32 hmf) {
-  return FALSE;
+  return !GlobalFree32(hmf);
 }
 
 /*****************************************************************************
  *  CopyEnhMetaFileA (GDI32.21)
  */
+HENHMETAFILE32 CopyEnhMetaFile32A(HENHMETAFILE32 hmf, LPCSTR file) {
+  return 0;
+}
+
 
diff --git a/objects/font.c b/objects/font.c
index afa374d..564a43c 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -13,7 +13,6 @@
 #include "metafile.h"
 #include "options.h"
 #include "debug.h"
-#include "debugstr.h"
 
 #define ENUM_UNICODE	0x00000001
 
@@ -231,7 +230,7 @@
 	    GDI_HEAP_UNLOCK( hFont );
 	}
     }
-    else fprintf(stderr,"CreateFontIndirect(NULL) => NULL\n");
+    else WARN(font,"(NULL) => NULL\n");
 
     return hFont;
 }
@@ -1025,8 +1024,7 @@
                                   LPABC32 abc )
 {
     /* No TrueType fonts in Wine so far */
-    fprintf( stdnimp, "STUB: GetCharABCWidths(%04x,%04x,%04x,%p)\n",
-             hdc, firstChar, lastChar, abc );
+    FIXME(font, "(%04x,%04x,%04x,%p): stub\n", hdc, firstChar, lastChar, abc );
     return FALSE;
 }
 
@@ -1048,8 +1046,8 @@
                                 LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
                                 LPVOID lpBuffer, const MAT2 *lpmat2 )
 {
-    fprintf( stdnimp,"GetGlyphOutLine16(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
-             hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
+    FIXME(font,"(%04x, '%c', %04x, %p, %ld, %p, %p): empty stub!\n",
+	  hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
     return (DWORD)-1; /* failure */
 }
 
@@ -1061,8 +1059,8 @@
                                  LPGLYPHMETRICS32 lpgm, DWORD cbBuffer,
                                  LPVOID lpBuffer, const MAT2 *lpmat2 )
 {
-    fprintf( stdnimp,"GetGlyphOutLine32A(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
-             hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
+    FIXME(font,"(%04x, '%c', %04x, %p, %ld, %p, %p): empty stub!\n",
+	  hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
     return (DWORD)-1; /* failure */
 }
 
@@ -1073,8 +1071,8 @@
                                  LPGLYPHMETRICS32 lpgm, DWORD cbBuffer,
                                  LPVOID lpBuffer, const MAT2 *lpmat2 )
 {
-    fprintf( stdnimp,"GetGlyphOutLine32W(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
-             hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
+    FIXME(font,"(%04x, '%c', %04x, %p, %ld, %p, %p): empty stub!\n",
+	  hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
     return (DWORD)-1; /* failure */
 }
 
@@ -1101,8 +1099,8 @@
      * enumbered with EnumFonts/EnumFontFamilies
      * lpszCurrentPath can be NULL
      */
-    fprintf(stdnimp,"CreateScalableFontResource(%ld,%s,%s,%s) // empty stub\n",
-            fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
+    FIXME(font,"(%ld,%s,%s,%s): empty stub\n",
+	  fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
     return FALSE; /* create failed */
 }
 
@@ -1114,8 +1112,8 @@
                                              LPCWSTR lpszFontFile,
                                              LPCWSTR lpszCurrentPath )
 {
-    fprintf(stdnimp,"CreateScalableFontResource32W(%ld,%p,%p,%p) // empty stub\n",
-            fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
+    FIXME(font,"(%ld,%p,%p,%p): empty stub\n",
+	  fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
     return FALSE; /* create failed */
 }
 
@@ -1149,8 +1147,10 @@
 {
     /* At this time kerning is ignored (set to 0) */
     int i;
-    fprintf(stdnimp,"GetKerningPairs16: almost empty stub!\n");
-    for (i = 0; i < cPairs; i++) lpKerningPairs[i].iKernAmount = 0;
+    FIXME(font,"(%x,%d,%p): almost empty stub!\n",
+	  hDC, cPairs, lpKerningPairs);
+    for (i = 0; i < cPairs; i++) 
+        lpKerningPairs[i].iKernAmount = 0;
     return 0;
 }
 
@@ -1163,8 +1163,10 @@
                                  LPKERNINGPAIR32 lpKerningPairs )
 {
     int i;
-    fprintf(stdnimp,"GetKerningPairs32: almost empty stub!\n");
-    for (i = 0; i < cPairs; i++) lpKerningPairs[i].iKernAmount = 0;
+    FIXME(font,"(%x,%ld,%p): almost empty stub!\n",
+	  hDC, cPairs, lpKerningPairs);
+    for (i = 0; i < cPairs; i++) 
+        lpKerningPairs[i].iKernAmount = 0;
     return 0;
 }
 
@@ -1179,9 +1181,7 @@
 }
 
 BOOL32 WINAPI TranslateCharSetInfo(LPDWORD lpSrc,LPCHARSETINFO lpCs,DWORD dwFlags) {
-    fprintf(stderr,"TranslateCharSetInfo(%p,%p,0x%08lx), stub.\n",
-    	lpSrc,lpCs,dwFlags
-    );
+    FIXME(font,"(%p,%p,0x%08lx), stub.\n",lpSrc,lpCs,dwFlags);
     return TRUE;
 }
 
@@ -1191,7 +1191,7 @@
  */
 DWORD WINAPI GetFontLanguageInfo32(HDC32 hdc) {
 	/* return value 0 is correct for most cases anyway */
-	fprintf(stderr,"GetFontLanguageInfo:stub!\n");
+        FIXME(font,"(%x):stub!\n", hdc);
 	return 0;
 }
 
@@ -1200,6 +1200,6 @@
  */
 DWORD WINAPI GetFontLanguageInfo16(HDC16 hdc) {
 	/* return value 0 is correct for most cases anyway */
-	fprintf(stderr,"GetFontLanguageInfo:stub!\n");
+	FIXME(font,"(%x):stub!\n",hdc);
 	return 0;
 }
diff --git a/objects/metafile.c b/objects/metafile.c
index 686d5cd..cd0a80b 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -728,7 +728,7 @@
 	  {
 	   TRACE(metafile,"%s  len: %ld\n",
              sot,mr->rdSize);
-           fprintf(stderr,
+           WARN(metafile,
 	     "Please report: PlayMetaFile/ExtTextOut len=%ld slen=%d rdSize=%ld opt=%04x\n",
 		   len,s1,mr->rdSize,mr->rdParam[3]);
            dxx = NULL; /* should't happen -- but if, we continue with NULL [for workaround] */
@@ -860,7 +860,7 @@
        	SetTextJustification32(hdc, *(mr->rdParam + 1), *(mr->rdParam));
 	break;
 
-#define META_UNIMP(x) case x: fprintf(stderr,"PlayMetaFileRecord:record type "#x" not implemented.\n");break;
+#define META_UNIMP(x) case x: FIXME(metafile, "PlayMetaFileRecord:record type "#x" not implemented.\n");break;
     META_UNIMP(META_FRAMEREGION)
     META_UNIMP(META_DRAWTEXT)
     META_UNIMP(META_SETDIBTODEV)
@@ -880,12 +880,23 @@
 #undef META_UNIMP
 
     default:
-	fprintf(stddeb,"PlayMetaFileRecord: Unknown record type %x\n",
+	WARN(metafile, "PlayMetaFileRecord: Unknown record type %x\n",
 	                                      mr->rdFunction);
     }
 }
 
 
+BOOL32 WINAPI PlayMetaFileRecord32( 
+     HDC32 hdc, 
+     HANDLETABLE32 *handletable, 
+     METARECORD *metarecord, 
+     UINT32 handles  
+    )
+{
+  PlayMetaFileRecord16(hdc, handletable, metarecord, handles);
+  return TRUE;
+}
+
 /******************************************************************
  *         GetMetaFileBits   (GDI.159)
  *
@@ -938,6 +949,21 @@
 }
 
 /******************************************************************
+ *         SetMetaFileBitsEx    (GDI32.323)
+ */
+HMETAFILE32 WINAPI SetMetaFileBitsEx( 
+     UINT32 size, /* size of metafile, in bytes */
+     const BYTE *lpData /* pointer to metafile data */  
+    )
+{
+  HMETAFILE32 hmf = GlobalAlloc16(GHND, size);
+  BYTE *p = GlobalLock16(hmf) ;
+  memcpy(p, lpData, size);
+  GlobalUnlock16(hmf);
+  return hmf;
+}
+
+/******************************************************************
  *         MF_Meta_CreateRegion
  *
  *  Handles META_CREATEREGION for PlayMetaFileRecord().
@@ -986,13 +1012,13 @@
 
 	end = start + *start + 3;
 	if(end > (WORD *)mr + mr->rdSize) {
-	    fprintf(stderr, "META_CREATEREGION: end points outside record.\n");
+	    WARN(metafile, "META_CREATEREGION: end points outside record.\n");
 	    DeleteObject32( hrgn2 );
 	    return FALSE;
         }
 
 	if(*start != *end) {
-	    fprintf(stderr, "META_CREATEREGION: mismatched delimiters.\n");
+	    WARN(metafile, "META_CREATEREGION: mismatched delimiters.\n");
 	    DeleteObject32( hrgn2 );
 	    return FALSE;
 	}
@@ -1037,7 +1063,7 @@
 	    return FALSE;
         break;
     default:
-        fprintf( stderr, "Unknown metafile type %d\n", physDev->mh->mtType );
+        ERR(metafile, "Unknown metafile type %d\n", physDev->mh->mtType );
         return FALSE;
     }
 
@@ -1554,7 +1580,7 @@
 
     len = GetRegionData( hrgn, 0, NULL );
     if( !(rgndata = HeapAlloc( SystemHeap, 0, len )) ) {
-        fprintf(stderr, "MF_CreateRegion: can't alloc rgndata buffer\n");
+        WARN(metafile, "MF_CreateRegion: can't alloc rgndata buffer\n");
 	return -1;
     }
     GetRegionData( hrgn, len, rgndata );
@@ -1564,7 +1590,7 @@
      */
     len = sizeof(METARECORD) + 20 + (rgndata->rdh.nCount * 12);
     if( !(mr = HeapAlloc( SystemHeap, 0, len )) ) {
-        fprintf(stderr, "MF_CreateRegion: can't alloc METARECORD buffer\n");
+        WARN(metafile, "MF_CreateRegion: can't alloc METARECORD buffer\n");
 	HeapFree( SystemHeap, 0, rgndata );
 	return -1;
     }
@@ -1619,7 +1645,7 @@
     HeapFree( SystemHeap, 0, rgndata );
     if(!ret) 
     {
-        fprintf(stderr, "MF_CreateRegion: MF_WriteRecord failed\n");
+        WARN(metafile, "MF_CreateRegion: MF_WriteRecord failed\n");
 	return -1;
     }
     return MF_AddHandleDC( dc );
diff --git a/objects/palette.c b/objects/palette.c
index 8e25970..3775e9f 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -115,7 +115,7 @@
  */
 HPALETTE32 WINAPI CreateHalftonePalette(HDC32 hdc)
 {
-  fprintf(stdnimp,"CreateHalftonePalette: empty stub!\n");
+  FIXME(palette,"(%x): empty stub!\n", hdc);
   return NULL;
 }
 
@@ -312,8 +312,7 @@
 UINT32 WINAPI SetSystemPaletteUse32( HDC32 hdc, UINT32 use )
 {
     UINT32 old = SystemPaletteUse;
-    fprintf( stdnimp,"SetSystemPaletteUse(%04x,%04x) // empty stub !!!\n",
-             hdc, use );
+    FIXME(palette,"(%04x,%04x): empty stub !!!\n", hdc, use );
     SystemPaletteUse = use;
     return old;
 }
@@ -536,9 +535,9 @@
     }
     else TRACE(palette, "  skipping (hLastRealizedPalette = %04x)\n",
 			 hLastRealizedPalette);
-    
     GDI_HEAP_UNLOCK( hdc );
-    FIXME(palette, "   realized %i colors - not impmenented?\n", realized );
+
+    TRACE(palette, "   realized %i colors.\n", realized );
     return (UINT16)realized;
 }
 
diff --git a/objects/text.c b/objects/text.c
index 4f83209..c6e8b26 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -320,10 +320,8 @@
 INT32 DrawTextEx32A( HDC32 hdc, LPCSTR str, INT32 count,
                      LPRECT32 rect, UINT32 flags, LPDRAWTEXTPARAMS dtp )
 {
-    fprintf(stderr,"DrawTextEx32A(%d,'%s',%d,%p,0x%08x,%p)\n",
-    	hdc,str,count,rect,flags,dtp
-    );
-    /*FIXME: ignores extended functionality ... */
+    TRACE(text,"(%d,'%s',%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
+    FIXME(text,"ignores extended functionality\n");
     return DrawText32A(hdc,str,count,rect,flags);
 }
 
@@ -333,10 +331,8 @@
 INT32 DrawTextEx32W( HDC32 hdc, LPCWSTR str, INT32 count,
                      LPRECT32 rect, UINT32 flags, LPDRAWTEXTPARAMS dtp )
 {
-    fprintf(stderr,"DrawTextEx32A(%d,%p,%d,%p,0x%08x,%p)\n",
-    	hdc,str,count,rect,flags,dtp
-    );
-    /*FIXME: ignores extended functionality ... */
+    TRACE(text,"(%d,%p,%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
+    FIXME(text,"ignores extended functionality\n");
     return DrawText32W(hdc,str,count,rect,flags);
 }
 
@@ -719,8 +715,8 @@
  */
 INT32 WINAPI GetTextCharset32(HDC32 hdc)
 {
-    fprintf(stdnimp,"GetTextCharset(0x%x)\n",hdc);
-    return DEFAULT_CHARSET; /* FIXME */
+    FIXME(text,"(0x%x): stub\n",hdc);
+    return DEFAULT_CHARSET; 
 }
 
 INT16 WINAPI GetTextCharset16(HDC16 hdc)
@@ -733,7 +729,7 @@
  */
 INT32 WINAPI GetTextCharsetInfo(HDC32 hdc,LPCHARSETINFO csi,DWORD flags)
 {
-    fprintf(stdnimp,"GetTextCharsetInfo(0x%x,%p,%08lx), stub!\n",hdc,csi,flags);
+    FIXME(text,"(0x%x,%p,%08lx): stub!\n",hdc,csi,flags);
     if (csi) {
 	csi->ciCharset = DEFAULT_CHARSET;
 	csi->ciACP = GetACP();
diff --git a/ole/compobj.c b/ole/compobj.c
index 19047fa..2f10e31 100644
--- a/ole/compobj.c
+++ b/ole/compobj.c
@@ -30,6 +30,9 @@
 
 /***********************************************************************
  *           CoBuildVersion [COMPOBJ.1]
+ *
+ * RETURNS
+ *	Current built version, hiword is majornumber, loword is minornumber
  */
 DWORD WINAPI CoBuildVersion()
 {
@@ -39,7 +42,7 @@
 
 /***********************************************************************
  *           CoInitialize	[COMPOBJ.2]
- * lpReserved is an IMalloc pointer in 16bit OLE.
+ * Set the win16 IMalloc used for memory management
  */
 HRESULT WINAPI CoInitialize16(
 	LPMALLOC16 lpReserved	/* [in] pointer to win16 malloc interface */
@@ -50,7 +53,7 @@
 
 /***********************************************************************
  *           CoInitialize	(OLE32.26)
- * lpReserved is an IMalloc pointer in 32bit OLE.
+ * Set the win32 IMalloc used for memorymanagement
  */
 HRESULT WINAPI CoInitialize32(
 	LPMALLOC32 lpReserved	/* [in] pointer to win32 malloc interface */
@@ -61,6 +64,7 @@
 
 /***********************************************************************
  *           CoUnitialize   [COMPOBJ.3]
+ * Don't know what it does.
  */
 void WINAPI CoUnitialize()
 {
@@ -69,6 +73,8 @@
 
 /***********************************************************************
  *           CoGetMalloc    [COMPOBJ.4]
+ * RETURNS
+ *	The current win16 IMalloc
  */
 HRESULT WINAPI CoGetMalloc16(
 	DWORD dwMemContext,	/* [in] unknown */
@@ -82,6 +88,8 @@
 
 /***********************************************************************
  *           CoGetMalloc    (OLE32.4]
+ * RETURNS
+ *	The current win32 IMalloc
  */
 HRESULT WINAPI CoGetMalloc32(
 	DWORD dwMemContext,	/* [in] unknown */
@@ -104,20 +112,31 @@
 
 /***********************************************************************
  *           IsEqualGUID [COMPOBJ.18]
+ * Compares two Unique Identifiers
+ * RETURNS
+ *	TRUE if equal
  */
-BOOL16 WINAPI IsEqualGUID(GUID* g1, GUID* g2)
-{
+BOOL16 WINAPI IsEqualGUID(
+	GUID* g1,	/* [in] unique id 1 */
+	GUID* g2	/* [in] unique id 2 */
+) {
     return !memcmp( g1, g2, sizeof(GUID) );
 }
 
 /***********************************************************************
  *           CLSIDFromString [COMPOBJ.20]
+ * Converts a unique identifier from it's string representation into 
+ * the GUID struct.
+ * RETURNS
+ *	the converted GUID
  */
 
 /* Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] */
 
-OLESTATUS WINAPI CLSIDFromString16(const LPCOLESTR16 idstr, CLSID *id)
-{
+OLESTATUS WINAPI CLSIDFromString16(
+	LPCOLESTR16 idstr,	/* [in] string representation of guid */
+	CLSID *id		/* [out] GUID converted from string */
+) {
   BYTE *s = (BYTE *) idstr;
   BYTE *p;
   int	i;
@@ -182,9 +201,15 @@
 
 /***********************************************************************
  *           CLSIDFromString (OLE32.3)
+ * Converts a unique identifier from it's string representation into 
+ * the GUID struct.
+ * RETURNS
+ *	the converted GUID
  */
-OLESTATUS WINAPI CLSIDFromString32(const LPCOLESTR32 idstr, CLSID *id)
-{
+OLESTATUS WINAPI CLSIDFromString32(
+	LPCOLESTR32 idstr,	/* [in] string representation of GUID */
+	CLSID *id		/* [out] GUID represented by above string */
+) {
     LPOLESTR16      xid = HEAP_strdupWtoA(GetProcessHeap(),0,idstr);
     OLESTATUS       ret = CLSIDFromString16(xid,id);
 
@@ -193,10 +218,15 @@
 }
 
 /***********************************************************************
- *           StringFromCLSID [COMPOBJ.19]
+ *           WINE_StringFromCLSID 				[internal]
+ * Converts a GUID into the respective string representation.
+ * RETURNS
+ *	the string representation and OLESTATUS
  */
-OLESTATUS WINAPI WINE_StringFromCLSID(const CLSID *id, LPSTR idstr)
-{
+OLESTATUS WINAPI WINE_StringFromCLSID(
+	const CLSID *id,	/* [in] GUID to be converted */
+	LPSTR idstr		/* [out] pointer to buffer to contain converted guid */
+) {
   static const char *hex = "0123456789ABCDEF";
   char *s;
   int	i;
@@ -224,8 +254,18 @@
   return OLE_OK;
 }
 
-OLESTATUS WINAPI StringFromCLSID16(const CLSID *id, LPOLESTR16 *idstr)
-{
+/***********************************************************************
+ *           StringFromCLSID 	[COMPOBJ.19]
+ * Converts a GUID into the respective string representation.
+ * The target string is allocated using the OLE IMalloc.
+ * RETURNS
+ *	the string representation and OLESTATUS
+ */
+OLESTATUS WINAPI StringFromCLSID16(
+	const CLSID *id,	/* [in] the GUID to be converted */
+	LPOLESTR16 *idstr	/* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
+
+) {
     LPMALLOC16	mllc;
     OLESTATUS	ret;
     DWORD	args[2];
@@ -254,8 +294,17 @@
     return WINE_StringFromCLSID(id,PTR_SEG_TO_LIN(*idstr));
 }
 
-OLESTATUS WINAPI StringFromCLSID32(const CLSID *id, LPOLESTR32 *idstr)
-{
+/***********************************************************************
+ *           StringFromCLSID 	[OLE32.151]
+ * Converts a GUID into the respective string representation.
+ * The target string is allocated using the OLE IMalloc.
+ * RETURNS
+ *	the string representation and OLESTATUS
+ */
+OLESTATUS WINAPI StringFromCLSID32(
+	const CLSID *id,	/* [in] the GUID to be converted */
+	LPOLESTR32 *idstr	/* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
+) {
 	char            buf[80];
 	OLESTATUS       ret;
 	LPMALLOC32	mllc;
@@ -271,23 +320,50 @@
 	return ret;
 }
 
-OLESTATUS WINAPI StringFromGUID2(
-	const CLSID *id, LPOLESTR16 idstr, INT16 max
-) {
-	char		buf[80];
-	OLESTATUS	ret = WINE_StringFromCLSID(id,buf);
+/***********************************************************************
+ *           StringFromGUID2 (OLE32.152)
+ *
+ * Converts a global unique identifier into a string of an API-
+ * specified fixed format.
+ *
+ * mortene@pvv.org 980318
+ */
+OLESTATUS WINAPI
+StringFromGUID2(const REFGUID *id, LPOLESTR32 *str, INT32 cmax)
+{
+  int chars_in_string = strlen("[DDDDDDDD-WWWW-WWWW-WWWW-WWWWDDDDDDDD]")+1;
+  DWORD dwtmp[2];
+  WORD wtmp[4];
 
-	if (!ret)
-		lstrcpyn32A(idstr,buf,max);
-	return ret;
+  if(cmax >= chars_in_string) {
+    dwtmp[0] = *(DWORD *)id;
+    wtmp[0] = *(WORD *)(id + sizeof(DWORD));
+    wtmp[1] = *(WORD *)(id + sizeof(DWORD) + sizeof(WORD));
+    wtmp[2] = *(WORD *)(id + sizeof(DWORD) + 2*sizeof(WORD));
+    wtmp[3] = *(WORD *)(id + sizeof(DWORD) + 3*sizeof(WORD));
+    dwtmp[1] = *(DWORD *)(id + sizeof(DWORD) + 4*sizeof(WORD));
+    sprintf(*(char **)str, "[%08lx-%04x-%04x-%04x-%04x%08lx]",
+	    dwtmp[0], wtmp[0], wtmp[1], wtmp[2], wtmp[3], dwtmp[1]);
+    TRACE(ole, "'%s'\n", *str);
+    return chars_in_string;
+  }
+  else {
+    WARN(ole, "Too little space in the string: need %d chars, got: %d\n",
+	 chars_in_string, cmax);
+    return 0;
+  }
 }
 
 /***********************************************************************
  *           CLSIDFromProgID [COMPOBJ.61]
+ * Converts a program id into the respective GUID. (By using a registry lookup)
+ * RETURNS
+ *	riid associated with the progid
  */
-
-OLESTATUS WINAPI CLSIDFromProgID16(LPCSTR progid,LPCLSID riid)
-{
+OLESTATUS WINAPI CLSIDFromProgID16(
+	LPCOLESTR16 progid,	/* [in] program id as found in registry */
+	LPCLSID riid		/* [out] associated CLSID */
+) {
 	char	*buf,buf2[80];
 	DWORD	buf2len;
 	HRESULT	err;
@@ -311,9 +387,14 @@
 
 /***********************************************************************
  *           CLSIDFromProgID (OLE32.2)
+ * Converts a program id into the respective GUID. (By using a registry lookup)
+ * RETURNS
+ *	riid associated with the progid
  */
-OLESTATUS WINAPI CLSIDFromProgID32(LPCOLESTR32 progid,LPCLSID riid)
-{
+OLESTATUS WINAPI CLSIDFromProgID32(
+	LPCOLESTR32 progid,	/* [in] program id as found in registry */
+	LPCLSID riid		/* [out] associated CLSID */
+) {
 	LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid);
 	OLESTATUS       ret = CLSIDFromProgID16(pid,riid);
 
@@ -321,11 +402,17 @@
 	return ret;
 }
 
+/***********************************************************************
+ *           LookupETask (COMPOBJ.94)
+ */
 OLESTATUS WINAPI LookupETask(LPVOID p1,LPVOID p2) {
 	fprintf(stderr,"LookupETask(%p,%p),stub!\n",p1,p2);
 	return 0;
 }
 
+/***********************************************************************
+ *           LookupETask (COMPOBJ.201)
+ */
 OLESTATUS WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) {
 	fprintf(stderr,"CallObjectInWOW(%p,%p),stub!\n",p1,p2);
 	return 0;
@@ -333,16 +420,20 @@
 
 /***********************************************************************
  *		CoRegisterClassObject [COMPOBJ.5]
+ * Don't know where it registers it ...
  */
 OLESTATUS WINAPI CoRegisterClassObject16(
-	REFCLSID rclsid, LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,
+	REFCLSID rclsid,
+	LPUNKNOWN pUnk,
+	DWORD dwClsContext,
+	DWORD flags,
 	LPDWORD lpdwRegister
 ) {
 	char	buf[80];
 
 	WINE_StringFromCLSID(rclsid,buf);
 
-	fprintf(stderr,"CoRegisterClassObject(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
+	FIXME(ole,"(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
 		buf,pUnk,dwClsContext,flags,lpdwRegister
 	);
 	return 0;
@@ -350,16 +441,20 @@
 
 /***********************************************************************
  *		CoRegisterClassObject (OLE32.36)
+ * Don't know where it registers it ...
  */
 OLESTATUS WINAPI CoRegisterClassObject32(
-	REFCLSID rclsid, LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,
+	REFCLSID rclsid,
+	LPUNKNOWN pUnk,
+	DWORD dwClsContext,
+	DWORD flags,
 	LPDWORD lpdwRegister
 ) {
     char buf[80];
 
     WINE_StringFromCLSID(rclsid,buf);
 
-    fprintf(stderr,"CoRegisterClassObject(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
+    FIXME(ole,"(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
 	    buf,pUnk,dwClsContext,flags,lpdwRegister
     );
     return 0;
@@ -369,21 +464,35 @@
  *		CoRegisterMessageFilter [COMPOBJ.27]
  */
 OLESTATUS WINAPI CoRegisterMessageFilter16(
-	LPMESSAGEFILTER lpMessageFilter,LPMESSAGEFILTER *lplpMessageFilter
+	LPMESSAGEFILTER lpMessageFilter,
+	LPMESSAGEFILTER *lplpMessageFilter
 ) {
-	fprintf(stderr,"CoRegisterMessageFilter(%p,%p),stub!\n",
-		lpMessageFilter,lplpMessageFilter
-	);
+	FIXME(ole,"(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);
 	return 0;
 }
 
 /***********************************************************************
  *           CoCreateInstance [COMPOBJ.13, OLE32.7]
  */
-HRESULT WINAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
-				DWORD dwClsContext, REFIID riid, LPVOID *ppv)
-{
-	fprintf(stderr, "CoCreateInstance(): stub !\n");
+HRESULT WINAPI CoCreateInstance(
+	REFCLSID rclsid,
+	LPUNKNOWN pUnkOuter,
+	DWORD dwClsContext,
+	REFIID riid,
+	LPVOID *ppv
+) {
+	char buf[80],xbuf[80];
+
+	if (rclsid)
+		WINE_StringFromCLSID(rclsid,buf);
+	else
+		sprintf(buf,"<rclsid-0x%08lx>",(DWORD)rclsid);
+	if (riid)
+		WINE_StringFromCLSID(riid,xbuf);
+	else
+		sprintf(xbuf,"<riid-0x%08lx>",(DWORD)riid);
+
+	FIXME(ole,"(%s,%p,0x%08lx,%s,%p): stub !\n",buf,pUnkOuter,dwClsContext,xbuf,ppv);
 	*ppv = NULL;
 	return S_OK;
 }
@@ -393,16 +502,17 @@
  */
 void WINAPI CoFreeUnusedLibraries()
 {
-	fprintf(stderr, "CoFreeUnusedLibraries(): stub !\n");
+	FIXME(ole,"(), stub !\n");
 }
 
 /***********************************************************************
  *           CoFileTimeNow [COMPOBJ.82, OLE32.10]
- *
- *	stores the current system time in lpFileTime
+ * RETURNS
+ *	the current system time in lpFileTime
  */
-HRESULT WINAPI CoFileTimeNow(FILETIME *lpFileTime)
-{
+HRESULT WINAPI CoFileTimeNow(
+	FILETIME *lpFileTime	/* [out] the current time */
+) {
 	DOSFS_UnixTimeToFileTime(time(NULL), lpFileTime, 0);
 	return S_OK;
 }
@@ -410,7 +520,7 @@
 /***********************************************************************
  *           CoTaskMemAlloc (OLE32.43)
  * RETURNS
- *  pointer to newly allocated block
+ * 	pointer to newly allocated block
  */
 LPVOID WINAPI CoTaskMemAlloc(
 	ULONG size	/* [in] size of memoryblock to be allocated */
diff --git a/ole/ole2nls.c b/ole/ole2nls.c
index 19d7a6a..a0d5608 100644
--- a/ole/ole2nls.c
+++ b/ole/ole2nls.c
@@ -282,7 +282,7 @@
 		i++;
 	}
 	if (!retString) {
-		fprintf(stderr,"Unkown LC type %lX\n",LCType);
+		WARN(ole,"Unkown LC type %lX\n",LCType);
 		return 0;
 	}
 
@@ -1787,7 +1787,7 @@
     }  /* switch */
 
 	if(!found) {
-		fprintf(stderr,"'%s' not supported for your language.\n",
+		ERR(ole,"'%s' not supported for your language.\n",
 			retString);
 		retString = "<WINE-NLS-unknown>";
 		/*return 0;*/
@@ -1831,11 +1831,9 @@
 {
 	int len,ret;
 	if(fdwStyle & NORM_IGNORENONSPACE)
-	{
-		fprintf(stdnimp, "CompareStringA: IGNORENONSPACE not supprted\n");
-	}
+		FIXME(ole, "IGNORENONSPACE not supprted\n");
 	if(fdwStyle & NORM_IGNORESYMBOLS)
-		fprintf(stdnimp, "CompareStringA: IGNORESYMBOLS not supported\n");
+		FIXME(ole, "IGNORESYMBOLS not supported\n");
 	/* Is strcmp defaulting to string sort or to word sort?? */
 	/* FIXME: Handle NORM_STRINGSORT */
 	l1 = (l1==-1)?strlen(s1):l1;
@@ -1861,9 +1859,9 @@
 {
 	int len,ret;
 	if(fdwStyle & NORM_IGNORENONSPACE)
-		fprintf(stdnimp,"CompareStringW:IGNORENONSPACE not supprted\n");
+		FIXME(ole,"IGNORENONSPACE not supprted\n");
 	if(fdwStyle & NORM_IGNORESYMBOLS)
-		fprintf(stdnimp,"CompareStringW:IGNORESYMBOLS not supported\n");
+		FIXME(ole,"IGNORESYMBOLS not supported\n");
 
 	/* Is strcmp defaulting to string sort or to word sort?? */
 	/* FIXME: Handle NORM_STRINGSORT */
@@ -1885,7 +1883,7 @@
  */
 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
 {
-    fprintf(stdnimp,"SetLocaleInfoA(%ld,%ld,%s)\n",lcid,lctype,data);
+    FIXME(ole,"(%ld,%ld,%s): stub\n",lcid,lctype,data);
     return TRUE;
 }
 
@@ -1909,8 +1907,7 @@
 	WCHAR	buffer[200];
 	HKEY	xhkey;
 
-	TRACE(win32,"(%p,%08lx)\n",
-                      lpfnLocaleEnum,flags );
+	TRACE(win32,"(%p,%08lx)\n",lpfnLocaleEnum,flags );
 	/* see if we can reuse the Win95 registry entries.... */
 	if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
 		i=0;
@@ -2003,10 +2000,10 @@
 
 	switch (dwInfoType) {
 	case CT_CTYPE2:
-		fprintf(stderr,"GetStringType32A:CT_CTYPE2 not supported.\n");
+		FIXME(ole,"CT_CTYPE2 not supported.\n");
 		return FALSE;
 	case CT_CTYPE3:
-		fprintf(stderr,"GetStringType32A:CT_CTYPE3 not supported.\n");
+		FIXME(ole,"CT_CTYPE3 not supported.\n");
 		return FALSE;
 	default:break;
 	}
@@ -2050,10 +2047,10 @@
 
 	switch (dwInfoType) {
 	case CT_CTYPE2:
-		fprintf(stderr,"GetStringType32W:CT_CTYPE2 not supported.\n");
+		FIXME(ole,"CT_CTYPE2 not supported.\n");
 		return FALSE;
 	case CT_CTYPE3:
-		fprintf(stderr,"GetStringType32W:CT_CTYPE3 not supported.\n");
+		FIXME(ole,"CT_CTYPE3 not supported.\n");
 		return FALSE;
 	default:break;
 	}
@@ -2163,10 +2160,9 @@
 	}
 	if (mapflags)
 	  {
-	    fprintf(stderr,
-		    "LCMapStringA(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
-		    lcid,mapflags,srcstr,srclen,dststr,dstlen);
-		fprintf(stderr,"	unimplemented flags: 0x%08lx\n",mapflags);
+	    FIXME(ole,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
+		  "unimplemented flags: 0x%08lx\n",
+		  lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
 	  }
 	return len;
 }
@@ -2202,10 +2198,9 @@
 	}
 	if (mapflags)
 	  {
-	    fprintf(stderr,
-		    "LCMapStringW(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
-		    lcid,mapflags,srcstr,srclen,dststr,dstlen);
-		fprintf(stderr,"	unimplemented flags: 0x%08lx\n",mapflags);
+	    FIXME(ole,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
+		  "unimplemented flags: 0x%08lx\n",
+		  lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
 	  }
 	return len;
 }
@@ -2255,16 +2250,16 @@
 {
    INT32 inpos, outpos;
    int count, type, inquote, Overflow;
-  char buf[40];
-  int buflen;
+   char buf[40];
+   int buflen;
 
    const char * _dgfmt[] = { "%d", "%02d" };
    const char ** dgfmt = _dgfmt - 1; 
 
    /* report, for debugging */
-   TRACE(ole, "func(%8x,%8x, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p (%9s), len=%ld)\n", locale, flags,
-		xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
-		format, format, date, date, datelen);
+   TRACE(ole, "func(%#lx,%#lx, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p (%9s), len=%d)\n", locale, flags,
+	 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
+	 format, format, date, date, datelen);
   
    /* initalize state variables and output buffer */
    inpos = outpos = 0;
@@ -2571,13 +2566,11 @@
 			      LPCSTR format, 
 			      LPSTR timestr,INT32 timelen) 
 {
-   INT32 ret;
    LPCSTR realformat;
    char fmt_buf[40];
    
    TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
-		locale,flags,xtime,format,timestr,timelen
-	);
+	 locale,flags,xtime,format,timestr,timelen);
    
    if (format) {
       realformat = format;
diff --git a/ole/olecli.c b/ole/olecli.c
index e510951..010f1eb 100644
--- a/ole/olecli.c
+++ b/ole/olecli.c
@@ -20,7 +20,7 @@
 OLESTATUS WINAPI OleRegisterClientDoc16(LPCSTR classname, LPCSTR docname,
                                         LONG reserved, LHCLIENTDOC *hRet )
 {
-    fprintf(stdnimp,"OleRegisterClientDoc:%s %s\n",classname,docname);
+    FIXME(ole,"(%s,%s,...): stub\n",classname,docname);
     *hRet=++OLE_current_handle;
     return OLE_OK;
 }
@@ -31,7 +31,7 @@
 OLESTATUS WINAPI OleRegisterClientDoc32(LPCSTR classname, LPCSTR docname,
                                         LONG reserved, LHCLIENTDOC *hRet )
 {
-    fprintf(stdnimp,"OleRegisterClientDoc:%s %s\n",classname,docname);
+    FIXME(ole,"(%s,%s,...): stub\n",classname,docname);
     *hRet=++OLE_current_handle;
     return OLE_OK;
 }
@@ -41,7 +41,7 @@
  */
 OLESTATUS WINAPI OleRenameClientDoc16(LHCLIENTDOC hDoc, LPCSTR newName)
 {
-    fprintf(stdnimp,"OleRenameClientDoc: %ld %s\n",hDoc, newName);
+    FIXME(ole,"(%ld,%s,...): stub\n",hDoc, newName);
     return OLE_OK;
 }
 
@@ -50,7 +50,7 @@
  */
 OLESTATUS WINAPI OleRenameClientDoc32(LHCLIENTDOC hDoc, LPCSTR newName)
 {
-    fprintf(stdnimp,"OleRenameClientDoc: %ld %s\n",hDoc, newName);
+    FIXME(ole,"(%ld,%s,...): stub\n",hDoc, newName);
     return OLE_OK;
 }
 
@@ -59,7 +59,7 @@
  */
 OLESTATUS WINAPI OleRevokeClientDoc16(LHCLIENTDOC hServerDoc)
 {
-    fprintf(stdnimp,"OleRevokeClientDoc:%ld\n",hServerDoc);
+    FIXME(ole,"(%ld): stub\n",hServerDoc);
     return OLE_OK;
 }
 
@@ -68,7 +68,7 @@
  */
 OLESTATUS WINAPI OleRevokeClientDoc32(LHCLIENTDOC hServerDoc)
 {
-    fprintf(stdnimp,"OleRevokeClientDoc:%ld\n",hServerDoc);
+    FIXME(ole,"(%ld): stub\n",hServerDoc);
     return OLE_OK;
 }
 
@@ -79,9 +79,8 @@
 	LPCSTR name,LPOLECLIENT olecli,LHCLIENTDOC hclientdoc,LPCSTR xname,
 	LPOLEOBJECT *lpoleob,OLEOPT_RENDER render,OLECLIPFORMAT clipformat
 ) {
-	fprintf(stdnimp,"OleCreateLinkFromClip(%s,%p,%08lx,%s,%p,%d,%ld),stub!\n",
-		name,olecli,hclientdoc,xname,lpoleob,render,clipformat
-	);
+	FIXME(ole,"(%s,%p,%08lx,%s,%p,%d,%ld): stub!\n",
+	      name,olecli,hclientdoc,xname,lpoleob,render,clipformat);
 	return OLE_OK;
 }
 
@@ -89,18 +88,14 @@
  *           OleQueryLinkFromClip32
  */
 OLESTATUS WINAPI OleQueryLinkFromClip32(LPCSTR name,OLEOPT_RENDER render,OLECLIPFORMAT clipformat) {
-	fprintf(stdnimp,"OleQueryLinkFromClip(%s,%d,%ld),stub!\n",
-		name,render,clipformat
-	);
+	FIXME(ole,"(%s,%d,%ld): stub!\n",name,render,clipformat);
 	return OLE_OK;
 }
 /***********************************************************************
  *           OleQueryCreateFromClip32
  */
 OLESTATUS WINAPI OleQueryCreateFromClip32(LPCSTR name,OLEOPT_RENDER render,OLECLIPFORMAT clipformat) {
-	fprintf(stdnimp,"OleQueryCreateFromClip(%s,%d,%ld),stub!\n",
-		name,render,clipformat
-	);
+	FIXME(ole,"(%s,%d,%ld): stub!\n",name,render,clipformat);
 	return OLE_OK;
 }
 
@@ -129,7 +124,7 @@
  *           OleSetHostNames
  */
 OLESTATUS WINAPI OleSetHostNames32(LPOLEOBJECT oleob,LPCSTR name1,LPCSTR name2) {
-	fprintf(stdnimp,"OleSetHostNames(%p,%s,%s),stub\n",oleob,name1,name2);
+	FIXME(ole,"(%p,%s,%s): stub\n",oleob,name1,name2);
 	return OLE_OK;
 }
 
@@ -137,12 +132,11 @@
  *           OleQueryType32
  */
 OLESTATUS WINAPI OleQueryType32(LPOLEOBJECT oleob,LONG*xlong) {
-	fprintf(stdnimp,"OleQueryType(%p,%p),stub!\n",oleob,xlong);
+	FIXME(ole,"(%p,%p): stub!\n",oleob,xlong);
 	if (!oleob)
 		return 0x10;
-	fprintf(stddeb,"Calling OLEOBJECT.QueryType (%p) (%p,%p)\n",
-		oleob->lpvtbl->QueryType,oleob,xlong
-	);
+	TRACE(ole,"Calling OLEOBJECT.QueryType (%p) (%p,%p)\n",
+	      oleob->lpvtbl->QueryType,oleob,xlong);
 	return oleob->lpvtbl->QueryType(oleob,xlong);
 }
 
@@ -153,9 +147,8 @@
 	LPCSTR name,LPOLECLIENT olecli,LHCLIENTDOC hclientdoc,LPCSTR xname,
 	LPOLEOBJECT *lpoleob,OLEOPT_RENDER render, OLECLIPFORMAT clipformat
 ) {
-	fprintf(stdnimp,"OleCreateLinkFromClip(%s,%p,%08lx,%s,%p,%d,%ld),stub!\n",
-		name,olecli,hclientdoc,xname,lpoleob,render,clipformat
-	);
+	FIXME(ole,"(%s,%p,%08lx,%s,%p,%d,%ld): stub!\n",
+	      name,olecli,hclientdoc,xname,lpoleob,render,clipformat);
 	/* clipb type, object kreieren entsprechend etc. */
 	return OLE_OK;
 }
diff --git a/ole/olesvr.c b/ole/olesvr.c
index f604a4a..62b5e0a 100644
--- a/ole/olesvr.c
+++ b/ole/olesvr.c
@@ -20,7 +20,7 @@
                                       LHSERVER *hRet, HINSTANCE16 hServer,
                                       OLE_SERVER_USE use )
 {
-    FIXME(ole,"%s - stub\n",name);
+    FIXME(ole,"(%s,...): stub\n",name);
     *hRet=++OLE_current_handle;
     /* return OLE_ERROR_MEMORY, OLE_ERROR_PROTECT_ONLY if you want it fail*/
     return OLE_OK;
@@ -31,7 +31,7 @@
  */
 OLESTATUS WINAPI OleBlockServer16(LHSERVER hServer)
 {
-    fprintf(stdnimp,"OleBlockServer:%ld\n",hServer);
+    FIXME(ole,"(%ld): stub\n",hServer);
     return OLE_OK;
 }
 
@@ -40,7 +40,7 @@
  */
 OLESTATUS WINAPI OleBlockServer32(LHSERVER hServer)
 {
-    fprintf(stdnimp,"OleBlockServer:%ld\n",hServer);
+    FIXME(ole,"(%ld): stub\n",hServer);
     return OLE_OK;
 }
 
@@ -49,7 +49,7 @@
  */
 OLESTATUS WINAPI OleUnblockServer16(LHSERVER hServer, BOOL16 *block)
 {
-    fprintf(stdnimp,"OleUnblockServer:%ld\n",hServer);
+    FIXME(ole,"(%ld): stub\n",hServer);
     /* no more blocked messages :) */
     *block=FALSE;
     return OLE_OK;
@@ -60,7 +60,7 @@
  */
 OLESTATUS WINAPI OleUnblockServer32(LHSERVER hServer, BOOL32 *block)
 {
-    fprintf(stdnimp,"OleUnblockServer:%ld\n",hServer);
+    FIXME(ole,"(%ld): stub\n",hServer);
     /* no more blocked messages :) */
     *block=FALSE;
     return OLE_OK;
@@ -73,8 +73,7 @@
                                          LPOLESERVERDOC document,
                                          LHSERVERDOC *hRet)
 {
-    FIXME(ole,"%ld,%s - stub\n", 
-		hServer, docname);
+    FIXME(ole,"(%ld,%s): stub\n",hServer, docname);
     *hRet=++OLE_current_handle;
     return OLE_OK;
 }
@@ -93,7 +92,7 @@
  */
 OLESTATUS WINAPI OleRevokeServerDoc32(LHSERVERDOC hServerDoc)
 {
-    fprintf(stdnimp,"OleRevokeServerDoc:%ld\n",hServerDoc);
+    FIXME(ole,"(%ld): stub\n",hServerDoc);
     return OLE_OK;
 }
 
@@ -107,9 +106,7 @@
 }
 
 OLESTATUS WINAPI OleRegisterServer32(LPCSTR svrname,LPOLESERVER olesvr,LHSERVER* hRet,HINSTANCE32 hinst,OLE_SERVER_USE osu) {
-	fprintf(stderr,"OleRegisterServer(%s,%p,%p,%08x,%d),stub!\n",
-		svrname,olesvr,hRet,hinst,osu
-	);
+	FIXME(ole,"(%s,%p,%p,%08x,%d): stub!\n",svrname,olesvr,hRet,hinst,osu);
     	*hRet=++OLE_current_handle;
 	return OLE_OK;
 }
@@ -118,7 +115,7 @@
                                          LPOLESERVERDOC document,
                                          LHSERVERDOC *hRet)
 {
-    fprintf(stdnimp,"OleRegisterServerDoc:%ld,%s\n", hServer, docname);
+    FIXME(ole,"(%ld,%s): stub\n", hServer, docname);
     *hRet=++OLE_current_handle;
     return OLE_OK;
 }
@@ -129,6 +126,6 @@
  */
 OLESTATUS WINAPI OleRenameServerDoc32(LHSERVERDOC hDoc, LPCSTR newName)
 {
-    fprintf(stderr,"OleRenameServerDoc: %ld %s; stub.\n",hDoc, newName);
+    FIXME(ole,"(%ld,%s): stub.\n",hDoc, newName);
     return OLE_OK;
 }
diff --git a/ole/storage.c b/ole/storage.c
index 3377f79..19f4fbd 100644
--- a/ole/storage.c
+++ b/ole/storage.c
@@ -23,7 +23,6 @@
 #include "module.h"
 #include "ldt.h"
 #include "debug.h"
-#include "debugstr.h"
 
 static const BYTE STORAGE_magic[8]   ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1};
 static const BYTE STORAGE_notmagic[8]={0x0e,0x11,0xfc,0x0d,0xd0,0xcf,0x11,0xe0};
diff --git a/ole/typelib.c b/ole/typelib.c
index 16cd72c..d988d03 100644
--- a/ole/typelib.c
+++ b/ole/typelib.c
@@ -15,17 +15,30 @@
 #include "compobj.h"
 #include "debug.h"
 
+/****************************************************************************
+ *	QueryPathOfRegTypeLib			(TYPELIB.14)
+ * RETURNS
+ *	path of typelib
+ */
 HRESULT WINAPI
-QueryPathOfRegTypeLib(REFGUID guid,WORD wMaj, WORD wMin, LCID lcid,LPSTR path) 
-{
+QueryPathOfRegTypeLib(	
+	REFGUID guid,	/* [in] referenced guid */
+	WORD wMaj,	/* [in] major version */
+	WORD wMin,	/* [in] minor version */
+	LCID lcid,	/* [in] locale id */
+	LPSTR path	/* [out] path of typelib */
+) {
 	char	xguid[80];
 
 	if (HIWORD(guid))
 		WINE_StringFromCLSID(guid,xguid);
 	else
-		sprintf(xguid,"<guid 0x%08lx>",guid);
-	fprintf(stderr,"QueryPathOfRegTypeLib(%s,%d,%d,0x%04x,%p),stub!\n",
-		xguid,wMaj,wMin,lcid,path
-	);
+		sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
+	FIXME(ole,"(%s,%d,%d,0x%04x,%p),stub!\n",xguid,wMaj,wMin,lcid,path);
 	return E_FAIL;
 }
+
+DWORD WINAPI OABuildVersion()
+{
+	return MAKELONG(0xbd3, 0x3);
+}
diff --git a/programs/notepad/TODO b/programs/notepad/TODO
index a14a2b4..bb55f48 100644
--- a/programs/notepad/TODO
+++ b/programs/notepad/TODO
@@ -1,2 +1,4 @@
 
+ - Notepad segfaults when selecting "Find" button in "Search" dialog.
+ 
  - create new *.rc files for all languages you know.
diff --git a/programs/notepad/dialog.c b/programs/notepad/dialog.c
index cde9a6b..62790d8 100644
--- a/programs/notepad/dialog.c
+++ b/programs/notepad/dialog.c
@@ -15,12 +15,14 @@
 #include "license.h"
 #include "dialog.h"
 #include "version.h"
+#include "debug.h"
 
 static LRESULT DIALOG_PAGESETUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
 
 VOID DIALOG_FileNew(VOID)
 {
-  fprintf(stderr, "FileNew()\n");
+//  dprintf_fixme(Global, "FileNew() not yet implemented\n");
+  printf("FileNew()\n");
 }
 
 VOID DIALOG_FileOpen(VOID)
@@ -65,7 +67,9 @@
  	  openfilename.lpTemplateName    = 0;
 
   	  if (GetOpenFileName(&openfilename)) {
-	  printf("Openfile: %s\n", openfilename.lpstrFile);
+            lstrcpyn(Globals.szFileName, openfilename.lpstrFile, 
+                     strlen(openfilename.lpstrFile)+1);
+          printf("OpenFile: %s\n", Globals.szFileName);
 	  }
 }
 
@@ -76,7 +80,7 @@
 
 VOID DIALOG_FileSaveAs(VOID)
 {
-          OPENFILENAME savefilename;
+          OPENFILENAME saveas;
           CHAR szPath[MAX_PATHNAME_LEN];
           CHAR szDir[MAX_PATHNAME_LEN];
           CHAR szzFilter[2 * MAX_STRING_LEN + 100];
@@ -94,34 +98,38 @@
 
           GetWindowsDirectory(szDir, sizeof(szDir));
 
-          savefilename.lStructSize       = 0;
-          savefilename.hwndOwner         = Globals.hMainWnd;
-          savefilename.hInstance         = Globals.hInstance;
-          savefilename.lpstrFilter       = szzFilter;
-          savefilename.lpstrCustomFilter = 0;
-          savefilename.nMaxCustFilter    = 0;
-          savefilename.nFilterIndex      = 0;
-          savefilename.lpstrFile         = szPath;
-          savefilename.nMaxFile          = sizeof(szPath);
-          savefilename.lpstrFileTitle    = 0;
-          savefilename.nMaxFileTitle     = 0;
-          savefilename.lpstrInitialDir   = szDir;
-          savefilename.lpstrTitle        = 0;
-          savefilename.Flags             = 0;
-          savefilename.nFileOffset       = 0;
-          savefilename.nFileExtension    = 0;
-          savefilename.lpstrDefExt       = 0;
-          savefilename.lCustData         = 0;
-          savefilename.lpfnHook          = 0;
-          savefilename.lpTemplateName    = 0;
+          saveas.lStructSize       = 0;
+          saveas.hwndOwner         = Globals.hMainWnd;
+          saveas.hInstance         = Globals.hInstance;
+          saveas.lpstrFilter       = szzFilter;
+          saveas.lpstrCustomFilter = 0;
+          saveas.nMaxCustFilter    = 0;
+          saveas.nFilterIndex      = 0;
+          saveas.lpstrFile         = szPath;
+          saveas.nMaxFile          = sizeof(szPath);
+          saveas.lpstrFileTitle    = 0;
+          saveas.nMaxFileTitle     = 0;
+          saveas.lpstrInitialDir   = szDir;
+          saveas.lpstrTitle        = 0;
+          saveas.Flags             = 0;
+          saveas.nFileOffset       = 0;
+          saveas.nFileExtension    = 0;
+          saveas.lpstrDefExt       = 0;
+          saveas.lCustData         = 0;
+          saveas.lpfnHook          = 0;
+          saveas.lpTemplateName    = 0;
 
-          if (GetSaveFileName(&savefilename));
+          if (GetSaveFileName(&saveas)) {
+            lstrcpyn(Globals.szFileName, saveas.lpstrFile, 
+                     strlen(saveas.lpstrFile)+1);
+            printf("SaveAs(%s)\n", Globals.szFileName);
+          }
 }
 
 VOID DIALOG_FilePrint(VOID)
 {
 	PRINTDLG printer;
-	printer.lStructSize           = 0;
+	printer.lStructSize           = sizeof(printer);
         printer.hwndOwner             = Globals.hMainWnd;
         printer.hInstance             = Globals.hInstance;
         printer.hDevMode              = 0;
@@ -141,7 +149,9 @@
 	printer.hPrintTemplate        = 0;
 	printer.hSetupTemplate        = 0;
 	
-	if(PrintDlg16(&printer));
+	if(PrintDlg16(&printer)) {
+          /* do nothing */
+        };
 }
 
 VOID DIALOG_FilePageSetup(VOID)
@@ -205,6 +215,9 @@
 {
           FINDREPLACE find;
 	  CHAR szFind[MAX_PATHNAME_LEN];
+          
+          lstrcpyn(szFind, Globals.szFindText, strlen(Globals.szFindText)+1);
+          
 	  find.lStructSize               = 0;
           find.hwndOwner                 = Globals.hMainWnd;
           find.hInstance                 = Globals.hInstance;
@@ -214,7 +227,14 @@
           find.lCustData                 = 0;
           find.lpfnHook                  = 0;
           find.lpTemplateName            = 0;
-	  FindText(&find);
+
+	  if (FindText(&find)) {
+             lstrcpyn(Globals.szFindText, szFind, strlen(szFind)+1);
+          } 
+             else 
+          { 
+             /* do nothing */ 
+          };
 }
 
 VOID DIALOG_SearchNext(VOID)
diff --git a/programs/notepad/main.c b/programs/notepad/main.c
index a7f8cea..88493c4 100644
--- a/programs/notepad/main.c
+++ b/programs/notepad/main.c
@@ -114,17 +114,6 @@
  *           WinMain
  */
 
-void DumpGlobals(void) {
-
-    printf("DumpGlobals()\n");
-    printf(" Globals.lpszIniFile: %s\n", Globals.lpszIniFile); 
-    printf(" Globals.lpszIcoFile: %s\n", Globals.lpszIcoFile);
-    printf("Globals.lpszLanguage: %s\n", Globals.lpszLanguage);
-    printf("   Globals.hInstance: %i\n", Globals.hInstance);
-    printf("   Globals.hMainMenu: %i\n", Globals.hMainMenu);
-    
-}
- 
 int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show)
 {
     MSG      msg;
@@ -139,14 +128,12 @@
       LIBWINE_Register_Sw();
     #endif
 
-    printf("WinMain()\n");
-    
     /* Setup Globals */
 
     Globals.lpszIniFile   = "notepad.ini";
     Globals.lpszIcoFile   = "notepad.ico";
 
-  /* Select Language */
+    /* Select Language */
     LANGUAGE_Init();
 
     Globals.hInstance     = hInstance;
@@ -155,20 +142,22 @@
     if (!Globals.hMainIcon) Globals.hMainIcon = 
                                   LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));
 
-    DumpGlobals();				  
-				  
+    lstrcpyn(Globals.szFindText, "\0", 1);
+    lstrcpyn(Globals.szFileName, "\0", 1);
+
     if (!prev){
-	class.style = CS_HREDRAW | CS_VREDRAW;
-	class.lpfnWndProc = NOTEPAD_WndProc;
-	class.cbClsExtra = 0;
-	class.cbWndExtra = 0;
-	class.hInstance  = Globals.hInstance;
-	class.hIcon      = LoadIcon (0, IDI_APPLICATION);
-	class.hCursor    = LoadCursor (0, IDC_ARROW);
+	class.style         = CS_HREDRAW | CS_VREDRAW;
+	class.lpfnWndProc   = NOTEPAD_WndProc;
+	class.cbClsExtra    = 0;
+	class.cbWndExtra    = 0;
+	class.hInstance     = Globals.hInstance;
+	class.hIcon         = LoadIcon (0, IDI_APPLICATION);
+	class.hCursor       = LoadCursor (0, IDC_ARROW);
 	class.hbrBackground = GetStockObject (WHITE_BRUSH);
-	class.lpszMenuName = "bla\0";
+	class.lpszMenuName  = 0;
 	class.lpszClassName = (SEGPTR)className;
     }
+
     if (!RegisterClass (&class))
 	return FALSE;
 
diff --git a/programs/notepad/main.h b/programs/notepad/main.h
index 69e7419..7c76b30 100644
--- a/programs/notepad/main.h
+++ b/programs/notepad/main.h
@@ -31,6 +31,8 @@
   LPCSTR  lpszLanguage;
   UINT    wStringTableOffset;
   BOOL    bWrapLongLines;
+  CHAR    szFindText[MAX_PATHNAME_LEN];
+  CHAR    szFileName[MAX_PATHNAME_LEN];
 } NOTEPAD_GLOBALS;
 
 extern NOTEPAD_GLOBALS Globals;
diff --git a/programs/view/Makefile.in b/programs/view/Makefile.in
index 5efd9f9..b222aef 100644
--- a/programs/view/Makefile.in
+++ b/programs/view/Makefile.in
@@ -13,6 +13,9 @@
 	view.c \
 	winmain.c
 
+RC_SRCS = \
+	viewrc.rc
+
 all: check_winerc $(PROGRAMS)
 
 depend:: $(RC_SRCS:.rc=.h)
diff --git a/programs/view/globals.h b/programs/view/globals.h
index dea1c60..9889911 100644
--- a/programs/view/globals.h
+++ b/programs/view/globals.h
@@ -16,7 +16,7 @@
 extern char      szTitle[];      /* The title bar text */
 
 
-
+#ifdef WINELIB
 typedef struct
 {
 	DWORD	key WINE_PACKED;
@@ -26,6 +26,18 @@
 	DWORD	reserved WINE_PACKED;
 	WORD	checksum WINE_PACKED;
 } APMFILEHEADER WINE_PACKED;
+#else
+#pragma pack( 2 )
+typedef struct
+{
+	DWORD		key;
+	WORD		hmf;
+	SMALL_RECT	bbox;
+	WORD		inch;
+	DWORD		reserved;
+	WORD		checksum;
+} APMFILEHEADER;
+#endif
 
 #define APMHEADER_KEY	0x9AC6CDD7l
 
diff --git a/programs/view/view.c b/programs/view/view.c
index 3f150b6..d49483c 100644
--- a/programs/view/view.c
+++ b/programs/view/view.c
@@ -11,6 +11,7 @@
 
 #include "globals.h"        
 #include "resource.h"
+#include <stdio.h>
 
 BOOL FileIsPlaceable( LPCSTR szFileName );
 HMETAFILE GetPlaceableMetaFile( LPCSTR szFileName );
@@ -67,12 +68,7 @@
 	    if (FileOpen(hwnd, filename)) {
 	      isAldus = FileIsPlaceable(filename);
 	      if (isAldus) {
-#if 1
 		hmf = GetPlaceableMetaFile(filename);
-#else
-		MessageBox(hwnd, "This is an Aldus placeable metafile: I can't deal with those!",
-			   "Aldus", MB_OK);
-#endif
 	      } else {
 		RECT r;
 		hmf = GetMetaFile(filename);
@@ -142,54 +138,58 @@
   return (apmh.key == APMHEADER_KEY);
 }
 
-/* this code doesn't work */
-#if 1
 HMETAFILE GetPlaceableMetaFile( LPCSTR szFileName )
 {
-  HANDLE hData;
   LPSTR	lpData;
   METAHEADER mfHeader;
   APMFILEHEADER	APMHeader;
-  HMETAFILE hmf = NULL;
   HFILE	fh;
+  HMETAFILE hmf;
   OFSTRUCT inof;
+  WORD checksum, *p;
+  int i;
 
-  if( (fh = OpenFile( szFileName, &inof, OF_READ ) ) == HFILE_ERROR ) return NULL;
+  if( (fh = OpenFile( szFileName, &inof, OF_READ ) ) == HFILE_ERROR ) return 0;
   _llseek(fh, 0, 0);
-  if (!_lread(fh, (LPSTR)&APMHeader, sizeof(APMFILEHEADER))) return NULL;
+  if (!_lread(fh, (LPSTR)&APMHeader, sizeof(APMFILEHEADER))) return 0;
   _llseek(fh, sizeof(APMFILEHEADER), 0);
-  printf("sizeof(APMFILEHEADER) %d\n", sizeof(APMFILEHEADER));
-  if (!_lread(fh, (LPSTR)&mfHeader, sizeof(METAHEADER))) return NULL;
+  checksum = 0;
+  p = (WORD *) &APMHeader;
 
-  if (!(hData = GlobalAlloc(GHND, (mfHeader.mtSize * 2L)))) return NULL;
-
-  if (!(lpData = GlobalLock(hData)))
-  {
-    GlobalFree(hData);
-    return NULL;
+  for(i=0; i<10; i++) 
+    checksum ^= *p++;
+  if (checksum != APMHeader.checksum) {
+    char msg[128];
+    sprintf(msg, "Computed checksum %04x != stored checksum %04x\n", 
+	   checksum, APMHeader.checksum);
+    /*    MessageBox(hwnd, msg, "Checksum failed", MB_OK); */
+    return 0;
   }
 
+  if (!_lread(fh, (LPSTR)&mfHeader, sizeof(METAHEADER))) return 0;
+
+  if (!(lpData = GlobalAlloc(GPTR, (mfHeader.mtSize * 2L)))) return 0;
+
   _llseek(fh, sizeof(APMFILEHEADER), 0);
   if (!_lread(fh, lpData, (UINT)(mfHeader.mtSize * 2L)))
   {
-    GlobalUnlock(hData);
-    GlobalFree(hData);
+    GlobalFree(lpData);
+    _lclose(fh);
     return NULL;
   }
   _lclose(fh);
-  GlobalUnlock(hData);
 
-  if (!(hmf = (HMETAFILE) SetMetaFileBits(hData))) return NULL;
+  if (!(hmf = SetMetaFileBitsEx(mfHeader.mtSize*2, lpData))) 
+    return NULL;
 
   
   width = APMHeader.bbox.right - APMHeader.bbox.left;
   height = APMHeader.bbox.bottom - APMHeader.bbox.top;
 
-  printf("Ok! width %d height %d\n", width, height);
+  /*  printf("Ok! width %d height %d\n", width, height); */
   deltax = 0;
   deltay = 0 ;
   return hmf;
 }
-#endif
 
 
diff --git a/programs/winhelp/ChangeLog b/programs/winhelp/ChangeLog
index 3d072ba..c69bc5f 100644
--- a/programs/winhelp/ChangeLog
+++ b/programs/winhelp/ChangeLog
@@ -1,8 +1,13 @@
+Mon Mar 23 17:00:36 1998  Marcel Baur <mbaur@g26.ethz.ch>
+
+        * Added preliminary Print() dialog in [macro.c]
+
 Sun Jan 18 23:05:04 1998  Karl Backström <karl_b@geocities.com>
+
         * [Sw.rc]
         Added Swedish language support.
 
-Fri Jul 4 12:00:00 1997  Henrik Olsen <Henrik.Olsen@iaeste.dk>
+Fri Jul  4 12:00:00 1997  Henrik Olsen <Henrik.Olsen@iaeste.dk>
 
 	* [Da.rc] (new)
 	Added Danish language support.
diff --git a/programs/winhelp/macro.c b/programs/winhelp/macro.c
index d33ddcc..2c43ba3 100644
--- a/programs/winhelp/macro.c
+++ b/programs/winhelp/macro.c
@@ -12,6 +12,7 @@
 #endif
 #include "winhelp.h"
 #include "macro.h"
+#include "debug.h"
 
 VOID MACRO_About(VOID)
 {
@@ -460,7 +461,31 @@
 
 VOID MACRO_Print(VOID)
 {
-  fprintf(stderr, "Print()\n");
+    PRINTDLG printer;
+    
+    printer.lStructSize         = sizeof(printer);
+    printer.hwndOwner           = Globals.active_win->hMainWnd;
+    printer.hInstance           = Globals.hInstance;
+    printer.hDevMode            = 0;
+    printer.hDevNames           = 0;
+    printer.hDC                 = 0;
+    printer.Flags               = 0;
+    printer.nFromPage           = 0;
+    printer.nToPage             = 0;
+    printer.nMinPage            = 0;
+    printer.nMaxPage            = 0;
+    printer.nCopies             = 0;
+    printer.lCustData           = 0;
+    printer.lpfnPrintHook       = 0;
+    printer.lpfnSetupHook       = 0;
+    printer.lpPrintTemplateName = 0;
+    printer.lpSetupTemplateName = 0;
+    printer.hPrintTemplate      = 0;
+    printer.hSetupTemplate      = 0;
+        
+    if (PrintDlg16(&printer)) {
+        fprintf(stderr, "Print()\n");
+    };
 }
 
 VOID MACRO_PrinterSetup(VOID)
diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c
index cd8a22b..a21f7de 100644
--- a/programs/winhelp/winhelp.c
+++ b/programs/winhelp/winhelp.c
@@ -17,9 +17,10 @@
 VOID LIBWINE_Register_En(void);
 VOID LIBWINE_Register_Fi(void);
 VOID LIBWINE_Register_Fr(void);
+VOID LIBWINE_Register_Hu(void);
 VOID LIBWINE_Register_It(void);
 VOID LIBWINE_Register_Ko(void);
-VOID LIBWINE_Register_Hu(void);
+VOID LIBWINE_Register_Sw(void);
 VOID LIBWINE_Register_Va(void);
 
 static BOOL    WINHELP_RegisterWinClasses();
diff --git a/relay32/comctl32.spec b/relay32/comctl32.spec
index 6e224d2..34f968d 100644
--- a/relay32/comctl32.spec
+++ b/relay32/comctl32.spec
@@ -4,6 +4,7 @@
 # Functions exported by the Win95 comctl32.dll 
 # (these need to have these exact ordinals, because some win95 dlls 
 #  import comctl32.dll by ordinal)
+#   This list was created from a comctl32.dll v4.72 (IE4.01).
 
   2 stub MenuHelp
   3 stub ShowHideMenuCtl
@@ -12,62 +13,140 @@
   6 stdcall CreateStatusWindowA(long ptr long long) CreateStatusWindow32A
   7 stub CreateToolbar
   8 stub CreateMappedBitmap
-  9 stub Cctl1632_ThunkData32
- 10 stub CreatePropertySheetPage
- 11 stub CreatePropertySheetPageA
- 12 stub CreatePropertySheetPageW
+#  9 stub COMCTL32_9
+# 10 stub COMCTL32_10
+# 11 stub COMCTL32_11
+ 12 stub Cctl1632_ThunkData32
  13 stub MakeDragList
  14 stub LBItemFromPt
  15 stub DrawInsert
  16 stdcall CreateUpDownControl(long long long long long long long long long long long long) CreateUpDownControl
  17 stdcall InitCommonControls() InitCommonControls
-# 18 pascal16 CreateStatusWindow(word ptr word word) CreateStatusWindow16
- 18 stub CreateStatusWindow
- 19 stdcall CreateStatusWindowW(long ptr long long) CreateStatusWindow32W
- 20 stub CreateToolbarEx
- 21 stub DestroyPropertySheetPage
- 22 stub DllGetVersion
-# 23 pascal16 DrawStatusText(word ptr ptr word) DrawStatusText16
- 23 stub DrawStatusText
- 24 stdcall DrawStatusTextW(long ptr ptr long) DrawStatusText32W
- 25 stdcall ImageList_Add(ptr long long) ImageList_Add
- 26 stub ImageList_AddIcon
- 27 stdcall ImageList_AddMasked(ptr long long) ImageList_AddMasked
- 28 stub ImageList_BeginDrag
- 29 stub ImageList_Copy
- 30 stdcall ImageList_Create(long long long long long) ImageList_Create
- 31 stdcall ImageList_Destroy(ptr) ImageList_Destroy
- 32 stub ImageList_DragEnter
- 33 stub ImageList_DragLeave
- 34 stub ImageList_DragMove
- 35 stub ImageList_DragShowNolock
- 36 stdcall ImageList_Draw(ptr long long long long long) ImageList_Draw
- 37 stub ImageList_DrawEx
- 38 stub ImageList_EndDrag
- 39 stdcall ImageList_GetBkColor(ptr) ImageList_GetBkColor
- 40 stub ImageList_GetDragImage
- 41 stub ImageList_GetIcon
- 42 stdcall ImageList_GetIconSize(ptr ptr ptr) ImageList_GetIconSize
- 43 stdcall ImageList_GetImageCount(ptr) ImageList_GetImageCount
- 44 stdcall ImageList_GetImageInfo(ptr long ptr) ImageList_GetImageInfo
- 45 stub ImageList_GetImageRect
- 46 stub ImageList_LoadImage
- 47 stdcall ImageList_LoadImageA(long ptr long long long long long) ImageList_LoadImage32A
- 48 stdcall ImageList_LoadImageW(long ptr long long long long long) ImageList_LoadImage32W
- 49 stdcall ImageList_Merge(ptr long ptr long long long) ImageList_Merge
- 50 stub ImageList_Read
- 51 stub ImageList_Remove
- 52 stdcall ImageList_Replace(ptr long long long) ImageList_Replace
- 53 stdcall ImageList_ReplaceIcon(ptr long long) ImageList_ReplaceIcon
- 54 stdcall ImageList_SetBkColor(ptr long) ImageList_SetBkColor
- 55 stub ImageList_SetDragCursorImage
- 56 stub ImageList_SetFilter
- 57 stub ImageList_SetIconSize
- 58 stub ImageList_SetImageCount
- 59 stdcall ImageList_SetOverlayImage(ptr long long) ImageList_SetOverlayImage
- 60 stub ImageList_Write
- 61 stub InitCommonControlsEx
- 62 stub PropertySheet
- 63 stub PropertySheetA
- 64 stub PropertySheetW
- 65 stub _TrackMouseEvent
+ 18 stub CreatePropertySheetPage
+ 19 stub CreatePropertySheetPageA
+ 20 stub CreatePropertySheetPageW
+# 21 pascal16 CreateStatusWindow(word ptr word word) CreateStatusWindow16
+ 21 stub CreateStatusWindow
+ 22 stdcall CreateStatusWindowW(long ptr long long) CreateStatusWindow32W
+ 23 stub CreateToolbarEx
+ 24 stub DestroyPropertySheetPage
+ 25 stub DllGetVersion
+ 26 stub DllInstall
+# 27 pascal16 DrawStatusText(word ptr ptr word) DrawStatusText16
+ 27 stub DrawStatusText
+ 28 stdcall DrawStatusTextW(long ptr ptr long) DrawStatusText32W
+ 29 stub FlatSB_EnableScrollBar
+ 30 stub FlatSB_GetScrollInfo
+ 31 stub FlatSB_GetScrollPos
+ 32 stub FlatSB_GetScrollProp
+ 33 stub FlatSB_GetScrollRange
+ 34 stub FlatSB_SetScrollInfo
+ 35 stub FlatSB_SetScrollPos
+ 36 stub FlatSB_SetScrollProp
+ 37 stub FlatSB_SetScrollRange
+ 38 stub FlatSB_ShowScrollBar
+ 39 stdcall ImageList_Add(ptr long long) ImageList_Add
+ 40 stub ImageList_AddIcon
+ 41 stdcall ImageList_AddMasked(ptr long long) ImageList_AddMasked
+ 42 stdcall ImageList_BeginDrag(ptr long long long) ImageList_BeginDrag
+ 43 stdcall ImageList_Copy(ptr long ptr long long) ImageList_Copy
+ 44 stdcall ImageList_Create(long long long long long) ImageList_Create
+ 45 stdcall ImageList_Destroy(ptr) ImageList_Destroy
+ 46 stdcall ImageList_DragEnter(long long long) ImageList_DragEnter
+ 47 stdcall ImageList_DragLeave(long) ImageList_DragLeave
+ 48 stdcall ImageList_DragMove(long long) ImageList_DragMove
+ 49 stdcall ImageList_DragShowNolock(long) ImageList_DragShowNolock
+ 50 stdcall ImageList_Draw(ptr long long long long long) ImageList_Draw
+ 51 stdcall ImageList_DrawEx(ptr long long long long long long long long long) ImageList_DrawEx
+ 52 stdcall ImageList_DrawIndirect(ptr) ImageList_DrawIndirect
+ 53 stdcall ImageList_Duplicate(ptr) ImageList_Duplicate
+ 54 stdcall ImageList_EndDrag() ImageList_EndDrag 
+ 55 stdcall ImageList_GetBkColor(ptr) ImageList_GetBkColor
+ 56 stdcall ImageList_GetDragImage(ptr ptr) ImageList_GetDragImage
+ 57 stdcall ImageList_GetIcon(ptr long long) ImageList_GetIcon
+ 58 stdcall ImageList_GetIconSize(ptr ptr ptr) ImageList_GetIconSize
+ 59 stdcall ImageList_GetImageCount(ptr) ImageList_GetImageCount
+ 60 stdcall ImageList_GetImageInfo(ptr long ptr) ImageList_GetImageInfo
+ 61 stdcall ImageList_GetImageRect(ptr long ptr) ImageList_GetImageRect
+ 62 stub ImageList_LoadImage
+ 63 stdcall ImageList_LoadImageA(long ptr long long long long long) ImageList_LoadImage32A
+ 64 stdcall ImageList_LoadImageW(long ptr long long long long long) ImageList_LoadImage32W
+ 65 stdcall ImageList_Merge(ptr long ptr long long long) ImageList_Merge
+ 66 stub ImageList_Read
+ 67 stdcall ImageList_Remove(ptr long) ImageList_Remove
+ 68 stdcall ImageList_Replace(ptr long long long) ImageList_Replace
+ 69 stdcall ImageList_ReplaceIcon(ptr long long) ImageList_ReplaceIcon
+ 70 stdcall ImageList_SetBkColor(ptr long) ImageList_SetBkColor
+# 71
+# 72
+# 73
+# 74 stub GetSize # 1 parameter
+ 75 stdcall ImageList_SetDragCursorImage(ptr long long long) ImageList_SetDragCursorImage
+ 76 stub ImageList_SetFilter
+ 77 stdcall ImageList_SetIconSize(ptr long long) ImageList_SetIconSize
+ 78 stdcall ImageList_SetImageCount(ptr long) ImageList_SetImageCount
+ 79 stdcall ImageList_SetOverlayImage(ptr long long) ImageList_SetOverlayImage
+ 80 stub ImageList_Write
+ 81 stub InitCommonControlsEx
+ 82 stub InitializeFlatSB
+ 83 stub PropertySheet
+ 84 stub PropertySheetA
+ 85 stub PropertySheetW
+ 86 stub UninitializeFlatSB
+ 87 stub _TrackMouseEvent
+
+#151
+#152 stub FreeMRUList  # 1 parameter
+#153
+#154
+#155 stub FindMRUStringA  # 3 parameters
+#156
+#157
+#163
+#164
+#167
+#169 stub FindMRUData
+#233 - 236
+
+#320
+#321
+#322
+#323
+#324
+#325
+#326
+#327
+#328
+#329 stub DPA_Create
+#330 stub DPA_Destroy
+#331
+#332 stub DPA_GetPtr
+#333
+#334 stub DPA_InsertPtr
+#335
+#336 stub DPA_DeletePtr
+#337
+#338
+#339 stub DPA_Search
+#340
+#341
+#342
+
+#350 stub StrChrA
+#351
+#352 stub StrCmpA
+#353
+#354 stub StrStrA
+#355
+#356
+#357 stub StrToIntA
+#358 - 369
+
+#372 - 375
+#376 stub IntlStrEqWorkerA
+#377 stub IntlStrEqWorkerW
+#382
+#383 stub DoReaderMode
+#384 - 390
+#400 - 404
+#410 - 413
diff --git a/relay32/gdi32.spec b/relay32/gdi32.spec
index 1ab4e4b..51a55ce 100644
--- a/relay32/gdi32.spec
+++ b/relay32/gdi32.spec
@@ -18,7 +18,7 @@
  14 stdcall Chord(long long long long long long long long long) Chord32
  15 stdcall CloseEnhMetaFile(long) CloseEnhMetaFile32
  16 stdcall CloseFigure(long) CloseFigure32
- 17 stub CloseMetaFile
+ 17 stdcall CloseMetaFile(long) CloseMetaFile32
  18 stub ColorMatchToTarget
  19 stdcall CombineRgn(long long long long) CombineRgn32
  20 stub CombineTransform
@@ -54,7 +54,7 @@
  48 stdcall CreateHatchBrush(long long) CreateHatchBrush32
  49 stdcall CreateICA(str str str ptr) CreateIC32A
  50 stdcall CreateICW(wstr wstr wstr ptr) CreateIC32W
- 51 stub CreateMetaFileA
+ 51 stdcall CreateMetaFileA(str) CreateMetaFile32A
  52 stub CreateMetaFileW
  53 stdcall CreatePalette(ptr) CreatePalette32
  54 stdcall CreatePatternBrush(long) CreatePatternBrush32
@@ -73,7 +73,7 @@
  66 stub DeleteColorSpace
  67 stdcall DeleteDC(long) DeleteDC32
  68 stdcall DeleteEnhMetaFile(long) DeleteEnhMetaFile32
- 69 stub DeleteMetaFile
+ 69 stdcall DeleteMetaFile(long) DeleteMetaFile32
  70 stdcall DeleteObject(long)	DeleteObject32
  71 stub DescribePixelFormat
  72 stub DeviceCapabilitiesExA
@@ -270,7 +270,7 @@
 263 stdcall PlayEnhMetaFile(long long ptr) PlayEnhMetaFile32
 264 stdcall PlayEnhMetaFileRecord(long ptr ptr long) PlayEnhMetaFileRecord32
 265 stdcall PlayMetaFile(long long) PlayMetaFile32
-266 stub PlayMetaFileRecord
+266 stdcall PlayMetaFileRecord(long ptr ptr long) PlayMetaFileRecord32
 267 stub PlgBlt
 268 stub PolyBezier
 269 stub PolyBezierTo
@@ -328,7 +328,7 @@
 320 stub SetICMProfileW
 321 stdcall SetMapMode(long long) SetMapMode32
 322 stdcall SetMapperFlags(long long) SetMapperFlags32
-323 stub SetMetaFileBitsEx
+323 stdcall SetMetaFileBitsEx(long ptr) SetMetaFileBitsEx
 324 stub SetMetaRgn
 325 stub SetMiterLimit
 326 stdcall SetPaletteEntries(long long long ptr) SetPaletteEntries32
diff --git a/relay32/kernel32.spec b/relay32/kernel32.spec
index 9e1cf92..8b0f1b3 100644
--- a/relay32/kernel32.spec
+++ b/relay32/kernel32.spec
@@ -157,8 +157,8 @@
 165 stub CreateMailslotW
 166 stdcall CreateMutexA(ptr long str) CreateMutex32A
 167 stdcall CreateMutexW(ptr long wstr) CreateMutex32W
-168 stub CreateNamedPipeA
-169 stub CreateNamedPipeW
+168 stdcall CreateNamedPipeA(str long long long long long long ptr) CreateNamedPipeA
+169 stdcall CreateNamedPipeW(wstr long long long long long long ptr) CreateNamedPipeW
 170 stub CreatePipe
 171 stdcall CreateProcessA(str str ptr ptr long long ptr str ptr ptr) CreateProcess32A
 172 stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) CreateProcess32W
diff --git a/relay32/ole32.spec b/relay32/ole32.spec
index 9fcd3b3..7350c10 100644
--- a/relay32/ole32.spec
+++ b/relay32/ole32.spec
@@ -152,7 +152,7 @@
 149 stub StgOpenStorageOnILockBytes
 150 stub StgSetTimes
 151 stdcall StringFromCLSID(ptr ptr) StringFromCLSID32
-152 stub StringFromGUID2
+152 stdcall StringFromGUID2(ptr ptr long) StringFromGUID2
 153 stub StringFromIID
 154 stub UtConvertDvtd16toDvtd32
 155 stub UtConvertDvtd32toDvtd16
diff --git a/relay32/user32.spec b/relay32/user32.spec
index ac39942..3340dd1 100644
--- a/relay32/user32.spec
+++ b/relay32/user32.spec
@@ -579,7 +579,7 @@
 574 stub VkKeyScanExA
 575 stub VkKeyScanExW
 576 stdcall VkKeyScanW(long) VkKeyScan32W
-577 stub WaitForInputIdle
+577 stdcall WaitForInputIdle(long long) WaitForInputIdle
 578 stdcall WaitMessage() WaitMessage
 579 stdcall WinHelpA(long str long long) WinHelp32A
 580 stdcall WinHelpW(long wstr long long) WinHelp32W
diff --git a/scheduler/thread.c b/scheduler/thread.c
index 3a92052..8774b83 100644
--- a/scheduler/thread.c
+++ b/scheduler/thread.c
@@ -550,7 +550,7 @@
  */
 BOOL32 WINAPI TerminateThread(HANDLE32 handle,DWORD exitcode)
 {
-    fprintf(stdnimp,"TerminateThread(0x%08x,%ld), STUB!\n",handle,exitcode);
+    FIXME(thread,"(0x%08x,%ld): STUB!\n",handle,exitcode);
     return TRUE;
 }
 
@@ -573,7 +573,7 @@
  */
 BOOL32 WINAPI ResumeThread( HANDLE32 handle )
 {
-    fprintf(stdnimp,"ResumeThread(0x%08x), STUB!\n",handle);
+    FIXME(thread,"(0x%08x): STUB!\n",handle);
     return TRUE;
 }
 
@@ -582,7 +582,7 @@
  */
 BOOL32 WINAPI SuspendThread( HANDLE32 handle )
 {
-    fprintf(stdnimp,"SuspendThread(0x%08x), STUB!\n",handle);
+    FIXME(thread,"(0x%08x): STUB!\n",handle);
     return TRUE;
 }
 
diff --git a/win32/advapi.c b/win32/advapi.c
index 50cae53..d84a2f1 100644
--- a/win32/advapi.c
+++ b/win32/advapi.c
@@ -18,10 +18,7 @@
  */
 BOOL32 WINAPI StartServiceCtrlDispatcher32A(LPSERVICE_TABLE_ENTRY32A servent)
 {
-	fprintf(stderr,"StartServiceCtrlDispatcherA(%p (%s)), STUB.\n",
-		servent,
-		servent->lpServiceName
-	);
+	FIXME(advapi,"(%p '%s'): STUB.\n",servent,servent->lpServiceName);
 	return TRUE;
 }
 
@@ -33,10 +30,7 @@
 	char	buffer[200];
 
 	lstrcpynWtoA(buffer,servent->lpServiceName,200);
-	fprintf(stderr,"StartServiceCtrlDispatcherA(%p (%s)), STUB.\n",
-		servent,
-		buffer
-	);
+	FIXME(advapi,"(%p '%s'): STUB.\n",servent,buffer);
 	return TRUE;
 }
 
@@ -47,9 +41,7 @@
 BOOL32 WINAPI OpenProcessToken(HANDLE32 process,DWORD desiredaccess,
                                HANDLE32 *thandle)
 {
-	fprintf(stdnimp,"OpenProcessToken(%08x,%08lx,%p),stub!\n",
-		process,desiredaccess,thandle
-	);
+	FIXME(advapi,"(%08x,%08lx,%p):stub!\n",process,desiredaccess,thandle);
 	return TRUE;
 }
 
@@ -59,9 +51,8 @@
 BOOL32 WINAPI OpenThreadToken( HANDLE32 thread,DWORD desiredaccess,
                                BOOL32 openasself,HANDLE32 *thandle )
 {
-	fprintf(stdnimp,"OpenThreadToken(%08x,%08lx,%d,%p),stub!\n",
-		thread,desiredaccess,openasself,thandle
-	);
+	FIXME(advapi,"(%08x,%08lx,%d,%p): stub!\n",
+	      thread,desiredaccess,openasself,thandle);
 	return TRUE;
 }
 
@@ -70,9 +61,7 @@
  */
 BOOL32 WINAPI LookupPrivilegeValue32A(LPCSTR system,LPCSTR name,LPVOID bla)
 {
-	fprintf(stdnimp,"LookupPrivilegeValue32A(%s,%s,%p),stub\n",
-		system,name,bla
-	);
+	FIXME(advapi,"(%s,%s,%p): stub\n",system,name,bla);
 	return TRUE;
 }
 
@@ -93,16 +82,15 @@
 	HANDLE32 token,/*TOKEN_INFORMATION_CLASS*/ DWORD tokeninfoclass,LPVOID tokeninfo,
 	DWORD tokeninfolength,LPDWORD retlen
 ) {
-	fprintf(stderr,"GetTokenInformation(%08x,%ld,%p,%ld,%p)\n",
-		token,tokeninfoclass,tokeninfo,tokeninfolength,retlen
-	);
+	FIXME(advapi,"(%08x,%ld,%p,%ld,%p): stub\n",
+	      token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
 	return TRUE;
 }
 
 /*SC_HANDLE*/
 DWORD WINAPI OpenSCManagerA(LPCSTR machine,LPCSTR dbname,DWORD desiredaccess)
 {
-	fprintf(stderr,"OpenSCManagerA(%s,%s,%08lx)\n",machine,dbname,desiredaccess);
+	FIXME(advapi,"(%s,%s,%08lx): stub\n",machine,dbname,desiredaccess);
 	return 0;
 }
 
@@ -110,7 +98,7 @@
 {
 	LPSTR	machineA = HEAP_strdupWtoA(GetProcessHeap(),0,machine);
 	LPSTR	dbnameA = HEAP_strdupWtoA(GetProcessHeap(),0,dbname);
-	fprintf(stderr,"OpenSCManagerW(%s,%s,%08lx)\n",machineA,dbnameA,desiredaccess);
+	FIXME(advapi,"(%s,%s,%08lx): stub\n",machineA,dbnameA,desiredaccess);
 	HeapFree(GetProcessHeap(),0,machineA);
 	HeapFree(GetProcessHeap(),0,dbnameA);
 	return 0;
diff --git a/win32/code_page.c b/win32/code_page.c
index 6ef3335..05e1ac2 100644
--- a/win32/code_page.c
+++ b/win32/code_page.c
@@ -118,10 +118,10 @@
     int eos = 0;
     int dont_copy= (dstlen==0);
     if (page!=GetACP() && page!=CP_OEMCP && page!=CP_ACP)
-	fprintf(stdnimp,"Conversion in CP %d not supported\n",page);
+	FIXME(win32,"Conversion in CP %d not supported\n",page);
 #if 0
     if (flags)
-	fprintf(stdnimp,"WideCharToMultiByte flags %lx not supported\n",flags);
+	FIXME(win32,"flags %lx not supported\n",flags);
 #endif
     if(used)
 	*used=0;
@@ -207,9 +207,7 @@
  */
 BOOL32 WINAPI EnumSystemCodePages32A(CODEPAGE_ENUMPROC32A lpfnCodePageEnum,DWORD flags)
 {
-	TRACE(win32,"(%p,%08lx)\n",
-		lpfnCodePageEnum,flags
-	);
+	TRACE(win32,"(%p,%08lx)\n",lpfnCodePageEnum,flags);
 	lpfnCodePageEnum("437");
 	return TRUE;
 }
@@ -221,8 +219,7 @@
                                       DWORD flags)
 {
     WCHAR	*cp;
-    TRACE(win32,"(%p,%08lx)\n",
-                  lpfnCodePageEnum,flags );
+    TRACE(win32,"(%p,%08lx)\n",lpfnCodePageEnum,flags );
 
     cp = HEAP_strdupAtoW( GetProcessHeap(), 0, "437" );
     lpfnCodePageEnum(cp);
diff --git a/win32/console.c b/win32/console.c
index 3bbf9f6..6c2719b 100644
--- a/win32/console.c
+++ b/win32/console.c
@@ -164,7 +164,7 @@
                                            DWORD dwFlags,
                                            LPVOID lpScreenBufferData)
 {
-	fprintf(stderr, "CreateConsoleScreenBuffer(): stub !\n");
+	FIXME(console, "(...): stub !\n");
 	return INVALID_HANDLE_VALUE32;
 }
 
@@ -193,7 +193,7 @@
  */
 BOOL32 WINAPI SetConsoleActiveScreenBuffer(HANDLE32 hConsoleOutput)
 {
-	fprintf(stderr, "SetConsoleActiveScreenBuffer(): stub !\n");
+	FIXME(console, "(%x): stub!\n", hConsoleOutput);
 	return 0;
 }
 
@@ -294,7 +294,7 @@
 		tcsetattr(*slave, TCSADRAIN, &term);
 		sprintf(buf, "-Sxx%d", *master);
 		execlp("xterm", "xterm", buf, NULL);
-		fprintf(stderr, "error creating AllocConsole xterm\n");
+		ERR(console, "error creating AllocConsole xterm\n");
 		exit(1);
 	}
 
@@ -310,7 +310,7 @@
 			usleep(100);
 		}
 		if (i > 10000) {
-			fprintf(stderr, "can't read xterm WID\n");
+			WARN(console, "can't read xterm WID\n");
 			kill(*pid, SIGKILL);
 			return FALSE;
 		}
@@ -461,11 +461,11 @@
 }
 
 /***********************************************************************
- *            SetConsoleMode   (KERNEL32.188)
+ *            SetConsoleMode   (KERNEL32.628)
  */
 BOOL32 WINAPI SetConsoleMode(HANDLE32 hcon,DWORD mode)
 {
-	fprintf(stdnimp,"SetConsoleMode(%08x,%08lx)\n",hcon,mode);
+	FIXME(console,"(%08x,%08lx): stub\n",hcon,mode);
 	return TRUE;
 }
 
@@ -477,7 +477,7 @@
 	PDB32 *pdb = PROCESS_Current();
 	CONSOLE *console= (CONSOLE *)pdb->console;
 
-	if(console->title) 
+	if(console && console->title) 
 	  {
 	    lstrcpyn32A(title,console->title,size);
 	    return strlen(title);
@@ -492,7 +492,7 @@
 {
 	PDB32 *pdb = PROCESS_Current();
 	CONSOLE *console= (CONSOLE *)pdb->console;
-	if(console->title) 
+	if(console && console->title) 
 	  {
 	    lstrcpynAtoW(title,console->title,size);
 	    return (lstrlen32W(title));
@@ -663,7 +663,7 @@
  */
 BOOL32 WINAPI FlushConsoleInputBuffer(HANDLE32 hConsoleInput)
 {
-    fprintf(stderr,"FlushConsoleInputBuffer(%d)\n",hConsoleInput);
+    FIXME(console,"(%d): stub\n",hConsoleInput);
     return TRUE;
 }
 
@@ -695,7 +695,7 @@
 BOOL32 WINAPI GetNumberOfConsoleMouseButtons(LPDWORD nrofbuttons)
 {
     *nrofbuttons = 2;
-    fprintf(stderr,"GetNumberOfConsoleMouseButtons: STUB returning 2\n");
+    FIXME(console,"(%p): STUB returning 2\n", nrofbuttons);
     return TRUE;
 }
 
@@ -710,7 +710,7 @@
     pirBuffer = NULL;
     cInRecords = 0;
     *lpcRead = 0;
-    fprintf(stderr,"PeekConsoleInput32A: STUB returning TRUE\n");
+    FIXME(console,"(...): STUB returning TRUE\n");
 	return TRUE;
 }
 
@@ -725,7 +725,7 @@
     pirBuffer = NULL;
     cInRecords = 0;
     *lpcRead = 0;
-    fprintf(stderr,"PeekConsoleInput32W: STUB returning TRUE\n");
+    FIXME(console,"(...): STUB returning TRUE\n");
     return TRUE;
 }
 
@@ -736,7 +736,7 @@
 {
   cinfo[0] = 10; /* 10% of character box is cursor.  */
   cinfo[1] = TRUE;  /* Cursor is visible.  */
-  fprintf (stdnimp, "GetConsoleCursorInfo32 -- STUB!\n");
+  FIXME(console, "(%x,%p): STUB!\n", hcon, cinfo);
   return TRUE;
 }
 
@@ -745,7 +745,7 @@
  */
 BOOL32 WINAPI SetConsoleCursorInfo32(HANDLE32 hcon, LPDWORD cinfo)
 {
-  fprintf (stdnimp, "SetConsoleCursorInfo32 -- STUB!\n");
+  FIXME(console, "(%#x,%p): STUB!\n", hcon, cinfo);
   return TRUE;
 }
 
@@ -754,7 +754,7 @@
  */
 BOOL32 WINAPI SetConsoleWindowInfo32(HANDLE32 hcon, BOOL32 flag, LPSMALL_RECT window)
 {
-  fprintf (stdnimp, "SetConsoleWindowInfo32-- STUB!\n");
+  FIXME(console, "(%x,%d,%p): STUB!\n", hcon, flag, window);
   return TRUE;
 }
 
@@ -763,7 +763,7 @@
  */
 BOOL32 WINAPI SetConsoleTextAttribute32(HANDLE32 hcon, DWORD attributes)
 {
-  fprintf (stdnimp, "SetConsoleTextAttribute32-- STUB!\n");
+  FIXME(console, "(%#x,%#lx): STUB!\n", hcon, attributes);
   return TRUE;
 }
 
diff --git a/win32/file.c b/win32/file.c
index 86a953e..03dfa3e 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -74,7 +74,7 @@
 /***********************************************************************
  *              ReadFileEx                (KERNEL32.)
  */
-typedef /* from winbase.h */
+typedef
 VOID
 (WINAPI *LPOVERLAPPED_COMPLETION_ROUTINE)(
     DWORD dwErrorCode,
@@ -87,8 +87,8 @@
 			 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 {
 
-    fprintf(stdnimp,"ReadFileEx file %d to buf %p num %ld %p func %p stub\n",
-	    hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
+    FIXME(file, "file %d to buf %p num %ld %p func %p stub\n",
+	  hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
     return 0;
 }
@@ -229,8 +229,8 @@
     if (attributes & FILE_ATTRIBUTE_NORMAL) {
       attributes &= ~FILE_ATTRIBUTE_NORMAL;
       if (attributes)
-        fprintf(stdnimp,"SetFileAttributesA(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
-		lpFileName,attributes);
+        FIXME(file,"(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
+	      lpFileName,attributes);
     }
     if(stat(full_name.long_name,&buf)==-1)
     {
@@ -244,7 +244,8 @@
     }
     attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
     if (attributes)
-        fprintf(stdnimp,"SetFileAttributesA(%s):%lx attribute(s) not implemented.\n",lpFileName,attributes);
+        FIXME(file,"(%s):%lx attribute(s) not implemented.\n",
+	      lpFileName,attributes);
     if (-1==chmod(full_name.long_name,buf.st_mode))
     {
         SetLastError(ErrnoToLastError(errno));
@@ -271,7 +272,7 @@
  */
 VOID WINAPI SetFileApisToOEM(void)
 {
-    /*fprintf(stdnimp,"SetFileApisToOEM(),stub!\n");*/
+  /*FIXME(file,"(): stub!\n");*/
 }
 
 
@@ -280,7 +281,7 @@
  */
 VOID WINAPI SetFileApisToANSI(void)
 {
-    /*fprintf(stdnimp,"SetFileApisToANSI(),stub!\n");*/
+    /*FIXME(file,"(): stub!\n");*/
 }
 
 
@@ -289,7 +290,7 @@
  */
 BOOL32 WINAPI AreFileApisANSI(void)
 {
-    fprintf(stdnimp,"AreFileApisANSI(),stub!\n");
+    FIXME(file,"(): stub!\n");
     return TRUE;
 }
 
diff --git a/win32/kernel32.c b/win32/kernel32.c
index 7eecb23..beabee6 100644
--- a/win32/kernel32.c
+++ b/win32/kernel32.c
@@ -50,20 +50,27 @@
 /***********************************************************************
  *			FT_PrologPrime			(KERNEL32.89)
  */
-void WINAPI FT_PrologPrime(DWORD startind,LPBYTE thunk) {
+void WINAPI FT_PrologPrime(
+	DWORD startind,		/* [in] start of thunktable */
+	LPBYTE thunk		/* [in] thunk codestart */
+) {
 	_write_ftprolog(thunk,*(DWORD*)(startind+thunk));
 }
 
 /***********************************************************************
+ *	_write_qtthunk					(internal)
  * Generates a QT_Thunk style call.
- *	
+ *
  *  33C9                    xor ecx, ecx
  *  8A4DFC                  mov cl , [ebp-04]
  *  8B148Dxxxxxxxx          mov edx, [4*ecx + (EAX+EDX)]
  *  B8yyyyyyyy              mov eax, QT_Thunk
  *  FFE0                    jmp eax
  */
-static void _write_qtthunk(LPBYTE start,DWORD thunkstart) {
+static void _write_qtthunk(
+	LPBYTE start,		/* [in] start of QT_Thunk stub */
+	DWORD thunkstart	/* [in] start of thunk (for index lookup) */
+) {
 	LPBYTE	x;
 
 	x	= start;
@@ -77,10 +84,6 @@
 	/* should fill the rest of the 32 bytes with 0xCC */
 }
 
-/***********************************************************************
- *		ThunkConnect32		(KERNEL32)
- * Connects a 32bit and a 16bit thunkbuffer.
- */
 struct thunkstruct
 {
 	char	magic[4];
@@ -95,10 +98,18 @@
 	DWORD	x20;
 };
 
-UINT32 WINAPI ThunkConnect32( struct thunkstruct *ths, LPSTR thunkfun16,
-                              LPSTR module16, LPSTR module32, HMODULE32 hmod32,
-                              DWORD dllinitarg1 )
-{
+/***********************************************************************
+ *		ThunkConnect32		(KERNEL32)
+ * Connects a 32bit and a 16bit thunkbuffer.
+ */
+UINT32 WINAPI ThunkConnect32( 
+	struct thunkstruct *ths,	/* [in/out] thunkbuffer */
+	LPCSTR thunkfun16,		/* [in] win16 thunkfunction */
+	LPCSTR module16,		/* [in] name of win16 dll */
+	LPCSTR module32,		/* [in] name of win32 dll */
+	HMODULE32 hmod32,		/* [in] hmodule of win32 dll (used?) */
+	DWORD dllinitarg1		/* [in] initialisation argument */
+) {
 	HINSTANCE16	hmm;
 	SEGPTR		thkbuf;
 	struct	thunkstruct	*ths16;
@@ -183,9 +194,14 @@
 
 /**********************************************************************
  *           WOWCallback16 (KERNEL32.62)(WOW32.2)
+ * Calls a win16 function with a single DWORD argument.
+ * RETURNS
+ *	the return value
  */
-DWORD WINAPI WOWCallback16(FARPROC16 fproc,DWORD arg)
-{
+DWORD WINAPI WOWCallback16(
+	FARPROC16 fproc,	/* [in] win16 function to call */
+	DWORD arg		/* [in] single DWORD argument to function */
+) {
 	DWORD	ret;
 	TRACE(thunk,"(%p,0x%08lx)...\n",fproc,arg);
 	ret =  Callbacks->CallWOWCallbackProc(fproc,arg);
@@ -195,10 +211,16 @@
 
 /**********************************************************************
  *           WOWCallback16Ex (KERNEL32.55)(WOW32.3)
+ * Calls a function in 16bit code.
+ * RETURNS
+ *	TRUE for success
  */
 BOOL32 WINAPI WOWCallback16Ex(
-	FARPROC16 vpfn16,DWORD dwFlags,DWORD cbArgs,LPVOID pArgs,
-	LPDWORD pdwRetCode
+	FARPROC16 vpfn16,	/* [in] win16 function to call */
+	DWORD dwFlags,		/* [in] flags */
+	DWORD cbArgs,		/* [in] nr of arguments */
+	LPVOID pArgs,		/* [in] pointer to arguments (LPDWORD) */
+	LPDWORD pdwRetCode	/* [out] return value of win16 function */
 ) {
 	return Callbacks->CallWOWCallback16Ex(vpfn16,dwFlags,cbArgs,pArgs,pdwRetCode);
 }
@@ -229,10 +251,16 @@
  * The pointer ptr is written into the first DWORD of 'thunk'.
  * (probably correct implemented)
  * [ok probably]
+ * RETURNS
+ *	segmented pointer to thunk?
  */
-DWORD WINAPI _KERNEL32_43(LPDWORD thunk,LPCSTR thkbuf,DWORD len,
-                           LPCSTR dll16,LPCSTR dll32)
-{
+DWORD WINAPI _KERNEL32_43(
+	LPDWORD thunk,	/* [in] win32 thunk */
+	LPCSTR thkbuf,	/* [in] thkbuffer name in win16 dll */
+	DWORD len,	/* [in] thkbuffer length */
+	LPCSTR dll16,	/* [in] name of win16 dll */
+	LPCSTR dll32	/* [in] name of win32 dll (FIXME: not used?) */
+) {
 	HINSTANCE16	hmod;
 	LPDWORD		addr;
 	SEGPTR		segaddr;
@@ -270,7 +298,7 @@
  * uses 0x66 lret, and that we have to pass CX in DI.
  * (there seems to be some kind of BL/BX return magic too...)
  *
- * [doesn't crash anymore]
+ * [crashes]
  */
 VOID WINAPI _KERNEL32_45(CONTEXT *context)
 {
@@ -303,7 +331,7 @@
 /***********************************************************************
  * 		_KERNEL32_40 	(KERNEL32.40)
  * YET Another 32->16 thunk, the difference to the others is still mysterious
- * target address is EDX
+ * Target address is in EDX.
  *
  * [crashes]
  */
@@ -370,11 +398,16 @@
  *	04: SEGPTR	ptr		? where does it point to?
  * The segpointer ptr is written into the first DWORD of 'thunk'.
  * [ok probably]
+ * RETURNS
+ *	unclear, pointer to win16 thkbuffer?
  */
-
-LPVOID WINAPI _KERNEL32_41(LPBYTE thunk,LPCSTR thkbuf,DWORD len,LPCSTR dll16,
-                           LPCSTR dll32)
-{
+LPVOID WINAPI _KERNEL32_41(
+	LPBYTE thunk,	/* [in] win32 thunk */
+	LPCSTR thkbuf,	/* [in] thkbuffer name in win16 dll */
+	DWORD len,	/* [in] length of thkbuffer */
+	LPCSTR dll16,	/* [in] name of win16 dll */
+	LPCSTR dll32	/* [in] name of win32 dll */
+) {
 	HMODULE32	hkrnl32 = GetModuleHandle32A("KERNEL32");
 	HMODULE16	hmod;
 	LPDWORD		addr,addr2;
@@ -388,18 +421,18 @@
 	
 	hmod = LoadLibrary16(dll16);
 	if (hmod<32) {
-		WARN(thunk,"failed to load 16bit DLL %s, error %d\n",
+		ERR(thunk,"failed to load 16bit DLL %s, error %d\n",
 			     dll16,hmod);
 		return NULL;
 	}
 	segaddr = (DWORD)WIN32_GetProcAddress16(hmod,(LPSTR)thkbuf);
 	if (!segaddr) {
-		WARN(thunk,"no %s exported from %s!\n",thkbuf,dll16);
+		ERR(thunk,"no %s exported from %s!\n",thkbuf,dll16);
 		return NULL;
 	}
 	addr = (LPDWORD)PTR_SEG_TO_LIN(segaddr);
 	if (addr[0] != len) {
-		WARN(thunk,"thkbuf length mismatch? %ld vs %ld\n",len,addr[0]);
+		ERR(thunk,"thkbuf length mismatch? %ld vs %ld\n",len,addr[0]);
 		return NULL;
 	}
 	addr2 = PTR_SEG_TO_LIN(addr[1]);
@@ -440,26 +473,30 @@
  *	04: SEGPTR	address for thunkbuffer pointer
  * [ok probably]
  */
-VOID WINAPI _KERNEL32_46(LPBYTE thunk,LPSTR thkbuf,DWORD len,LPSTR dll16,
-                         LPSTR dll32)
-{
+VOID WINAPI _KERNEL32_46(
+	LPBYTE thunk,		/* [in] start of thunkbuffer */
+	LPCSTR thkbuf,		/* [in] name/ordinal of thunkbuffer in win16 dll */
+	DWORD len,		/* [in] length of thunkbuffer */
+	LPCSTR dll16,		/* [in] name of win16 dll containing the thkbuf */
+	LPCSTR dll32		/* [in] win32 dll. FIXME: strange, unused */
+) {
 	LPDWORD		addr;
 	HMODULE16	hmod;
 	SEGPTR		segaddr;
 
 	hmod = LoadLibrary16(dll16);
 	if (hmod < 32) {
-		WARN(thunk,"couldn't load %s, error %d\n",dll16,hmod);
+		ERR(thunk,"couldn't load %s, error %d\n",dll16,hmod);
 		return;
 	}
 	segaddr = (SEGPTR)WIN32_GetProcAddress16(hmod,thkbuf);
 	if (!segaddr) {
-		WARN(thunk,"haven't found %s in %s!\n",thkbuf,dll16);
+		ERR(thunk,"haven't found %s in %s!\n",thkbuf,dll16);
 		return;
 	}
 	addr = (LPDWORD)PTR_SEG_TO_LIN(segaddr);
 	if (addr[0] != len) {
-	        WARN(thunk,"length of thkbuf differs from expected length! "
+	        ERR(thunk,"length of thkbuf differs from expected length! "
 			     "(%ld vs %ld)\n",addr[0],len);
 		return;
 	}
@@ -475,6 +512,8 @@
  * Check if thunking is initialized (ss selector set up etc.)
  * We do that differently, so just return TRUE.
  * [ok]
+ * RETURNS
+ *	TRUE for success.
  */
 BOOL32 WINAPI _KERNEL32_87()
 {
@@ -490,8 +529,12 @@
  * And YES, I've seen nr=48 (somewhere in the Win95 32<->16 OLE coupling)
  * [ok]
  */
-DWORD WINAPIV _KERNEL32_88( DWORD nr, DWORD flags, FARPROC32 fun, ... )
-{
+DWORD WINAPIV _KERNEL32_88(
+	DWORD nr,	/* [in] number of argument bytes */
+	DWORD flags,	/* [in] FIXME: flags ? */
+	FARPROC32 fun,	/* [in] function to call */
+	...		/* [in/out] arguments */
+) {
     DWORD i,ret;
     DWORD *args = ((DWORD *)&fun) + 1;
 
@@ -578,9 +621,14 @@
  * returns the startaddress of this thunk.
  *
  * Note, that they look very similair to the ones allocates by THUNK_Alloc.
+ * RETURNS
+ *	segmented pointer to the start of the thunk
  */
 DWORD WINAPI
-AllocSLCallback(DWORD finalizer,DWORD callback) {
+AllocSLCallback(
+	DWORD finalizer,	/* [in] finalizer function */
+	DWORD callback		/* [in] callback function */
+) {
 	LPBYTE	x,thunk = HeapAlloc( GetProcessHeap(), 0, 32 );
 	WORD	sel;
 
@@ -596,8 +644,14 @@
 	return (sel<<16)|0;
 }
 
+/**********************************************************************
+ * 		FreeSLCallback		(KERNEL32.274)
+ * Frees the specified 16->32 callback
+ */
 void WINAPI
-FreeSLCallback(DWORD x) {
+FreeSLCallback(
+	DWORD x	/* [in] 16 bit callback (segmented pointer?) */
+) {
 	fprintf(stderr,"FreeSLCallback(0x%08lx)\n",x);
 }
 
@@ -605,6 +659,8 @@
  * 		KERNEL_358		(KERNEL)
  * Allocates a code segment which starts at the address passed in x. limit
  * 0xfffff, and returns the pointer to the start.
+ * RETURNS
+ *	a segmented pointer 
  */
 DWORD WINAPI
 _KERNEL_358(DWORD x) {
@@ -624,7 +680,9 @@
  * been allocated by _KERNEL_358).
  */
 VOID WINAPI
-_KERNEL_359(DWORD x) {
+_KERNEL_359(
+	DWORD x	/* [in] segmented pointer? */
+) {
 	fprintf(stderr,"_KERNEL_359(0x%08lx),stub\n",x);
 	if ((HIWORD(x) & 7)!=7)
 		return;
@@ -633,8 +691,9 @@
 }
 
 /**********************************************************************
- * 		KERNEL_471		(KERNEL)
- * Seems to return the uncrypted current process pointer. [Not 100% sure].
+ * 		KERNEL_471		(KERNEL.471)
+ * RETURNS
+ * 	Seems to return the uncrypted current process pointer. [Not 100% sure].
  */
 LPVOID WINAPI
 _KERNEL_471() {
@@ -642,8 +701,10 @@
 }
 
 /**********************************************************************
- * 		KERNEL_472		(KERNEL)
+ * 		KERNEL_472		(KERNEL.472)
  * something like GetCurrenthInstance.
+ * RETURNS
+ *	the hInstance
  */
 VOID WINAPI
 _KERNEL_472(CONTEXT *context) {
@@ -660,17 +721,27 @@
 
 /**********************************************************************
  * 		KERNEL_431		(KERNEL.431)
- * IsPeFile
+ *		IsPeFormat		(W32SYS.2)
+ * Checks the passed filename if it is a PE format executeable
+ * RETURNS
+ *  TRUE, if it is.
+ *  FALSE if not.
  */
-BOOL16 WINAPI KERNEL_431(LPSTR fn,WORD x) {
+BOOL16 WINAPI IsPeFormat(
+	LPSTR	fn,	/* [in] filename to executeable */
+	HFILE16 hf16	/* [in] open file, if filename is NULL */
+) {
 	IMAGE_DOS_HEADER	mzh;
-	HFILE32			hf;
+	HFILE32			hf=hf16;
 	OFSTRUCT		ofs;
 	DWORD			xmagic;
 
-	hf = OpenFile32(fn,&ofs,OF_READ);
-	if (hf==HFILE_ERROR32)
-		return FALSE;
+	if (fn) {
+		hf = OpenFile32(fn,&ofs,OF_READ);
+		if (hf==HFILE_ERROR32)
+			return FALSE;
+	}
+	_llseek32(hf,0,SEEK_SET);
 	if (sizeof(mzh)!=_lread32(hf,&mzh,sizeof(mzh))) {
 		_lclose32(hf);
 		return FALSE;
@@ -689,7 +760,61 @@
 	return (xmagic == IMAGE_NT_SIGNATURE);
 }
 
-HANDLE32 WINAPI WOWHandle32(WORD handle,WOW_HANDLE_TYPE type) {
+/***********************************************************************
+ *           WOWHandle32			(KERNEL32.57)(WOW32.16)
+ * Converts a win16 handle of type into the respective win32 handle.
+ * We currently just return this handle, since most handles are the same
+ * for win16 and win32.
+ * RETURNS
+ *	The new handle
+ */
+HANDLE32 WINAPI WOWHandle32(
+	WORD handle,		/* [in] win16 handle */
+	WOW_HANDLE_TYPE type	/* [in] handle type */
+) {
 	fprintf(stderr,"WOWHandle32(0x%04x,%d)\n",handle,type);
 	return (HANDLE32)handle;
 }
+
+/***********************************************************************
+ *           FUNC004				(KERNEL.631)
+ * A 16->32 thunk setup function.
+ * Gets called from a thunkbuffer (value of EAX). It overwrites the start
+ * with a jmp to a kernel32 function. The kernel32 function gets passed EDX.
+ * (and possibly CX).
+ */
+void WINAPI FUNC004(
+	CONTEXT *context	/* [in/out] register context from 1632-relay */
+) {
+
+	FIXME(reg,",STUB (edx is 0x%08lx, eax is 0x%08lx,edx[0x10] is 0x%08lx)!\n",
+		EDX_reg(context),
+		EAX_reg(context),
+		((DWORD*)PTR_SEG_TO_LIN(EDX_reg(context)))[0x10/4]
+	);
+
+#if 0
+{
+	LPBYTE	x,target = (LPBYTE)PTR_SEG_TO_LIN(EAX_reg(context));
+	WORD	ds,cs;
+
+	GET_DS(ds);
+	GET_CS(cs);
+/* Won't work anyway since we don't know the function called in KERNEL32 -Marcus*/
+	x = target;
+	*x++= 0xb8; *(WORD*)x= ds;x+=2;		/* mov ax,KERNEL32_DS */
+	*x++= 0x8e; *x++ = 0xc0; 		/* mov es,ax */
+	*x++= 0x66; *x++ = 0xba; *(DWORD*)x=EDX_reg(context);x+=4;
+						/* mov edx, $EDX */
+	*x++= 0x66; *x++ = 0xea;	/* jmp KERNEL32_CS:kernel32fun */
+		*(DWORD*)x=0;x+=4;/* FIXME: _what_ function does it call? */
+		*(WORD*)x=cs;x+=2;
+					
+
+	IP_reg(context) = LOWORD(EAX_reg(context));
+	CS_reg(context) = HIWORD(EAX_reg(context));
+}
+#endif
+	return;
+}
+
diff --git a/win32/newfns.c b/win32/newfns.c
index fd3e646..adedb07 100644
--- a/win32/newfns.c
+++ b/win32/newfns.c
@@ -26,7 +26,7 @@
                       /*FARPROC*/ LPVOID pfnUT32CallBack,
                       LPVOID lpBuff)
 {
-    fprintf(stdnimp, "UTRegister Stub called!\n");
+    fprintf(stderr, "UTRegister(%#x,...): stub!\n",hModule);
     return TRUE;
 }
 
@@ -35,7 +35,7 @@
  */
 BOOL32 WINAPI UTUnRegister(HMODULE32 hModule)
 {
-    fprintf(stdnimp, "UTUnRegister Stub called!\n");
+    fprintf(stderr, "UTUnRegister(%#x: stub!\n", hModule);
     return TRUE;
 }
 
@@ -54,14 +54,13 @@
 }
 
 HANDLE32 WINAPI FindFirstChangeNotification32A(LPCSTR lpPathName,BOOL32 bWatchSubtree,DWORD dwNotifyFilter) {
-	fprintf(stderr,"FindFirstChangeNotification(%s,%d,%08lx),stub\n",
-		lpPathName,bWatchSubtree,dwNotifyFilter
-	);
+	FIXME(file,"(%s,%d,%08lx): stub\n",
+	      lpPathName,bWatchSubtree,dwNotifyFilter);
 	return 0xcafebabe;
 }
 
 BOOL32 WINAPI FindNextChangeNotification(HANDLE32 fcnhandle) {
-	fprintf(stderr,"FindNextChangeNotification(%08x),stub!\n",fcnhandle);
+	FIXME(file,"(%08x): stub!\n",fcnhandle);
 	return FALSE;
 }
 
@@ -85,7 +84,7 @@
 			      LPOVERLAPPED lpoPverlapped)
 {
 
-        fprintf(stdnimp, "DeviceIoControl Stub called!\n");
+        FIXME(comm, "(...): stub!\n");
 	/* FIXME: Set appropriate error */
 	return FALSE;
 
@@ -95,6 +94,40 @@
  *		FlushInstructionCache (KERNEL32.261)
  */
 BOOL32 WINAPI FlushInstructionCache(DWORD x,DWORD y,DWORD z) {
-	fprintf(stderr,"FlushInstructionCache(0x%08lx,0x%08lx,0x%08lx)\n",x,y,z);
+	FIXME(debug,"(0x%08lx,0x%08lx,0x%08lx): stub\n",x,y,z);
 	return TRUE;
 }
+
+/***********************************************************************
+ *           CreateNamedPipeA   (KERNEL32.168)
+ */
+HANDLE32 WINAPI CreateNamedPipeA (LPCSTR lpName, DWORD dwOpenMode,
+				  DWORD dwPipeMode, DWORD nMaxInstances,
+				  DWORD nOutBufferSize, DWORD nInBufferSize,
+				  DWORD nDafaultTimeOut,
+				  LPSECURITY_ATTRIBUTES lpSecurityAttributes)
+{
+  FIXME (win32, "CreateNamedPipeA: stub\n");
+  /* if (nMaxInstances > PIPE_UNLIMITED_INSTANCES) {
+    SetLastError (ERROR_INVALID_PARAMETER);
+    return INVALID_HANDLE_VALUE;
+  } */
+
+  SetLastError (ERROR_UNKNOWN);
+  return INVALID_HANDLE_VALUE32;
+}
+
+/***********************************************************************
+ *           CreateNamedPipeW   (KERNEL32.169)
+ */
+HANDLE32 WINAPI CreateNamedPipeW (LPCWSTR lpName, DWORD dwOpenMode,
+				  DWORD dwPipeMode, DWORD nMaxInstances,
+				  DWORD nOutBufferSize, DWORD nInBufferSize,
+				  DWORD nDafaultTimeOut,
+				  LPSECURITY_ATTRIBUTES lpSecurityAttributes)
+{
+  FIXME (win32, "CreateNamedPipeW: stub\n");
+
+  SetLastError (ERROR_UNKNOWN);
+  return INVALID_HANDLE_VALUE32;
+}
diff --git a/win32/security.c b/win32/security.c
index 91fc6c0..acfec87 100644
--- a/win32/security.c
+++ b/win32/security.c
@@ -125,7 +125,7 @@
 BOOL32 WINAPI InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr,
                                             DWORD revision )
 {
-    fprintf( stdnimp, "InitializeSecurityDescriptor: empty stub\n" );
+    FIXME(security, "(%p,%#lx): empty stub\n", pDescr, revision);
     return TRUE;
 }
 
@@ -208,8 +208,8 @@
 				  LPCSTR domain, LPDWORD domainSize,
 				  PSID_NAME_USE name_use)
 {
-	fprintf(stdnimp,"LookupAccountSid32A(%s,%p,%p,%p,%p,%p,%p),stub\n",
-		system,sid,account,accountSize,domain,domainSize,name_use);
+	FIXME(security,"(%s,%p,%p,%p,%p,%p,%p): stub\n",
+	      system,sid,account,accountSize,domain,domainSize,name_use);
 	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
 	return FALSE;
 }
@@ -222,8 +222,8 @@
 				  LPCWSTR domain, LPDWORD domainSize,
 				  PSID_NAME_USE name_use)
 {
-	fprintf(stdnimp,"LookupAccountSid32W(%p,%p,%p,%p,%p,%p,%p),stub\n",
-		system,sid,account,accountSize,domain,domainSize,name_use);
+	FIXME(security,"(%p,%p,%p,%p,%p,%p,%p): stub\n",
+	      system,sid,account,accountSize,domain,domainSize,name_use);
 	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
 	return FALSE;
 }
diff --git a/windows/caret.c b/windows/caret.c
index e06e304..2f32db7 100644
--- a/windows/caret.c
+++ b/windows/caret.c
@@ -131,7 +131,7 @@
 }
 
 /*****************************************************************
- *           CreateCaret32   (USER32.65)
+ *           CreateCaret32   (USER32.66)
  */
 BOOL32 WINAPI CreateCaret32( HWND32 hwnd, HBITMAP32 bitmap,
                              INT32 width, INT32 height )
@@ -182,7 +182,7 @@
 
 
 /*****************************************************************
- *           DestroyCaret32   (USER32.130)
+ *           DestroyCaret32   (USER32.131)
  */
 BOOL32 WINAPI DestroyCaret32(void)
 {
@@ -209,7 +209,7 @@
 
 
 /*****************************************************************
- *           SetCaretPos32   (USER32.465)
+ *           SetCaretPos32   (USER32.466)
  */
 BOOL32 WINAPI SetCaretPos32( INT32 x, INT32 y)
 {
@@ -241,7 +241,7 @@
 
 
 /*****************************************************************
- *           HideCaret32   (USER32.316)
+ *           HideCaret32   (USER32.317)
  */
 BOOL32 WINAPI HideCaret32( HWND32 hwnd )
 {
@@ -268,7 +268,7 @@
 
 
 /*****************************************************************
- *           ShowCaret32   (USER32.528)
+ *           ShowCaret32   (USER32.529)
  */
 BOOL32 WINAPI ShowCaret32( HWND32 hwnd )
 {
@@ -300,7 +300,7 @@
 }
 
 /*****************************************************************
- *           SetCaretBlinkTime32   (USER32.464)
+ *           SetCaretBlinkTime32   (USER32.465)
  */
 BOOL32 WINAPI SetCaretBlinkTime32( UINT32 msecs )
 {
@@ -325,7 +325,7 @@
 
 
 /*****************************************************************
- *           GetCaretBlinkTime32   (USER32.208)
+ *           GetCaretBlinkTime32   (USER32.209)
  */
 UINT32 WINAPI GetCaretBlinkTime32(void)
 {
@@ -348,7 +348,7 @@
 
 
 /*****************************************************************
- *           GetCaretPos32   (USER32.209)
+ *           GetCaretPos32   (USER32.210)
  */
 BOOL32 WINAPI GetCaretPos32( LPPOINT32 pt )
 {
diff --git a/windows/class.c b/windows/class.c
index dbf9154..fa5504e 100644
--- a/windows/class.c
+++ b/windows/class.c
@@ -337,7 +337,7 @@
 
 
 /***********************************************************************
- *           RegisterClass32A      (USER32.426)
+ *           RegisterClass32A      (USER32.427)
  * RETURNS
  *	>0: Unique identifier
  *	0: Failure
@@ -375,7 +375,7 @@
 
 
 /***********************************************************************
- *           RegisterClass32W      (USER32.429)
+ *           RegisterClass32W      (USER32.430)
  */
 ATOM WINAPI RegisterClass32W( const WNDCLASS32W* wc )
 {
@@ -441,7 +441,7 @@
 
 
 /***********************************************************************
- *           RegisterClassEx32A      (USER32.427)
+ *           RegisterClassEx32A      (USER32.428)
  */
 ATOM WINAPI RegisterClassEx32A( const WNDCLASSEX32A* wc )
 {
@@ -473,7 +473,7 @@
 
 
 /***********************************************************************
- *           RegisterClassEx32W      (USER32.428)
+ *           RegisterClassEx32W      (USER32.429)
  */
 ATOM WINAPI RegisterClassEx32W( const WNDCLASSEX32W* wc )
 {
@@ -521,7 +521,7 @@
 
 
 /***********************************************************************
- *           UnregisterClass32A    (USER32.562)
+ *           UnregisterClass32A    (USER32.563)
  */
 BOOL32 WINAPI UnregisterClass32A( LPCSTR className, HINSTANCE32 hInstance )
 {
@@ -536,7 +536,7 @@
 
 
 /***********************************************************************
- *           UnregisterClass32W    (USER32.563)
+ *           UnregisterClass32W    (USER32.564)
  */
 BOOL32 WINAPI UnregisterClass32W( LPCWSTR className, HINSTANCE32 hInstance )
 {
@@ -560,7 +560,7 @@
 
 
 /***********************************************************************
- *           GetClassWord32    (USER32.218)
+ *           GetClassWord32    (USER32.219)
  */
 WORD WINAPI GetClassWord32( HWND32 hwnd, INT32 offset )
 {
@@ -613,7 +613,7 @@
 
 
 /***********************************************************************
- *           GetClassLong32A    (USER32.214)
+ *           GetClassLong32A    (USER32.215)
  */
 LONG WINAPI GetClassLong32A( HWND32 hwnd, INT32 offset )
 {
@@ -647,7 +647,7 @@
 
 
 /***********************************************************************
- *           GetClassLong32W    (USER32.215)
+ *           GetClassLong32W    (USER32.216)
  */
 LONG WINAPI GetClassLong32W( HWND32 hwnd, INT32 offset )
 {
@@ -677,7 +677,7 @@
 
 
 /***********************************************************************
- *           SetClassWord32    (USER32.468)
+ *           SetClassWord32    (USER32.469)
  */
 WORD WINAPI SetClassWord32( HWND32 hwnd, INT32 offset, WORD newval )
 {
@@ -745,7 +745,7 @@
 
 
 /***********************************************************************
- *           SetClassLong32A    (USER32.466)
+ *           SetClassLong32A    (USER32.467)
  */
 LONG WINAPI SetClassLong32A( HWND32 hwnd, INT32 offset, LONG newval )
 {
@@ -797,7 +797,7 @@
 
 
 /***********************************************************************
- *           SetClassLong32W    (USER32.467)
+ *           SetClassLong32W    (USER32.468)
  */
 LONG WINAPI SetClassLong32W( HWND32 hwnd, INT32 offset, LONG newval )
 {
@@ -834,7 +834,7 @@
 
 
 /***********************************************************************
- *           GetClassName32A      (USER32.216)
+ *           GetClassName32A      (USER32.217)
  */
 INT32 WINAPI GetClassName32A( HWND32 hwnd, LPSTR buffer, INT32 count )
 {
@@ -845,7 +845,7 @@
 
 
 /***********************************************************************
- *           GetClassName32W      (USER32.217)
+ *           GetClassName32W      (USER32.218)
  */
 INT32 WINAPI GetClassName32W( HWND32 hwnd, LPWSTR buffer, INT32 count )
 {
@@ -888,7 +888,7 @@
 
 
 /***********************************************************************
- *           GetClassInfo32A      (USER32.210)
+ *           GetClassInfo32A      (USER32.211)
  */
 BOOL32 WINAPI GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name,
                                WNDCLASS32A *wc )
@@ -917,7 +917,7 @@
 
 
 /***********************************************************************
- *           GetClassInfo32W      (USER32.213)
+ *           GetClassInfo32W      (USER32.214)
  */
 BOOL32 WINAPI GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name,
                                WNDCLASS32W *wc )
@@ -979,7 +979,7 @@
 
 
 /***********************************************************************
- *           GetClassInfoEx32A      (USER32.211)
+ *           GetClassInfoEx32A      (USER32.212)
  */
 BOOL32 WINAPI GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name,
                                  WNDCLASSEX32A *wc )
@@ -1007,7 +1007,7 @@
 
 
 /***********************************************************************
- *           GetClassInfoEx32W      (USER32.212)
+ *           GetClassInfoEx32W      (USER32.213)
  */
 BOOL32 WINAPI GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name,
                                  WNDCLASSEX32W *wc )
diff --git a/windows/clipboard.c b/windows/clipboard.c
index 5c515d3..ed04c6d 100644
--- a/windows/clipboard.c
+++ b/windows/clipboard.c
@@ -258,7 +258,7 @@
 
 
 /**************************************************************************
- *            OpenClipboard32   (USER32.406)
+ *            OpenClipboard32   (USER32.407)
  *
  * Note: Netscape uses NULL hWnd to open the clipboard.
  */
@@ -292,7 +292,7 @@
 
 
 /**************************************************************************
- *            CloseClipboard32   (USER32.53)
+ *            CloseClipboard32   (USER32.54)
  */
 BOOL32 WINAPI CloseClipboard32(void)
 {
@@ -320,7 +320,7 @@
 
 
 /**************************************************************************
- *            EmptyClipboard32   (USER32.168)
+ *            EmptyClipboard32   (USER32.169)
  */
 BOOL32 WINAPI EmptyClipboard32(void)
 {
@@ -370,7 +370,7 @@
 
 
 /**************************************************************************
- *            GetClipboardOwner32   (USER32.224)
+ *            GetClipboardOwner32   (USER32.225)
  */
 HWND32 WINAPI GetClipboardOwner32(void)
 {
@@ -438,7 +438,7 @@
 
 
 /**************************************************************************
- *            SetClipboardData32   (USER32.469)
+ *            SetClipboardData32   (USER32.470)
  */
 HANDLE32 WINAPI SetClipboardData32( UINT32 wFormat, HANDLE32 hData )
 {
@@ -543,7 +543,7 @@
 
 
 /**************************************************************************
- *             GetClipboardData32   (USER32.221)
+ *             GetClipboardData32   (USER32.222)
  */
 HANDLE32 WINAPI GetClipboardData32( UINT32 wFormat )
 {
@@ -561,7 +561,7 @@
 
 
 /**************************************************************************
- *           CountClipboardFormats32   (USER32.62)
+ *           CountClipboardFormats32   (USER32.63)
  */
 INT32 WINAPI CountClipboardFormats32(void)
 {
@@ -601,7 +601,7 @@
 
 
 /**************************************************************************
- *            EnumClipboardFormats32   (USER32.178)
+ *            EnumClipboardFormats32   (USER32.179)
  */
 UINT32 WINAPI EnumClipboardFormats32( UINT32 wFormat )
 {
@@ -688,7 +688,7 @@
 
 
 /**************************************************************************
- *            RegisterClipboardFormat32A   (USER32.430)
+ *            RegisterClipboardFormat32A   (USER32.431)
  */
 UINT32 WINAPI RegisterClipboardFormat32A( LPCSTR formatName )
 {
@@ -697,7 +697,7 @@
 
 
 /**************************************************************************
- *            RegisterClipboardFormat32W   (USER32.431)
+ *            RegisterClipboardFormat32W   (USER32.432)
  */
 UINT32 WINAPI RegisterClipboardFormat32W( LPCWSTR formatName )
 {
@@ -717,7 +717,7 @@
 
 
 /**************************************************************************
- *            GetClipboardFormatName32A   (USER32.222)
+ *            GetClipboardFormatName32A   (USER32.223)
  */
 INT32 WINAPI GetClipboardFormatName32A( UINT32 wFormat, LPSTR retStr, INT32 maxlen )
 {
@@ -736,7 +736,7 @@
 
 
 /**************************************************************************
- *            GetClipboardFormatName32W   (USER32.223)
+ *            GetClipboardFormatName32W   (USER32.224)
  */
 INT32 WINAPI GetClipboardFormatName32W( UINT32 wFormat, LPWSTR retStr, INT32 maxlen )
 {
@@ -758,7 +758,7 @@
 
 
 /**************************************************************************
- *            SetClipboardViewer32   (USER32.470)
+ *            SetClipboardViewer32   (USER32.471)
  */
 HWND32 WINAPI SetClipboardViewer32( HWND32 hWnd )
 {
@@ -781,7 +781,7 @@
 
 
 /**************************************************************************
- *           GetClipboardViewer32   (USER32.225)
+ *           GetClipboardViewer32   (USER32.226)
  */
 HWND32 WINAPI GetClipboardViewer32(void)
 {
@@ -798,7 +798,7 @@
 }
 
 /**************************************************************************
- *           ChangeClipboardChain32   (USER32.21)
+ *           ChangeClipboardChain32   (USER32.22)
  */
 BOOL32 WINAPI ChangeClipboardChain32(HWND32 hWnd, HWND32 hWndNext)
 {
@@ -830,7 +830,7 @@
 
 
 /**************************************************************************
- *           IsClipboardFormatAvailable32   (USER32.339)
+ *           IsClipboardFormatAvailable32   (USER32.340)
  */
 BOOL32 WINAPI IsClipboardFormatAvailable32( UINT32 wFormat )
 {
@@ -853,7 +853,7 @@
 
 
 /**************************************************************************
- *             GetOpenClipboardWindow32   (USER32.276)
+ *             GetOpenClipboardWindow32   (USER32.277)
  */
 HWND32 WINAPI GetOpenClipboardWindow32(void)
 {
diff --git a/windows/dce.c b/windows/dce.c
index 9ab105d..da1bee7 100644
--- a/windows/dce.c
+++ b/windows/dce.c
@@ -43,12 +43,13 @@
 {
     DCE* dce = firstDCE;
     
-    printf("DCE:\n");
+    DUMP("DCE:\n");
     while( dce )
     {
-	printf("\t[0x%08x] hWnd 0x%04x, dcx %08x, %s %s\n",
-	(unsigned)dce, dce->hwndCurrent, (unsigned)dce->DCXflags, (dce->DCXflags & DCX_CACHE) ?
-	"Cache" : "Owned", (dce->DCXflags & DCX_DCEBUSY) ? "InUse" : "" );
+	DUMP("\t[0x%08x] hWnd 0x%04x, dcx %08x, %s %s\n",
+	     (unsigned)dce, dce->hwndCurrent, (unsigned)dce->DCXflags, 
+	     (dce->DCXflags & DCX_CACHE) ? "Cache" : "Owned", 
+	     (dce->DCXflags & DCX_DCEBUSY) ? "InUse" : "" );
 	dce = dce->next;
     }
 }
@@ -143,7 +144,8 @@
 		}
 		else if( pDCE->DCXflags & DCX_DCEBUSY ) /* shared cache DCE */
 		{
-		    fprintf(stderr,"[%04x] GetDC() without ReleaseDC()!\n", pWnd->hwndSelf);
+		    ERR(cd,"[%04x] GetDC() without ReleaseDC()!\n", 
+			pWnd->hwndSelf);
 		    DCE_ReleaseDC( pDCE );
 		}
 
@@ -709,8 +711,8 @@
 
 		if( dce->hClipRgn != hrgnClip )
 		{
-		    fprintf(stdnimp,"GetDCEx: new hrgnClip [%04x] smashes the previous [%04x]!\n",
-				     hrgnClip, dce->hClipRgn );
+		    FIXME(dc,"new hrgnClip[%04x] smashes the previous[%04x]\n",
+			  hrgnClip, dce->hClipRgn );
 		    DCE_DeleteClipRgn( dce );
 		}
 		else 
@@ -928,7 +930,7 @@
 	   break;
 
       default:
-	   fprintf(stdnimp,"DCHook: unknown code\n");
+	   FIXME(dc,"unknown code\n");
     }
   return 0;
 }
diff --git a/windows/defwnd.c b/windows/defwnd.c
index 87a4daa..9b41bf1 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -36,10 +36,10 @@
 {
     WPARAM16 wp = SIZE_RESTORED;
 
-    if (!(flags & SWP_NOMOVE))
+    if (!(flags & SWP_NOCLIENTMOVE))
         SendMessage16( wndPtr->hwndSelf, WM_MOVE, 0,
                     MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top));
-    if (!(flags & SWP_NOSIZE))
+    if (!(flags & SWP_NOCLIENTSIZE))
     {
         if (wndPtr->dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
         else if (wndPtr->dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
diff --git a/windows/hook.c b/windows/hook.c
index ffd5ce5..79f1a7b 100644
--- a/windows/hook.c
+++ b/windows/hook.c
@@ -221,7 +221,7 @@
 	case WH_HARDWARE: 
 	case WH_FOREGROUNDIDLE: 
 	case WH_CALLWNDPROCRET:
-	    fprintf(stderr, "\t[%i] 16to32 translation unimplemented\n", id);
+	    FIXME(hook, "\t[%i] 16to32 translation unimplemented\n", id);
     }
 }
 
@@ -325,7 +325,7 @@
         case WH_HARDWARE:
 	case WH_FOREGROUNDIDLE:
 	case WH_CALLWNDPROCRET:
-	    fprintf(stderr, "\t[%i] skipping unmap\n", id);
+	    FIXME(hook, "\t[%i] skipping unmap\n", id);
   	    break;
     }
 }
@@ -489,7 +489,7 @@
       case WH_HARDWARE:
       case WH_FOREGROUNDIDLE:
       case WH_CALLWNDPROCRET:
-	fprintf(stderr,"\t[%i] 32to16 translation unimplemented\n", id);
+	FIXME(hook,"\t[%i] 32to16 translation unimplemented\n", id);
     }
 }
 
@@ -635,7 +635,7 @@
       case WH_HARDWARE:
       case WH_FOREGROUNDIDLE:
       case WH_CALLWNDPROCRET:
-	fprintf(stderr, "\t[%i] skipping unmap\n", id);
+	FIXME(hook, "\t[%i] skipping unmap\n", id);
     }
 }
 
@@ -1175,7 +1175,7 @@
 
     if (id == WH_DEBUG)
     {
-	fprintf( stdnimp, "WH_DEBUG is broken in 16-bit Windows.\n");
+	FIXME(hook, "WH_DEBUG is broken in 16-bit Windows.\n");
 	return 0;
     }
 
@@ -1363,7 +1363,7 @@
     fromtype = oldhook->flags & HOOK_MAPTYPE;
 
     if (fromtype == HOOK_WIN16)
-      fprintf(stderr, "CallNextHookEx32: called from 16bit hook!\n");
+      ERR(hook, "called from 16bit hook!\n");
 
     return HOOK_CallHook( next, fromtype, code, wParam, lParam );
 }
diff --git a/windows/keyboard.c b/windows/keyboard.c
index 5717db5..6d91398 100644
--- a/windows/keyboard.c
+++ b/windows/keyboard.c
@@ -24,7 +24,9 @@
 #include "keyboard.h"
 #include "message.h"
 #include "debug.h"
+#include "debugtools.h"
 #include "struct32.h"
+#include "winerror.h"
 
 BOOL32 MouseButtonsStates[3];
 BOOL32 AsyncMouseButtonsStates[3];
@@ -611,14 +613,6 @@
     return GetAsyncKeyState32(nKey);
 }
 
-/*********************************************************************
- *                    CreateAcceleratorTable   (USER.64)
- */
-HACCEL32 WINAPI CreateAcceleratorTable32A(LPACCEL32 lpaccel, INT32 cEntries) {
-   fprintf(stderr, "CreateAcceleratorTable32A Stub\n");
-   return NULL;
-}
-
 /**********************************************************************
  *			TranslateAccelerator 	[USER.178][USER32.551..]
  *
@@ -745,20 +739,26 @@
     LPACCEL32	lpAccelTbl = (LPACCEL32)LockResource32(hAccel);
     int 	i;
     
-    if (hAccel == 0 || msg == NULL) return 0;
-    if (msg->message != WM_KEYDOWN &&
-    	msg->message != WM_KEYUP &&
-	msg->message != WM_SYSKEYDOWN &&
-	msg->message != WM_SYSKEYUP &&
-    	msg->message != WM_CHAR) return 0;
+    if (hAccel == 0 || msg == NULL ||
+	(msg->message != WM_KEYDOWN &&
+	 msg->message != WM_KEYUP &&
+	 msg->message != WM_SYSKEYDOWN &&
+	 msg->message != WM_SYSKEYUP &&
+	 msg->message != WM_CHAR)) {
+      WARN(accel, "erraneous input parameters\n");
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return 0;
+    }
 
-    TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,\
-msg->hwnd=%04x, msg->message=%04x\n", hAccel,hWnd,msg->hwnd,msg->message);
+    TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,"
+	  "msg->hwnd=%04x, msg->message=%04x\n",
+	  hAccel,hWnd,msg->hwnd,msg->message);
 
     for (i = 0; lpAccelTbl[i].key ; i++)
     	if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt,
                                       lpAccelTbl[i].key,lpAccelTbl[i].cmd))
 		return 1;
+    WARN(accel, "couldn't translate accelerator key");
     return 0;
 }
 	
@@ -768,12 +768,16 @@
     int 	i;
     MSG32	msg32;
     
-    if (hAccel == 0 || msg == NULL) return 0;
-    if (msg->message != WM_KEYDOWN &&
-    	msg->message != WM_KEYUP &&
-	msg->message != WM_SYSKEYDOWN &&
-	msg->message != WM_SYSKEYUP &&
-    	msg->message != WM_CHAR) return 0;
+    if (hAccel == 0 || msg == NULL ||
+	(msg->message != WM_KEYDOWN &&
+	 msg->message != WM_KEYUP &&
+	 msg->message != WM_SYSKEYDOWN &&
+	 msg->message != WM_SYSKEYUP &&
+	 msg->message != WM_CHAR)) {
+      WARN(accel, "erraneous input parameters\n");
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return 0;
+    }
 
     TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,\
 msg->hwnd=%04x, msg->message=%04x\n", hAccel,hWnd,msg->hwnd,msg->message);
@@ -784,6 +788,7 @@
     	if (KBD_translate_accelerator(hWnd,&msg32,lpAccelTbl[i].fVirt,
                                       lpAccelTbl[i].key,lpAccelTbl[i].cmd))
 		return 1;
+    WARN(accel, "couldn't translate accelerator key");
     return 0;
 }
 
diff --git a/windows/message.c b/windows/message.c
index 294e254..e96fe52 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -1090,7 +1090,7 @@
 
     if (!(wndPtr = WIN_FindWndPtr( hwnd )))
     {
-        fprintf( stderr, "SendMessage16: invalid hwnd %04x\n", hwnd );
+        WARN(msg, "invalid hwnd %04x\n", hwnd );
         return 0;
     }
     if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))
@@ -1136,7 +1136,7 @@
 BOOL32 WINAPI PostThreadMessage32A(DWORD idThread , UINT32 message,
                                    WPARAM32 wParam, LPARAM lParam )
 {
-   fprintf(stderr, "PostThreadMessage32A Stub\n");
+   FIXME(sendmsg, "(...): Stub\n");
    return FALSE;
 }
 
@@ -1170,7 +1170,7 @@
 
     if (!(wndPtr = WIN_FindWndPtr( hwnd )))
     {
-        fprintf( stderr, "SendMessage32A: invalid hwnd %08x\n", hwnd );
+        WARN(msg, "invalid hwnd %08x\n", hwnd );
         return 0;
     }
 
@@ -1221,7 +1221,7 @@
 
     if (!(wndPtr = WIN_FindWndPtr( hwnd )))
     {
-        fprintf( stderr, "SendMessage32W: invalid hwnd %08x\n", hwnd );
+        WARN(msg, "invalid hwnd %08x\n", hwnd );
         return 0;
     }
     if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))
@@ -1248,7 +1248,7 @@
 				     LPARAM lParam, UINT16 flags,
 				     UINT16 timeout, LPWORD resultp)
 {
-  fprintf (stdnimp, "SendMessageTimeout16 -- semistub\n");
+  FIXME(sendmsg, "(...): semistub\n");
   return SendMessage16 (hwnd, msg, wParam, lParam);
 }
 
@@ -1260,7 +1260,7 @@
 				      LPARAM lParam, UINT32 flags,
 				      UINT32 timeout, LPDWORD resultp)
 {
-  fprintf (stdnimp, "SendMessageTimeout32A -- semistub\n");
+  FIXME(sendmsg, "(...): semistub\n");
   return SendMessage32A (hwnd, msg, wParam, lParam);
 }
 
@@ -1272,7 +1272,7 @@
 				      LPARAM lParam, UINT32 flags,
 				      UINT32 timeout, LPDWORD resultp)
 {
-  fprintf (stdnimp, "SendMessageTimeout32W -- semistub\n");
+  FIXME(sendmsg, "(...): semistub\n");
   return SendMessage32W (hwnd, msg, wParam, lParam);
 }
 
@@ -1533,8 +1533,8 @@
     if (painting && (wndPtr = WIN_FindWndPtr( msg->hwnd )) &&
         (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
     {
-	fprintf(stderr, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", 
-		msg->hwnd);
+	ERR(msg, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", 
+	    msg->hwnd);
 	wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
         /* Validate the update region to avoid infinite WM_PAINT loop */
         ValidateRect32( msg->hwnd, NULL );
@@ -1580,8 +1580,8 @@
     if (painting && (wndPtr = WIN_FindWndPtr( msg->hwnd )) &&
         (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
     {
-	fprintf(stderr, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", 
-		msg->hwnd);
+	ERR(msg, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", 
+	    msg->hwnd);
 	wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
         /* Validate the update region to avoid infinite WM_PAINT loop */
         ValidateRect32( msg->hwnd, NULL );
@@ -1627,8 +1627,8 @@
     if (painting && (wndPtr = WIN_FindWndPtr( msg->hwnd )) &&
         (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
     {
-	fprintf(stderr, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", 
-		msg->hwnd);
+	ERR(msg, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", 
+	    msg->hwnd);
 	wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
         /* Validate the update region to avoid infinite WM_PAINT loop */
         ValidateRect32( msg->hwnd, NULL );
@@ -1717,8 +1717,8 @@
 	DWORD dwFlags,LPDWORD recipients,UINT32 uMessage,WPARAM32 wParam,
 	LPARAM lParam
 ) {
-	fprintf(stdnimp,"BroadcastSystemMessage(%08lx,%08lx,%08x,%08x,%08lx),stub!\n",
-		dwFlags,*recipients,uMessage,wParam,lParam
+	FIXME(sendmsg,"(%08lx,%08lx,%08x,%08x,%08lx): stub!\n",
+	      dwFlags,*recipients,uMessage,wParam,lParam
 	);
 	return 0;
 }
@@ -1728,8 +1728,8 @@
  */
 LONG WINAPI SendNotifyMessage32A(HWND32 hwnd,UINT32 msg,WPARAM32 wParam,LPARAM lParam)
 {
-	fprintf(stderr,"SendNotifyMessage32A(%04x,%08lx,%08lx,%08lx),stub!\n",
-		hwnd,(long)msg,(long)wParam,lParam
+	FIXME(msg,"(%04x,%08lx,%08lx,%08lx): stub!\n",
+	      hwnd,(long)msg,(long)wParam,lParam
 	);
 	return 0;
 }
diff --git a/windows/msgbox.c b/windows/msgbox.c
index f5f90bd..01f45e2 100644
--- a/windows/msgbox.c
+++ b/windows/msgbox.c
@@ -12,6 +12,8 @@
 #include "win.h"
 #include "resource.h"
 #include "task.h"
+#include "debug.h"
+#include "debugstr.h"
 
 /**************************************************************************
  *           MSGBOX_DlgProc
@@ -168,6 +170,9 @@
       EndDialog32(hwnd, wParam);
       break;
     }
+   default:
+     /* Ok. Ignore all the other messages */
+     TRACE (dialog, "Message number %i is being ignored.\n", message);
     break;
   }
   return 0;
@@ -191,7 +196,8 @@
     MSGBOXPARAMS32A mbox;
 
     if (!text) text="<WINE-NULL>";
-    if (!title) title="<WINE-NULL>";
+    if (!title)
+      title="Error";
     mbox.lpszCaption = title;
     mbox.lpszText  = text;
     mbox.dwStyle  = type;
diff --git a/windows/queue.c b/windows/queue.c
index 44b0ec5..0937f93 100644
--- a/windows/queue.c
+++ b/windows/queue.c
@@ -811,6 +811,15 @@
     return GetInputState32();
 }
 
+/***********************************************************************
+ *           WaitForInputIdle   (USER32.577)
+ */
+DWORD WINAPI WaitForInputIdle (HANDLE32 hProcess, DWORD dwTimeOut)
+{
+  FIXME (msg, "WaitForInputIdle: stub\n");
+  return WAIT_TIMEOUT;
+}
+
 
 /***********************************************************************
  *           GetInputState32   (USER32.243)
diff --git a/windows/scroll.c b/windows/scroll.c
index 9682082..701e69b 100644
--- a/windows/scroll.c
+++ b/windows/scroll.c
@@ -164,10 +164,10 @@
     if ( !dc || !hdc ) return FALSE;
 
 /*
-    printf(stddeb,"\t[wndOrgX=%i, wndExtX=%i, vportOrgX=%i, vportExtX=%i]\n",
-		  dc->wndOrgX, dc->wndExtX, dc->vportOrgX, dc->vportExtX );
-    printf(stddeb,"\t[wndOrgY=%i, wndExtY=%i, vportOrgY=%i, vportExtY=%i]\n",
-                  dc->wndOrgY, dc->wndExtY, dc->vportOrgY, dc->vportExtY );
+    TRACE(scroll,"\t[wndOrgX=%i, wndExtX=%i, vportOrgX=%i, vportExtX=%i]\n",
+          dc->wndOrgX, dc->wndExtX, dc->vportOrgX, dc->vportExtX );
+    TRACE(scroll,"\t[wndOrgY=%i, wndExtY=%i, vportOrgY=%i, vportExtY=%i]\n",
+	  dc->wndOrgY, dc->wndExtY, dc->vportOrgY, dc->vportExtY );
 */
 
     /* compute device clipping region */
diff --git a/windows/user.c b/windows/user.c
index 1c42131..ec801d6 100644
--- a/windows/user.c
+++ b/windows/user.c
@@ -257,7 +257,7 @@
  */
 BOOL16 WINAPI ExitWindowsExec16( LPCSTR lpszExe, LPCSTR lpszParams )
 {
-fprintf(stdnimp, "ExitWindowsExec() : Should run the following in DOS-mode :\n\t\"%s %s\"\n",
+    fprintf(stderr, "ExitWindowsExec() : Should run the following in DOS-mode :\n\t\"%s %s\"\n",
 	lpszExe, lpszParams);
     return ExitWindowsEx( EWX_LOGOFF, 0xffffffff );
 }
diff --git a/windows/win.c b/windows/win.c
index e0412db..b15181d 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -31,7 +31,6 @@
 #include "winproc.h"
 #include "thread.h"
 #include "debug.h"
-#include "debugstr.h"
 
 /* Desktop window */
 static WND *pWndDesktop = NULL;
@@ -705,15 +704,19 @@
                        LoadMenu(cs->hInstance,(SEGPTR)classPtr->menuNameA);
 #else
 	    SEGPTR menuName = (SEGPTR)GetClassLong16( hwnd, GCL_MENUNAME );
-	    /* hInstance is still 16-bit in 980215 winelib */
-	    if (HIWORD(cs->hInstance) || __winelib)
-	    	cs->hMenu = LoadMenu32A(cs->hInstance,PTR_SEG_TO_LIN(menuName));
-	    else
-	      /* doesn't work for winelib, since resources are unicode */
-	    	cs->hMenu = LoadMenu16(cs->hInstance,menuName);
+            if (menuName)
+            {
+                /* hInstance is still 16-bit in 980215 winelib */
+                if (HIWORD(cs->hInstance) || __winelib)
+                    cs->hMenu = LoadMenu32A(cs->hInstance,PTR_SEG_TO_LIN(menuName));
+                else
+                    /* doesn't work for winelib, since resources are unicode */
+                    cs->hMenu = LoadMenu16(cs->hInstance,menuName);
+
+                if (cs->hMenu) SetMenu32( hwnd, cs->hMenu );
+            }
 #endif
         }
-        if (cs->hMenu) SetMenu32( hwnd, cs->hMenu );
     }
     else wndPtr->wIDmenu = (UINT32)cs->hMenu;
 
@@ -1740,7 +1743,7 @@
 HWND32 WINAPI GetParent32( HWND32 hwnd )
 {
     WND *wndPtr = WIN_FindWndPtr(hwnd);
-    if (!wndPtr) return 0;
+    if ((!wndPtr) || (!(wndPtr->dwStyle & (WS_POPUP|WS_CHILD)))) return 0;
     wndPtr = (wndPtr->dwStyle & WS_CHILD) ? wndPtr->parent : wndPtr->owner;
     return wndPtr ? wndPtr->hwndSelf : 0;
 }
diff --git a/windows/winpos.c b/windows/winpos.c
index 7603807..aebdca8 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -465,7 +465,7 @@
     {
         if (!(wndPtr = WIN_FindWndPtr( hwndFrom )))
         {
-            fprintf(stderr,"MapWindowPoints: bad hwndFrom = %04x\n",hwndFrom);
+            ERR(win,"bad hwndFrom = %04x\n",hwndFrom);
             return;
         }
         while (wndPtr->parent)
@@ -481,7 +481,7 @@
     {
         if (!(wndPtr = WIN_FindWndPtr( hwndTo )))
         {
-            fprintf(stderr,"MapWindowPoints: bad hwndTo = %04x\n", hwndTo );
+            ERR(win,"bad hwndTo = %04x\n", hwndTo );
             return;
         }
         while (wndPtr->parent)
@@ -672,7 +672,7 @@
  */
 HWND32 WINAPI SetShellWindow32(HWND32 hwndshell)
 {
-    fprintf( stdnimp, "SetShellWindow(%08x): empty stub\n",hwndshell );
+    FIXME(win, "(%08x): empty stub\n",hwndshell );
     return 0;
 }
 
@@ -682,7 +682,7 @@
  */
 HWND32 WINAPI GetShellWindow32(void)
 {
-    fprintf( stdnimp, "GetShellWindow: empty stub\n" );
+    FIXME(win, "(void): empty stub\n" );
     return 0;
 }
 
@@ -2564,7 +2564,7 @@
  */
 void WINAPI TileChildWindows( HWND16 parent, WORD action )
 {
-    printf("STUB TileChildWindows(%04x, %d)\n", parent, action);
+    FIXME(win, "(%04x, %d): stub\n", parent, action);
 }
 
 /***********************************************************************
@@ -2572,5 +2572,5 @@
  */
 void WINAPI CascadeChildWindows( HWND16 parent, WORD action )
 {
-    printf("STUB CascadeChildWindows(%04x, %d)\n", parent, action);
+    FIXME(win, "(%04x, %d): stub\n", parent, action);
 }