Release 960405

Fri Apr  5 15:22:55 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [controls/button.c] [controls/static.c]
	Changes to use WND * wherever possible.

	* [debugger/dbg.y] [debugger/debug.l]
	Added 'info module' and 'walk module' commands.

	* [if1632/Makefile.in] [if1632/relay.c] [tools/build.c]
	Added assembly code generation to call from Wine into 32-bit code.
	Changed all 'call32' references in 'callfrom16' to avoid confusion
	with Win32 routines.

	* [include/callback.h]
	Added prototypes for 32-bit callbacks.

	* [loader/module.c] [if1632/relay32.c] [tools/build.c]
	Unified 16- and 32-bit modules. The fake module for 32-bit DLLs is
	now generated by the build program.

	* [include/module.h]
	Added extra info to NE_MODULE for Win32 modules to point to the PE
	module data.

	* [include/pe_image.h] [loader/pe_image.c] [win32/resource.c]
	Removed the wine_files list. The PE data for a module can now be
	accessed with the NE_WIN32_MODULE macro.

	* [loader/signal.c] [miscemu/instr.c]
	Don't start the BIOS timer at startup, but only after an access to
	the 0x40 segment.

	* [memory/local.c]
	Changed LOCAL_Lock() to return a 32-bit pointer.

	* [misc/main.c] [include/dlls.h]
	Some built-in DLLs (like KERNEL) can no longer be disabled from
 	the command-line.
	
Thu Apr  4 19:54:39 1996  Keith Reynolds <keithr@sco.COM>

	* [*/*]
	A lot of small changes to support SCO OpenServer 5.

Thu Apr  4 15:38:13 1996  Frans van Dorsselaer <dorssel@rulhm1.leidenuniv.nl>

	* [controls/edit.c]
	Fixed GetKeyState() call to use 0x8000 convention.

	* [include/windows.h]
	Added undocumented messages EM_SCROLL and EM_GETTHUMB.

Thu Apr  4 09:52:52 1996  John Harvey <john@division.co.uk>

	* [if1632/except.S]
	Modified code to assemble on unixware.

Wed Apr  3 09:38:26 1996  Juergen Marquardt <marqu@lunar.advantest.de>

	* [objects/font.c]
	Implementation of a second font cache which will be updated
	dynamically.

Mon Apr  1 16:47:40 1996  Robert Pouliot <krynos@qbc.clic.net>

	* [resources/sysres_Cz.rc] [resources/sysres_Da.rc]
	  [resources/sysres_De.rc] [resources/sysres_Eo.rc]
	  [resources/sysres_Es.rc] [resources/sysres_Fi.rc]
	  [resources/sysres_No.rc] [resources/TODO]
	Updated FIND_TEXT and REPLACE_TEXT to work like the English version.
diff --git a/ANNOUNCE b/ANNOUNCE
index 64fa517..e2d0c98 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,14 +1,14 @@
-This is release 960331 of Wine the MS Windows emulator.  This is still a
+This is release 960405 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.
 
 Patches should be submitted to "julliard@lrc.epfl.ch".  Please don't
 forget to include a ChangeLog entry.
 
-WHAT'S NEW with Wine-960331: (see ChangeLog for details)
-	- Many improvements to keyboard handling.
-	- New registry code with Win32 support.
-	- Support for Italian language.
+WHAT'S NEW with Wine-960405: (see ChangeLog for details)
+	- Faster text display.
+	- Support for SCO OpenServer 5.
+	- Cleaner Win32 module handling.
 	- 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:
 
-    sunsite.unc.edu:/pub/Linux/ALPHA/wine/development/Wine-960331.tar.gz
-    tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-960331.tar.gz
-    ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-960331.tar.gz
-    aris.com:/pub/linux/ALPHA/Wine/development/Wine-960331.tar.gz
+    sunsite.unc.edu:/pub/Linux/ALPHA/wine/development/Wine-960405.tar.gz
+    tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-960405.tar.gz
+    ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-960405.tar.gz
+    aris.com:/pub/linux/ALPHA/Wine/development/Wine-960405.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/ChangeLog b/ChangeLog
index 88685439..f37c6bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,76 @@
 ----------------------------------------------------------------------
+Fri Apr  5 15:22:55 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
+
+	* [controls/button.c] [controls/static.c]
+	Changes to use WND * wherever possible.
+
+	* [debugger/dbg.y] [debugger/debug.l]
+	Added 'info module' and 'walk module' commands.
+
+	* [if1632/Makefile.in] [if1632/relay.c] [tools/build.c]
+	Added assembly code generation to call from Wine into 32-bit code.
+	Changed all 'call32' references in 'callfrom16' to avoid confusion
+	with Win32 routines.
+
+	* [include/callback.h]
+	Added prototypes for 32-bit callbacks.
+
+	* [loader/module.c] [if1632/relay32.c] [tools/build.c]
+	Unified 16- and 32-bit modules. The fake module for 32-bit DLLs is
+	now generated by the build program.
+
+	* [include/module.h]
+	Added extra info to NE_MODULE for Win32 modules to point to the PE
+	module data.
+
+	* [include/pe_image.h] [loader/pe_image.c] [win32/resource.c]
+	Removed the wine_files list. The PE data for a module can now be
+	accessed with the NE_WIN32_MODULE macro.
+
+	* [loader/signal.c] [miscemu/instr.c]
+	Don't start the BIOS timer at startup, but only after an access to
+	the 0x40 segment.
+
+	* [memory/local.c]
+	Changed LOCAL_Lock() to return a 32-bit pointer.
+
+	* [misc/main.c] [include/dlls.h]
+	Some built-in DLLs (like KERNEL) can no longer be disabled from
+ 	the command-line.
+	
+Thu Apr  4 19:54:39 1996  Keith Reynolds <keithr@sco.COM>
+
+	* [*/*]
+	A lot of small changes to support SCO OpenServer 5.
+
+Thu Apr  4 15:38:13 1996  Frans van Dorsselaer <dorssel@rulhm1.leidenuniv.nl>
+
+	* [controls/edit.c]
+	Fixed GetKeyState() call to use 0x8000 convention.
+
+	* [include/windows.h]
+	Added undocumented messages EM_SCROLL and EM_GETTHUMB.
+
+Thu Apr  4 09:52:52 1996  John Harvey <john@division.co.uk>
+
+	* [if1632/except.S]
+	Modified code to assemble on unixware.
+
+Wed Apr  3 09:38:26 1996  Juergen Marquardt <marqu@lunar.advantest.de>
+
+	* [objects/font.c]
+	Implementation of a second font cache which will be updated
+	dynamically.
+
+Mon Apr  1 16:47:40 1996  Robert Pouliot <krynos@qbc.clic.net>
+
+	* [resources/sysres_Cz.rc] [resources/sysres_Da.rc]
+	  [resources/sysres_De.rc] [resources/sysres_Eo.rc]
+	  [resources/sysres_Es.rc] [resources/sysres_Fi.rc]
+	  [resources/sysres_No.rc] [resources/TODO]
+	Updated FIND_TEXT and REPLACE_TEXT to work like the English version.
+
+----------------------------------------------------------------------
 Sun Mar 31 13:54:46 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
 
 	* [tools/build.c]
diff --git a/Make.rules.in b/Make.rules.in
index b07b131..bb56d51 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -3,7 +3,8 @@
 
 # First some useful definitions
 
-CC 	  = @CC@
+SHELL     = /bin/sh
+CC        = @CC@
 CPP       = @CPP@
 CFLAGS 	  = @CFLAGS@
 DEFS      = @DEFS@
diff --git a/Makefile.in b/Makefile.in
index 42f935e..12bd1b7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -11,7 +11,8 @@
 
 # First some useful definitions
 
-CC 	  = @CC@
+SHELL     = /bin/sh
+CC        = @CC@
 CPP       = @CPP@
 CFLAGS 	  = @CFLAGS@
 DEFS      = @DEFS@ -DWINE_INI_GLOBAL=\"$(WINE_INI_GLOBAL)\"
diff --git a/controls/button.c b/controls/button.c
index 80bd0f4..68515db 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -12,14 +12,14 @@
 #include "button.h"
 #include "stackframe.h"
 
-extern void DEFWND_SetText( HWND hwnd, LPSTR text );  /* windows/defwnd.c */
+extern void DEFWND_SetText( WND *wndPtr, LPSTR text );  /* windows/defwnd.c */
 
-static void PB_Paint( HWND hWnd, HDC hDC, WORD action );
-static void CB_Paint( HWND hWnd, HDC hDC, WORD action );
-static void GB_Paint( HWND hWnd, HDC hDC, WORD action );
-static void UB_Paint( HWND hWnd, HDC hDC, WORD action );
-static void OB_Paint( HWND hWnd, HDC hDC, WORD action );
-static void BUTTON_CheckAutoRadioButton(HWND hWnd);
+static void PB_Paint( WND *wndPtr, HDC hDC, WORD action );
+static void CB_Paint( WND *wndPtr, HDC hDC, WORD action );
+static void GB_Paint( WND *wndPtr, HDC hDC, WORD action );
+static void UB_Paint( WND *wndPtr, HDC hDC, WORD action );
+static void OB_Paint( WND *wndPtr, HDC hDC, WORD action );
+static void BUTTON_CheckAutoRadioButton( WND *wndPtr );
 
 
 #define MAX_BTN_TYPE  12
@@ -40,7 +40,7 @@
     BUTTON_UNCHECKED    /* BS_OWNERDRAW */
 };
 
-typedef void (*pfPaint)(HWND,HDC,WORD);
+typedef void (*pfPaint)( WND *wndPtr, HDC hdc, WORD action );
 
 static pfPaint btnPaintFunc[MAX_BTN_TYPE] =
 {
@@ -58,11 +58,21 @@
     OB_Paint     /* BS_OWNERDRAW */
 };
 
-#define PAINT_BUTTON(hwnd,style,action) \
+#define PAINT_BUTTON(wndPtr,style,action) \
      if (btnPaintFunc[style]) { \
-         HDC hdc = GetDC( hwnd ); \
-         (btnPaintFunc[style])(hwnd,hdc,action); \
-         ReleaseDC( hwnd, hdc ); }
+         HDC hdc = GetDC( (wndPtr)->hwndSelf ); \
+         (btnPaintFunc[style])(wndPtr,hdc,action); \
+         ReleaseDC( (wndPtr)->hwndSelf, hdc ); }
+
+#ifdef WINELIB32
+#define BUTTON_SEND_CTLCOLOR(wndPtr,hdc) \
+    SendMessage( GetParent((wndPtr)->hwndSelf), WM_CTLCOLORBTN, \
+                 (hdc), (wndPtr)->hwndSelf )
+#else
+#define BUTTON_SEND_CTLCOLOR(wndPtr,hdc) \
+    SendMessage( GetParent((wndPtr)->hwndSelf), WM_CTLCOLOR, (hdc), \
+                 MAKELPARAM((wndPtr)->hwndSelf, CTLCOLOR_BTN) )
+#endif
 
 static HBITMAP hbitmapCheckBoxes = 0;
 static WORD checkBoxWidth = 0, checkBoxHeight = 0;
@@ -93,7 +103,7 @@
                 }
 
 	case WM_ENABLE:
-                PAINT_BUTTON( hWnd, style, ODA_DRAWENTIRE );
+                PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
 		break;
 
 	case WM_CREATE:
@@ -124,7 +134,7 @@
                 {
                     PAINTSTRUCT ps;
                     HDC hdc = BeginPaint( hWnd, &ps );
-                    (btnPaintFunc[style])( hWnd, hdc, ODA_DRAWENTIRE );
+                    (btnPaintFunc[style])( wndPtr, hdc, ODA_DRAWENTIRE );
                     ReleaseDC( hWnd, hdc );
                 }
 		break;
@@ -187,14 +197,14 @@
                 break;
 
         case WM_SETTEXT:
-		DEFWND_SetText( hWnd, (LPSTR)PTR_SEG_TO_LIN(lParam) );
-                PAINT_BUTTON( hWnd, style, ODA_DRAWENTIRE );
+		DEFWND_SetText( wndPtr, (LPSTR)PTR_SEG_TO_LIN(lParam) );
+                PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
 		return 0;
 
         case WM_SETFONT:
                 infoPtr->hFont = (HFONT) wParam;
                 if (lParam)
-                    PAINT_BUTTON( hWnd, style, ODA_DRAWENTIRE );
+                    PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
                 break;
 
         case WM_GETFONT:
@@ -202,12 +212,12 @@
 
 	case WM_SETFOCUS:
                 infoPtr->state |= BUTTON_HASFOCUS;
-                PAINT_BUTTON( hWnd, style, ODA_FOCUS );
+                PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
 		break;
 
 	case WM_KILLFOCUS:
                 infoPtr->state &= ~BUTTON_HASFOCUS;
-                PAINT_BUTTON( hWnd, style, ODA_FOCUS );
+                PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
 		break;
 
 	case WM_SYSCOLORCHANGE:
@@ -219,7 +229,7 @@
 		wndPtr->dwStyle = (wndPtr->dwStyle & 0xfffffff0) 
 		                   | (wParam & 0x0000000f);
                 style = wndPtr->dwStyle & 0x0000000f;
-                PAINT_BUTTON( hWnd, style, ODA_DRAWENTIRE );
+                PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
 		break;
 
 	case BM_GETCHECK:
@@ -232,10 +242,10 @@
 		if ((infoPtr->state & 3) != wParam)
                 {
                     infoPtr->state = (infoPtr->state & ~3) | wParam;
-                    PAINT_BUTTON( hWnd, style, ODA_SELECT );
+                    PAINT_BUTTON( wndPtr, style, ODA_SELECT );
                 }
 		if(style == BS_AUTORADIOBUTTON && wParam==BUTTON_CHECKED)
-			BUTTON_CheckAutoRadioButton(hWnd);
+			BUTTON_CheckAutoRadioButton( wndPtr );
                 break;
 
 	case BM_GETSTATE:
@@ -247,7 +257,7 @@
                 {
                     if (wParam) infoPtr->state |= BUTTON_HIGHLIGHTED;
                     else infoPtr->state &= ~BUTTON_HIGHLIGHTED;
-                    PAINT_BUTTON( hWnd, style, ODA_SELECT );
+                    PAINT_BUTTON( wndPtr, style, ODA_SELECT );
                 }
                 break;
 
@@ -264,7 +274,7 @@
  *       Push Button Functions
  */
 
-static void PB_Paint( HWND hButton, HDC hDC, WORD action )
+static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
 {
     RECT rc;
     HPEN hOldPen;
@@ -272,19 +282,13 @@
     char *text;
     DWORD dwTextSize;
     TEXTMETRIC tm;
-    WND *wndPtr = WIN_FindWndPtr( hButton );
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
-    GetClientRect(hButton, &rc);
+    GetClientRect(wndPtr->hwndSelf, &rc);
 
       /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
     if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
-#ifdef WINELIB32
-    SendMessage( GetParent(hButton), WM_CTLCOLORBTN, hDC, hButton );
-#else
-    SendMessage( GetParent(hButton), WM_CTLCOLOR, (WORD)hDC,
-                 MAKELPARAM(hButton, CTLCOLOR_BTN) );
-#endif
+    BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
     hOldPen = (HPEN)SelectObject(hDC, sysColorObjects.hpenWindowFrame);
     hOldBrush = (HBRUSH)SelectObject(hDC, sysColorObjects.hbrushBtnFace);
     SetBkMode(hDC, TRANSPARENT);
@@ -347,7 +351,7 @@
  *       Check Box & Radio Button Functions
  */
 
-static void CB_Paint( HWND hWnd, HDC hDC, WORD action )
+static void CB_Paint( WND *wndPtr, HDC hDC, WORD action )
 {
     RECT rc;
     HBRUSH hBrush;
@@ -355,18 +359,12 @@
     char *text;
     TEXTMETRIC tm;
     SIZE size;
-    WND *wndPtr = WIN_FindWndPtr(hWnd);
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
-    GetClientRect(hWnd, &rc);
+    GetClientRect(wndPtr->hwndSelf, &rc);
 
     if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
-#ifdef WINELIB32 /* JBP: Different in Win32 */
-    hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLORBTN, hDC, hWnd);
-#else
-    hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, hDC,
-			 MAKELPARAM(hWnd, CTLCOLOR_BTN));
-#endif
+    hBrush = BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
     if (action == ODA_DRAWENTIRE) FillRect(hDC, &rc, hBrush);
 
     GetTextMetrics(hDC, &tm);
@@ -412,14 +410,15 @@
 /**********************************************************************
  *       BUTTON_CheckAutoRadioButton
  *
- * hWnd is checked, uncheck everything else in group
+ * wndPtr is checked, uncheck everything else in group
  */
-static void BUTTON_CheckAutoRadioButton(HWND hWnd)
+static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
 {
-    HWND parent = GetParent(hWnd);
-    HWND sibling;
-    for(sibling = GetNextDlgGroupItem(parent,hWnd,FALSE);
-        sibling != hWnd;
+    HWND parent, sibling;
+    if (!(wndPtr->dwStyle & WS_CHILD)) return;
+    parent = wndPtr->parent->hwndSelf;
+    for(sibling = GetNextDlgGroupItem(parent,wndPtr->hwndSelf,FALSE);
+        sibling != wndPtr->hwndSelf;
         sibling = GetNextDlgGroupItem(parent,sibling,FALSE))
 	    SendMessage(sibling,BM_SETCHECK,BUTTON_UNCHECKED,0);
 }
@@ -429,26 +428,20 @@
  *       Group Box Functions
  */
 
-static void GB_Paint( HWND hWnd, HDC hDC, WORD action )
+static void GB_Paint( WND *wndPtr, HDC hDC, WORD action )
 {
     RECT rc;
     char *text;
     SIZE size;
-    WND *wndPtr = WIN_FindWndPtr( hWnd );
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
     if (action != ODA_DRAWENTIRE) return;
 
     if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
-#ifdef WINELIB32
-    SendMessage( GetParent(hWnd), WM_CTLCOLORBTN, hDC, hWnd );
-#else
-    SendMessage( GetParent(hWnd), WM_CTLCOLOR, hDC,
-		 MAKELPARAM(hWnd, CTLCOLOR_BTN));
-#endif
+    BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
     SelectObject( hDC, sysColorObjects.hpenWindowFrame );
 
-    GetClientRect(hWnd, &rc);
+    GetClientRect( wndPtr->hwndSelf, &rc);
 
     MoveTo( hDC, rc.left, rc.top+2 );
     LineTo( hDC, rc.right-1, rc.top+2 );
@@ -471,24 +464,18 @@
  *       User Button Functions
  */
 
-static void UB_Paint( HWND hWnd, HDC hDC, WORD action )
+static void UB_Paint( WND *wndPtr, HDC hDC, WORD action )
 {
     RECT rc;
     HBRUSH hBrush;
-    WND *wndPtr = WIN_FindWndPtr( hWnd );
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
     if (action == ODA_SELECT) return;
 
-    GetClientRect(hWnd, &rc);
+    GetClientRect( wndPtr->hwndSelf, &rc);
 
     if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
-#ifdef WINELIB32
-    hBrush = SendMessage( GetParent(hWnd), WM_CTLCOLORBTN, hDC, hWnd );
-#else
-    hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC,
-			 MAKELPARAM(hWnd, CTLCOLOR_BTN));
-#endif
+    hBrush = BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
     FillRect(hDC, &rc, hBrush);
 
     if ((action == ODA_FOCUS) ||
@@ -501,10 +488,9 @@
  *       Ownerdrawn Button Functions
  */
 
-static void OB_Paint( HWND hWnd, HDC hDC, WORD action )
+static void OB_Paint( WND *wndPtr, HDC hDC, WORD action )
 {
     DRAWITEMSTRUCT dis;
-    WND *wndPtr = WIN_FindWndPtr( hWnd );
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
     dis.CtlType    = ODT_BUTTON;
@@ -514,9 +500,10 @@
     dis.itemState  = (infoPtr->state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0 |
                      (infoPtr->state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0 |
                      (wndPtr->dwStyle & WS_DISABLED) ? ODS_DISABLED : 0;
-    dis.hwndItem   = hWnd;
+    dis.hwndItem   = wndPtr->hwndSelf;
     dis.hDC        = hDC;
-    GetClientRect( hWnd, &dis.rcItem );
+    GetClientRect( wndPtr->hwndSelf, &dis.rcItem );
     dis.itemData   = 0;
-    SendMessage(GetParent(hWnd), WM_DRAWITEM, 1, (LPARAM) MAKE_SEGPTR(&dis) );
+    SendMessage( GetParent(wndPtr->hwndSelf), WM_DRAWITEM, 1,
+                 (LPARAM)MAKE_SEGPTR(&dis) );
 }
diff --git a/controls/edit.c b/controls/edit.c
index 6b1154c..37d95ad 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -135,16 +135,7 @@
  */
 static void *EDIT_HeapLock(HWND hwnd, HANDLE handle)
 {
-    HINSTANCE hinstance = WIN_GetWindowInstance( hwnd );
-#if defined(WINELIB)
-    return LOCAL_Lock( hinstance, handle );
-#else
-    HANDLE offs;
-    
-    if (handle == 0) return 0;
-    offs = LOCAL_Lock( hinstance, handle );
-    return PTR_SEG_OFF_TO_LIN( hinstance, offs );
-#endif
+    return LOCAL_Lock( WIN_GetWindowInstance(hwnd), handle );
 }
 
 /*********************************************************************
@@ -2798,7 +2789,7 @@
         return;
     }
 
-    if(motionKey && (0x80 & GetKeyState(VK_SHIFT))) {
+    if(motionKey && (0x8000 & GetKeyState(VK_SHIFT))) {
         EDIT_ExtendSel(hwnd, es->WndCol, es->WndRow*es->txtht);
     } else {
         EDIT_SetAnchor(hwnd, es->CurrLine, es->CurrCol);
diff --git a/controls/static.c b/controls/static.c
index eb51961..9f470b5 100644
--- a/controls/static.c
+++ b/controls/static.c
@@ -3,8 +3,7 @@
  *
  * Copyright  David W. Metcalfe, 1993
  *
-static char Copyright[] = "Copyright  David W. Metcalfe, 1993";
-*/
+ */
 
 #include <stdio.h>
 #include <windows.h>
@@ -12,35 +11,35 @@
 #include "user.h"
 #include "static.h"
 
-extern void DEFWND_SetText( HWND hwnd, LPSTR text );  /* windows/defwnd.c */
+extern void DEFWND_SetText( WND *wndPtr, LPSTR text );  /* windows/defwnd.c */
 
-static void PaintTextfn( HWND hwnd, HDC hdc );
-static void PaintRectfn( HWND hwnd, HDC hdc );
-static void PaintIconfn( HWND hwnd, HDC hdc );
+static void STATIC_PaintTextfn( WND *wndPtr, HDC hdc );
+static void STATIC_PaintRectfn( WND *wndPtr, HDC hdc );
+static void STATIC_PaintIconfn( WND *wndPtr, HDC hdc );
 
 
 static COLORREF color_windowframe, color_background, color_window;
 
 
-typedef void (*pfPaint)(HWND, HDC);
+typedef void (*pfPaint)( WND *, HDC);
 
 #define LAST_STATIC_TYPE  SS_LEFTNOWORDWRAP
 
 static pfPaint staticPaintFunc[LAST_STATIC_TYPE+1] =
 {
-    PaintTextfn,             /* SS_LEFT */
-    PaintTextfn,             /* SS_CENTER */
-    PaintTextfn,             /* SS_RIGHT */
-    PaintIconfn,             /* SS_ICON */
-    PaintRectfn,             /* SS_BLACKRECT */
-    PaintRectfn,             /* SS_GRAYRECT */
-    PaintRectfn,             /* SS_WHITERECT */
-    PaintRectfn,             /* SS_BLACKFRAME */
-    PaintRectfn,             /* SS_GRAYFRAME */
-    PaintRectfn,             /* SS_WHITEFRAME */
+    STATIC_PaintTextfn,      /* SS_LEFT */
+    STATIC_PaintTextfn,      /* SS_CENTER */
+    STATIC_PaintTextfn,      /* SS_RIGHT */
+    STATIC_PaintIconfn,      /* SS_ICON */
+    STATIC_PaintRectfn,      /* SS_BLACKRECT */
+    STATIC_PaintRectfn,      /* SS_GRAYRECT */
+    STATIC_PaintRectfn,      /* SS_WHITERECT */
+    STATIC_PaintRectfn,      /* SS_BLACKFRAME */
+    STATIC_PaintRectfn,      /* SS_GRAYFRAME */
+    STATIC_PaintRectfn,      /* SS_WHITEFRAME */
     NULL,                    /* Not defined */
-    PaintTextfn,             /* SS_SIMPLE */
-    PaintTextfn              /* SS_LEFTNOWORDWRAP */
+    STATIC_PaintTextfn,      /* SS_SIMPLE */
+    STATIC_PaintTextfn       /* SS_LEFTNOWORDWRAP */
 };
 
 
@@ -49,10 +48,9 @@
  *
  * Set the icon for an SS_ICON control.
  */
-static HICON STATIC_SetIcon( HWND hwnd, HICON hicon )
+static HICON STATIC_SetIcon( WND *wndPtr, HICON hicon )
 {
     HICON prevIcon;
-    WND *wndPtr = WIN_FindWndPtr( hwnd );
     STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
 
     if ((wndPtr->dwStyle & 0x0f) != SS_ICON) return 0;
@@ -61,7 +59,7 @@
     if (hicon)
     {
         CURSORICONINFO *info = (CURSORICONINFO *) GlobalLock( hicon );
-        SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight,
+        SetWindowPos( wndPtr->hwndSelf, 0, 0, 0, info->nWidth, info->nHeight,
                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
         GlobalUnlock( hicon );
     }
@@ -94,7 +92,7 @@
                                             createStruct->lpszName );
                     if (!hicon)  /* Try OEM icon (FIXME: is this right?) */
                         hicon = LoadIcon( 0, createStruct->lpszName );
-                    STATIC_SetIcon( hWnd, hicon );
+                    STATIC_SetIcon( wndPtr, hicon );
                 }
                 return 1;
             }
@@ -115,7 +113,7 @@
 
         case WM_NCDESTROY:
             if (style == SS_ICON)
-                DestroyIcon( STATIC_SetIcon( hWnd, 0 ) );
+                DestroyIcon( STATIC_SetIcon( wndPtr, 0 ) );
             else 
                 lResult = DefWindowProc(hWnd, uMsg, wParam, lParam);
             break;
@@ -125,7 +123,7 @@
                 PAINTSTRUCT ps;
                 BeginPaint( hWnd, &ps );
                 if (staticPaintFunc[style])
-                    (staticPaintFunc[style])( hWnd, ps.hdc );
+                    (staticPaintFunc[style])( wndPtr, ps.hdc );
                 EndPaint( hWnd, &ps );
             }
 	    break;
@@ -140,10 +138,10 @@
 	case WM_SETTEXT:
 	    if (style == SS_ICON)
 	        /* FIXME : should we also return the previous hIcon here ??? */
-                STATIC_SetIcon( hWnd, LoadIcon( wndPtr->hInstance,
-                                                (SEGPTR)lParam ));
+                STATIC_SetIcon( wndPtr, LoadIcon( wndPtr->hInstance,
+                                                  (SEGPTR)lParam ));
             else
-                DEFWND_SetText( hWnd, (LPSTR)PTR_SEG_TO_LIN(lParam) );
+                DEFWND_SetText( wndPtr, (LPSTR)PTR_SEG_TO_LIN(lParam) );
 	    InvalidateRect( hWnd, NULL, FALSE );
 	    UpdateWindow( hWnd );
 	    break;
@@ -171,7 +169,7 @@
 	    return infoPtr->hIcon;
 
 	case STM_SETICON:
-            lResult = STATIC_SetIcon( hWnd, (HICON)wParam );
+            lResult = STATIC_SetIcon( wndPtr, (HICON)wParam );
             InvalidateRect( hWnd, NULL, FALSE );
             UpdateWindow( hWnd );
 	    break;
@@ -185,18 +183,17 @@
 }
 
 
-static void PaintTextfn( HWND hwnd, HDC hdc )
+static void STATIC_PaintTextfn( WND *wndPtr, HDC hdc )
 {
     RECT rc;
     HBRUSH hBrush;
     char *text;
     WORD wFormat;
 
-    WND *wndPtr = WIN_FindWndPtr(hwnd);
     LONG style = wndPtr->dwStyle;
     STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
 
-    GetClientRect(hwnd, &rc);
+    GetClientRect( wndPtr->hwndSelf, &rc);
     text = USER_HEAP_LIN_ADDR( wndPtr->hText );
 
     switch (style & 0x0000000F)
@@ -230,24 +227,23 @@
 
     if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont );
 #ifdef WINELIB32
-    hBrush = SendMessage( GetParent(hwnd), WM_CTLCOLORSTATIC, hdc, hwnd );
+    hBrush = SendMessage( GetParent(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
+                          hdc, wndPtr->hwndSelf );
 #else
-    hBrush = SendMessage( GetParent(hwnd), WM_CTLCOLOR, (WORD)hdc,
-                          MAKELONG(hwnd, CTLCOLOR_STATIC));
+    hBrush = SendMessage( GetParent(wndPtr->hwndSelf), WM_CTLCOLOR, (WORD)hdc,
+                          MAKELONG(wndPtr->hwndSelf, CTLCOLOR_STATIC));
 #endif
     if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH);
     FillRect(hdc, &rc, hBrush);
     if (text) DrawText( hdc, text, -1, &rc, wFormat );
 }
 
-static void PaintRectfn( HWND hwnd, HDC hdc )
+static void STATIC_PaintRectfn( WND *wndPtr, HDC hdc )
 {
     RECT rc;
     HBRUSH hBrush;
 
-    WND *wndPtr = WIN_FindWndPtr(hwnd);
-
-    GetClientRect(hwnd, &rc);
+    GetClientRect( wndPtr->hwndSelf, &rc);
     
     switch (wndPtr->dwStyle & 0x0f)
     {
@@ -282,19 +278,19 @@
 }
 
 
-static void PaintIconfn( HWND hwnd, HDC hdc )
+static void STATIC_PaintIconfn( WND *wndPtr, HDC hdc )
 {
     RECT 	rc;
     HBRUSH      hbrush;
-    WND *wndPtr = WIN_FindWndPtr(hwnd);
     STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
 
-    GetClientRect(hwnd, &rc);
+    GetClientRect( wndPtr->hwndSelf, &rc);
 #ifdef WINELIB32
-    hbrush = SendMessage( GetParent(hwnd), WM_CTLCOLORSTATIC, hdc, hwnd );
+    hbrush = SendMessage( GetParent(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
+                          hdc, wndPtr->hwndSelf );
 #else
-    hbrush = SendMessage( GetParent(hwnd), WM_CTLCOLOR, hdc,
-                          MAKELONG(hwnd, CTLCOLOR_STATIC));
+    hbrush = SendMessage( GetParent(wndPtr->hwndSelf), WM_CTLCOLOR, hdc,
+                          MAKELONG(wndPtr->hwndSelf, CTLCOLOR_STATIC));
 #endif
     FillRect( hdc, &rc, hbrush );
     if (infoPtr->hIcon) DrawIcon( hdc, rc.left, rc.top, infoPtr->hIcon );
diff --git a/debugger/break.c b/debugger/break.c
index 78e4cc6..edbddb8 100644
--- a/debugger/break.c
+++ b/debugger/break.c
@@ -7,6 +7,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/types.h>
 #include <sys/mman.h>
 #include "windows.h"
 #include "debugger.h"
diff --git a/debugger/dbg.y b/debugger/dbg.y
index 206247b..b1ae0e4 100644
--- a/debugger/dbg.y
+++ b/debugger/dbg.y
@@ -10,6 +10,7 @@
 #include <signal.h>
 #include <unistd.h>
 #include "class.h"
+#include "module.h"
 #include "options.h"
 #include "queue.h"
 #include "win.h"
@@ -38,7 +39,7 @@
 
 %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK
 %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tDEFINE tABORT
-%token tCLASS tSTACK tSEGMENTS tREGS tWND tQUEUE 
+%token tCLASS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE 
 %token tNO_SYMBOL tEOL
 %token tSYMBOLFILE
 
@@ -129,6 +130,7 @@
 info_command:
       tINFO tBREAK tEOL         { DEBUG_InfoBreakpoints(); }
     | tINFO tCLASS expr tEOL    { CLASS_DumpClass( $3 ); }
+    | tINFO tMODULE expr tEOL   { MODULE_DumpModule( $3 ); }
     | tINFO tQUEUE expr tEOL    { QUEUE_DumpQueue( $3 ); }
     | tINFO tREGS tEOL          { DEBUG_InfoRegisters(); }
     | tINFO tSEGMENTS expr tEOL { LDT_Print( SELECTOR_TO_ENTRY($3), 1 ); }
@@ -138,6 +140,7 @@
 
 walk_command:
       tWALK tCLASS tEOL         { CLASS_WalkClasses(); }
+    | tWALK tMODULE tEOL        { MODULE_WalkModules(); }
     | tWALK tQUEUE tEOL         { QUEUE_WalkQueues(); }
     | tWALK tWND tEOL           { WIN_WalkWindows( 0, 0 ); }
     | tWALK tWND tNUM tEOL      { WIN_WalkWindows( $3, 0 ); }
diff --git a/debugger/debug.l b/debugger/debug.l
index abacf8e..0806e05 100644
--- a/debugger/debug.l
+++ b/debugger/debug.l
@@ -94,6 +94,7 @@
 x				{ return tEXAM; }
 
 class|clas|cla                  { return tCLASS; }
+module|modul|modu|mod           { return tMODULE; }
 queue|queu|que			{ return tQUEUE; }
 registers|regs|reg|re		{ return tREGS; }
 segments|segment|segm|seg|se	{ return tSEGMENTS; }
diff --git a/files/dos_fs.c b/files/dos_fs.c
index 2b736ca..6565361 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -13,7 +13,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <time.h>
-#ifdef __svr4__
+#if defined(__svr4__) || defined(_SCO_DS)
 #include <sys/statfs.h>
 #endif
 
diff --git a/files/drive.c b/files/drive.c
index 648faf5..948f9b6 100644
--- a/files/drive.c
+++ b/files/drive.c
@@ -18,7 +18,7 @@
 #include <sys/mount.h>
 #include <sys/errno.h>
 #endif
-#ifdef __svr4__
+#if defined(__svr4__) || defined(_SCO_DS)
 #include <sys/statfs.h>
 #endif
 
@@ -437,7 +437,7 @@
         return 0;
     }
 
-#ifdef __svr4__
+#if defined(__svr4__) || defined(_SCO_DS)
     if (statfs( DOSDrives[drive].root, &info, 0, 0) < 0)
 #else
     if (statfs( DOSDrives[drive].root, &info) < 0)
@@ -449,7 +449,7 @@
     }
 
     *size = info.f_bsize * info.f_blocks;
-#ifdef __svr4__
+#if defined(__svr4__) || defined(_SCO_DS)
     *available = info.f_bfree * info.f_bsize;
 #else
     *available = info.f_bavail * info.f_bsize;
diff --git a/if1632/Makefile.in b/if1632/Makefile.in
index 311fcab..d55fe40 100644
--- a/if1632/Makefile.in
+++ b/if1632/Makefile.in
@@ -50,10 +50,11 @@
 
 ASM_SRCS = \
 	$(SPEC_FILES) \
-	call16.S \
-	call32.S \
-	except.S \
-	stdcall.S
+	callfrom16.S \
+	callfrom32.S \
+	callto16.S \
+	callto32.S \
+	except.S
 
 .SUFFIXES: .spec
 
@@ -69,16 +70,19 @@
 $(BUILD) checkbuild:
 	cd $(TOPSRC)/tools; $(SUBMAKE) build
 
-call16.S: $(TOPSRC)/include/callback.h $(BUILD)
-	$(BUILD) -call16 `cat $(TOPSRC)/include/callback.h | grep "extern.*CallTo16_" | sed 's/.*CallTo16_\(.*\)(.*/\1/' | sort | uniq` > call16.S
+callfrom16.S: $(SPEC_FILES)
+	$(BUILD) -callfrom16 `cat $(SPEC_FILES) | grep CallFrom16_ | sed 's/.*CallFrom16_\(.*\)/\1/' | sort | uniq` > callfrom16.S
 
-call32.S: $(SPEC_FILES)
-	$(BUILD) -call32 `cat $(SPEC_FILES) | grep CallTo32_ | sed 's/.*CallTo32_\(.*\)/\1/' | sort | uniq` > call32.S
+callfrom32.S: $(SPEC_FILES)
+	$(BUILD) -callfrom32 `cat $(SPEC_FILES) | grep CallFrom32_ | sed 's/.*CallFrom32_\([0-9]*\)/\1/' | sort | uniq` > callfrom32.S
 
-stdcall.S: $(SPEC_FILES)
-	$(BUILD) -stdcall `cat $(SPEC_FILES) | grep Stdcall_ | sed 's/.*Stdcall_\([0-9]*\)/\1/' | sort | uniq` > stdcall.S
+callto16.S: $(TOPSRC)/include/callback.h $(BUILD)
+	$(BUILD) -callto16 `cat $(TOPSRC)/include/callback.h | grep "extern.*CallTo16_" | sed 's/.*CallTo16_\(.*\)(.*/\1/' | sort | uniq` > callto16.S
+
+callto32.S: $(TOPSRC)/include/callback.h $(BUILD)
+	$(BUILD) -callto32 `cat $(TOPSRC)/include/callback.h | grep "extern.*CallTo32_" | sed 's/.*CallTo32_\(.*\)(.*/\1/' | sort | uniq` > callto32.S
 
 clean::
-	rm -f $(SPEC_FILES) call32.S call16.S stdcall.S
+	rm -f $(SPEC_FILES) callfrom16.S callfrom32.S callto16.S callto32.S
 
 ### Dependencies:
diff --git a/if1632/callback.c b/if1632/callback.c
index 7d22b17..91e91e2 100644
--- a/if1632/callback.c
+++ b/if1632/callback.c
@@ -39,8 +39,7 @@
         fprintf(stderr,"Where is the Win32 callback?\n");
     if (UsesLParamPtr(message))
 	return RELAY32_CallWindowProcConvStruct(a->win32,hwnd,message,wParam,lParam);
-    else
-	return RELAY32_CallWindowProc(a->win32,hwnd,message,wParam,lParam);
+    return CallWndProc32( (FARPROC)a->win32, hwnd, message, wParam, lParam );
 }
 
 /**********************************************************************
diff --git a/if1632/except.S b/if1632/except.S
index 60cd710..2b522ca 100644
--- a/if1632/except.S
+++ b/if1632/except.S
@@ -4,17 +4,20 @@
  * Copyright (c) 1996 Onno Hovers, (onno@stack.urc.tue.nl)
  *
  */
+#if defined(__svr4__) || defined(_SCO_DS)
+#define __ELF__ 1
+#endif
 
 #ifndef __ELF__
+
      .globl _EXC_CallUnhandledExceptionFilter
-     .extern _pTopExcHandler
-
  _EXC_CallUnhandledExceptionFilter:
-#else  /* __ELF__ */
-     .globl EXC_CallUnhandledExceptionFilter
-     .extern pTopExcHandler
 
+#else  /* __ELF__ */
+
+     .globl EXC_CallUnhandledExceptionFilter
  EXC_CallUnhandledExceptionFilter:
+
 #endif  /* __ELF__ */
      leal   4(%esp),%eax
      pushl  %eax
@@ -45,56 +48,55 @@
  * we pass the function to be called as a fifth parameter to ContextCall
  *
  */
-       .equ CONTEXT_SegSs,        -4
-       .equ CONTEXT_Esp,          -8
-       .equ CONTEXT_EFlags,       -12
-       .equ CONTEXT_SegCs,        -16
-       .equ CONTEXT_Eip,          -20
-       .equ CONTEXT_Ebp,          -24
-       .equ CONTEXT_Eax,          -28
-       .equ CONTEXT_Ecx,          -32
-       .equ CONTEXT_Edx,          -36
-       .equ CONTEXT_Ebx,          -40
-       .equ CONTEXT_Esi,          -44
-       .equ CONTEXT_Edi,          -48
-       .equ CONTEXT_SegDs,        -52
-       .equ CONTEXT_SegEs,        -56
-       .equ CONTEXT_SegFs,        -60
-       .equ CONTEXT_SegGs,        -64
-       .equ FLOAT_Cr0NpxState,    -68
-       .equ FLOAT_RegisterArea,   -148
-       .equ FLOAT_DataSelector,   -152
-       .equ FLOAT_DataOffset,     -156
-       .equ FLOAT_ErrorSelector,  -160
-       .equ FLOAT_ErrorOffset,    -164
-       .equ FLOAT_TagWord,        -168
-       .equ FLOAT_StatusWord,     -172
-       .equ FLOAT_ControlWord,    -176
-       .equ CONTEXT_FloatSave,    -176
-       .equ CONTEXT_Dr7,          -180
-       .equ CONTEXT_Dr6,          -184
-       .equ CONTEXT_Dr3,          -188
-       .equ CONTEXT_Dr2,          -192
-       .equ CONTEXT_Dr1,          -196
-       .equ CONTEXT_Dr0,          -200
-       .equ CONTEXT_ContextFlags, -204
-       .equ CONTEXT,              -204
-       .equ CONTEXTSIZE,           204
-       .equ CONTEXTFLAGS,          0x10007
+#define CONTEXT_SegSs        -4
+#define CONTEXT_Esp          -8
+#define CONTEXT_EFlags       -12
+#define CONTEXT_SegCs        -16
+#define CONTEXT_Eip          -20
+#define CONTEXT_Ebp          -24
+#define CONTEXT_Eax          -28
+#define CONTEXT_Ecx          -32
+#define CONTEXT_Edx          -36
+#define CONTEXT_Ebx          -40
+#define CONTEXT_Esi          -44
+#define CONTEXT_Edi          -48
+#define CONTEXT_SegDs        -52
+#define CONTEXT_SegEs        -56
+#define CONTEXT_SegFs        -60
+#define CONTEXT_SegGs        -64
+#define FLOAT_Cr0NpxState    -68
+#define FLOAT_RegisterArea   -148
+#define FLOAT_DataSelector   -152
+#define FLOAT_DataOffset     -156
+#define FLOAT_ErrorSelector  -160
+#define FLOAT_ErrorOffset    -164
+#define FLOAT_TagWord        -168
+#define FLOAT_StatusWord     -172
+#define FLOAT_ControlWord    -176
+#define CONTEXT_FloatSave    -176
+#define CONTEXT_Dr7          -180
+#define CONTEXT_Dr6          -184
+#define CONTEXT_Dr3          -188
+#define CONTEXT_Dr2          -192
+#define CONTEXT_Dr1          -196
+#define CONTEXT_Dr0          -200
+#define CONTEXT_ContextFlags -204
+#define CONTEXT              -204
+#define CONTEXTSIZE           204
+#define CONTEXTFLAGS          0x10007
 
-       .equ ORIG_ESP,              16         /** cdecl !!! **/
-       .equ PARM_ARG4,             28
-       .equ PARM_ARG3,             24
-       .equ PARM_ARG2,             20
-       .equ PARM_ARG1,             16
-       .equ PARM_RETURN,           12
-       .equ PARM_CALLFUNC,         8
-       .equ PARM_EBP,              4
-       .equ PARM_EFLAGS,           0
+#define ORIG_ESP              16         /** cdecl !!! **/
+#define PARM_ARG4             28
+#define PARM_ARG3             24
+#define PARM_ARG2             20
+#define PARM_ARG1             16
+#define PARM_RETURN           12
+#define PARM_CALLFUNC         8
+#define PARM_EBP              4
+#define PARM_EFLAGS           0
 
 #ifndef __ELF__
 	.globl _RaiseException
-        .extern _EXC_RaiseException
 
  _RaiseException:
        push   $_EXC_RaiseException
@@ -107,7 +109,6 @@
 
 #else  /* __ELF__ */
        .globl RaiseException
-       .extern EXC_RaiseException
 
  RaiseException:
        push   $EXC_RaiseException
diff --git a/if1632/relay.c b/if1632/relay.c
index c3960ba..9daacc1 100644
--- a/if1632/relay.c
+++ b/if1632/relay.c
@@ -25,43 +25,59 @@
 
 BUILTIN_DLL dll_builtin_table[] =
 {
-    DLL_ENTRY( KERNEL,   0),
-    DLL_ENTRY( USER,     0),
-    DLL_ENTRY( GDI,      0),
-    DLL_ENTRY( WIN87EM,  DLL_FLAG_NOT_USED),
-    DLL_ENTRY( SHELL,    0),
-    DLL_ENTRY( SOUND,    0),
-    DLL_ENTRY( KEYBOARD, 0),
-    DLL_ENTRY( WINSOCK,  0),
-    DLL_ENTRY( STRESS,   0),
-    DLL_ENTRY( MMSYSTEM, 0),
-    DLL_ENTRY( SYSTEM,   0),
-    DLL_ENTRY( TOOLHELP, 0),
-    DLL_ENTRY( MOUSE,    0),
-    DLL_ENTRY( COMMDLG,  DLL_FLAG_NOT_USED),
-    DLL_ENTRY( OLE2,     DLL_FLAG_NOT_USED),
-    DLL_ENTRY( OLE2CONV, DLL_FLAG_NOT_USED),
-    DLL_ENTRY( OLE2DISP, DLL_FLAG_NOT_USED),
-    DLL_ENTRY( OLE2NLS,  DLL_FLAG_NOT_USED),
-    DLL_ENTRY( OLE2PROX, DLL_FLAG_NOT_USED),
-    DLL_ENTRY( OLECLI,   DLL_FLAG_NOT_USED),
-    DLL_ENTRY( OLESVR,   DLL_FLAG_NOT_USED),
-    DLL_ENTRY( COMPOBJ,  DLL_FLAG_NOT_USED),
-    DLL_ENTRY( STORAGE,  DLL_FLAG_NOT_USED),
-    DLL_ENTRY( WINPROCS, 0),
-    DLL_ENTRY( DDEML,    DLL_FLAG_NOT_USED),
-    DLL_ENTRY( LZEXPAND, 0),
-    { NULL, }  /* Last entry */
+    /* Win16 DLLs */
+    DLL_ENTRY( KERNEL,     DLL_FLAG_ALWAYS_USED),
+    DLL_ENTRY( USER,       DLL_FLAG_ALWAYS_USED),
+    DLL_ENTRY( GDI,        DLL_FLAG_ALWAYS_USED),
+    DLL_ENTRY( WIN87EM,    DLL_FLAG_NOT_USED),
+    DLL_ENTRY( SHELL,      0),
+    DLL_ENTRY( SOUND,      0),
+    DLL_ENTRY( KEYBOARD,   0),
+    DLL_ENTRY( WINSOCK,    0),
+    DLL_ENTRY( STRESS,     0),
+    DLL_ENTRY( MMSYSTEM,   0),
+    DLL_ENTRY( SYSTEM,     0),
+    DLL_ENTRY( TOOLHELP,   0),
+    DLL_ENTRY( MOUSE,      0),
+    DLL_ENTRY( COMMDLG,    DLL_FLAG_NOT_USED),
+    DLL_ENTRY( OLE2,       DLL_FLAG_NOT_USED),
+    DLL_ENTRY( OLE2CONV,   DLL_FLAG_NOT_USED),
+    DLL_ENTRY( OLE2DISP,   DLL_FLAG_NOT_USED),
+    DLL_ENTRY( OLE2NLS,    DLL_FLAG_NOT_USED),
+    DLL_ENTRY( OLE2PROX,   DLL_FLAG_NOT_USED),
+    DLL_ENTRY( OLECLI,     DLL_FLAG_NOT_USED),
+    DLL_ENTRY( OLESVR,     DLL_FLAG_NOT_USED),
+    DLL_ENTRY( COMPOBJ,    DLL_FLAG_NOT_USED),
+    DLL_ENTRY( STORAGE,    DLL_FLAG_NOT_USED),
+    DLL_ENTRY( WINPROCS,   DLL_FLAG_ALWAYS_USED),
+    DLL_ENTRY( DDEML,      DLL_FLAG_NOT_USED),
+    DLL_ENTRY( LZEXPAND,   0),
+    /* Win32 DLLs */
+    DLL_ENTRY( ADVAPI32,   0),
+    DLL_ENTRY( COMCTL32,   0),
+    DLL_ENTRY( COMDLG32,   0),
+    DLL_ENTRY( OLE32,      0),
+    DLL_ENTRY( GDI32,      0),
+    DLL_ENTRY( KERNEL32,   DLL_FLAG_ALWAYS_USED),
+    DLL_ENTRY( SHELL32,    0),
+    DLL_ENTRY( USER32,     0),
+    DLL_ENTRY( WINPROCS32, DLL_FLAG_ALWAYS_USED),
+    DLL_ENTRY( WINSPOOL,   0),
+    /* Last entry */
+    { NULL, }
 };
 
-  /* Saved 16-bit stack */
+  /* Saved 16-bit stack for current process (Win16 only) */
 WORD IF1632_Saved16_ss = 0;
 WORD IF1632_Saved16_sp = 0;
 
-  /* Saved 32-bit stack */
+  /* Saved 32-bit stack for current process (Win16 only) */
 DWORD IF1632_Saved32_esp = 0;
 SEGPTR IF1632_Stack32_base = 0;
-DWORD IF1632_Original32_esp = 0;
+
+  /* Original Unix stack */
+DWORD IF1632_Original32_esp;
+
 
 /***********************************************************************
  *           RELAY_Init
@@ -72,20 +88,20 @@
 
       /* Allocate the code selector for CallTo16 routines */
 
-    extern void CALL16_Start(), CALL16_End();
-    extern void CALL16_Ret_word(), CALL16_Ret_long();
-    extern DWORD CALL16_RetAddr_word, CALL16_RetAddr_long;
+    extern void CALLTO16_Start(), CALLTO16_End();
+    extern void CALLTO16_Ret_word(), CALLTO16_Ret_long();
+    extern DWORD CALLTO16_RetAddr_word, CALLTO16_RetAddr_long;
 
-    codesel = GLOBAL_CreateBlock( GMEM_FIXED, (void *)CALL16_Start,
-                                   (int)CALL16_End - (int)CALL16_Start,
+    codesel = GLOBAL_CreateBlock( GMEM_FIXED, (void *)CALLTO16_Start,
+                                   (int)CALLTO16_End - (int)CALLTO16_Start,
                                    0, TRUE, TRUE, FALSE, NULL );
     if (!codesel) return FALSE;
 
       /* Patch the return addresses for CallTo16 routines */
 
-    CALL16_RetAddr_word = MAKELONG( (int)CALL16_Ret_word - (int)CALL16_Start,
+    CALLTO16_RetAddr_word=MAKELONG( (int)CALLTO16_Ret_word-(int)CALLTO16_Start,
                                     codesel );
-    CALL16_RetAddr_long = MAKELONG( (int)CALL16_Ret_long - (int)CALL16_Start,
+    CALLTO16_RetAddr_long=MAKELONG( (int)CALLTO16_Ret_long-(int)CALLTO16_Start,
                                     codesel );
 
     return TRUE;
@@ -93,10 +109,10 @@
 
 
 /***********************************************************************
- *           RELAY_DebugCall32
+ *           RELAY_DebugCallFrom16
  */
-void RELAY_DebugCall32( int func_type, char *args,
-                        void *entry_point, int args32 )
+void RELAY_DebugCallFrom16( int func_type, char *args,
+                            void *entry_point, int args32 )
 {
     STACK16FRAME *frame;
     struct dll_table_s *table;
@@ -162,9 +178,9 @@
 
 
 /***********************************************************************
- *           RELAY_DebugReturn
+ *           RELAY_DebugCallFrom16Ret
  */
-void RELAY_DebugReturn( int func_type, int ret_val, int args32 )
+void RELAY_DebugCallFrom16Ret( int func_type, int ret_val, int args32 )
 {
     STACK16FRAME *frame;
     struct dll_table_s *table;
@@ -230,7 +246,7 @@
  *
  * This function is called for unimplemented 32-bit entry points (declared
  * as 'stub' in the spec file).
- * (The args are the same than for RELAY_DebugStdcall).
+ * (The args are the same than for RELAY_DebugCallFrom32).
  */
 void RELAY_Unimplemented32( int nb_args, void *entry_point,
                             const char *func_name )
@@ -241,7 +257,7 @@
 
 
 /***********************************************************************
- *           RELAY_DebugCall16
+ *           RELAY_DebugCallTo16
  *
  * 'stack' points to the called function address on the 32-bit stack.
  * Stack layout:
@@ -251,7 +267,7 @@
  * (stack+4)   16-bit ds
  * (stack)     func to call
  */
-void RELAY_DebugCall16( int* stack, int nbargs )
+void RELAY_DebugCallTo16( int* stack, int nbargs )
 {
     if (!debugging_relay) return;
 
@@ -264,10 +280,11 @@
 
 
 /***********************************************************************
- *           RELAY_DebugStdcall
+ *           RELAY_DebugCallFrom32
  */
-void RELAY_DebugStdcall( int nb_args, void *entry_point, const char *func_name,
-                         int ebp, int ret_addr, int arg1 )
+void RELAY_DebugCallFrom32( int nb_args, void *entry_point,
+                            const char *func_name, int ebp, int ret_addr,
+                            int arg1 )
 {
     int  *parg;
     if (!debugging_relay) return;
@@ -282,12 +299,28 @@
 
 
 /***********************************************************************
- *           RELAY_DebugStdcallRet
+ *           RELAY_DebugCallFrom32Ret
  */
-void RELAY_DebugStdcallRet( int ret_val, void *entry_point,
-                            const char *func_name, int ebp, int ret_addr )
+void RELAY_DebugCallFrom32Ret( int ret_val, void *entry_point,
+                               const char *func_name, int ebp, int ret_addr )
 {
     if (!debugging_relay) return;
     printf( "Ret  %s() retval=0x%08x ret=%08x\n",
             func_name, ret_val, ret_addr );
 }
+
+
+/***********************************************************************
+ *           RELAY_DebugCallTo32
+ */
+void RELAY_DebugCallTo32( unsigned int func, int nbargs, unsigned int arg1  )
+{
+    unsigned int *argptr;
+
+    if (!debugging_relay) return;
+
+    printf( "CallTo32(func=%08x", func );
+    for (argptr = &arg1; nbargs; nbargs--, argptr++)
+        printf( ",%08x", *argptr );
+    printf( ")\n" );
+}
diff --git a/if1632/relay32.c b/if1632/relay32.c
index 418f1cc..14d98a4 100644
--- a/if1632/relay32.c
+++ b/if1632/relay32.c
@@ -11,10 +11,10 @@
 #include <unistd.h>
 #include <errno.h>
 #include "windows.h"
+#include "callback.h"
 #include "dlls.h"
 #include "module.h"
 #include "neexe.h"
-#include "pe_image.h"
 #include "peexe.h"
 #include "relay32.h"
 #include "struct32.h"
@@ -24,116 +24,57 @@
 #include "stddebug.h"
 #include "debug.h"
 
-#define DLL_ENTRY(name) \
-  { #name, (WIN32_function *)name##_Module_Start, \
-    (WIN32_function *)name##_Module_End, (int *)name##_Data_Start, NULL }
-
-static WIN32_builtin WIN32_builtin_list[] =
+typedef struct
 {
-    DLL_ENTRY(ADVAPI32),
-    DLL_ENTRY(COMCTL32),
-    DLL_ENTRY(COMDLG32),
-    DLL_ENTRY(OLE32),
-    DLL_ENTRY(GDI32),
-    DLL_ENTRY(KERNEL32),
-    DLL_ENTRY(SHELL32),
-    DLL_ENTRY(USER32),
-    DLL_ENTRY(WINPROCS32),
-    DLL_ENTRY(WINSPOOL)
-};
+    char *name;
+    void *definition;
+} WIN32_function;
 
-#define NB_DLLS (sizeof(WIN32_builtin_list)/sizeof(WIN32_builtin_list[0]))
-
-static void RELAY32_MakeFakeModule(WIN32_builtin*dll);
-
-int RELAY32_Init(void)
+typedef struct
 {
+    int base;
+    int size;
+    WIN32_function functions[1];
+} WIN32_DLL_INFO;
+
+
+void *RELAY32_GetEntryPoint(BUILTIN_DLL *dll, char *item, int hint)
+{
+    const WIN32_DLL_INFO *info = (const WIN32_DLL_INFO *)dll->data_start;
     int i;
 
-    for (i = 0; i < NB_DLLS; i++)
-        RELAY32_MakeFakeModule( &WIN32_builtin_list[i] );
+    dprintf_module(stddeb, "Looking for %s in %s, hint %x\n",
+                   item ? item: "(no name)", dll->name, hint);
+    if(!dll) return 0;
 
-    /* Why should it fail, anyways? */
-    return 1;
-}
+    /* import by ordinal */
+    if(!item)
+    {
+        if(hint && hint < info->size)
+            return info->functions[hint - info->base].definition;
+        return 0;
+    }
 
-WIN32_builtin *RELAY32_GetBuiltinDLL(char *name)
-{
-	WIN32_builtin *it;
-	size_t len;
-	char *cp;
-        int i;
+    /* hint is correct */
+    if (hint && hint < info->size && 
+        info->functions[hint].name &&
+        strcmp(item,info->functions[hint].name)==0)
+        return info->functions[hint].definition;
 
-	len = (cp=strchr(name,'.')) ? (cp-name) : strlen(name);
-	for(i = NB_DLLS, it = WIN32_builtin_list; (i > 0); i--, it++)
-            if (!lstrncmpi(name,it->name,len)) return it;
-	return NULL;
-}
+    /* hint is incorrect, search for name */
+    for(i=0;i < info->size;i++)
+        if (info->functions[i].name && !strcmp(item,info->functions[i].name))
+            return info->functions[i].definition;
 
-void RELAY32_Unimplemented(char *dll, int item)
-{
-	WIN32_builtin *Dll;
-	fprintf( stderr, "No handler for routine %s.%d", dll, item);
-	Dll=RELAY32_GetBuiltinDLL(dll);
-	if(Dll && Dll->functions[item].name)
-		fprintf(stderr, "(%s?)\n", Dll->functions[item].name);
-	else
-		fprintf(stderr, "\n");
-	fflush(stderr);
-	exit(1);
-}
-
-void *RELAY32_GetEntryPoint(WIN32_builtin *dll, char *item, int hint)
-{
-	int i, size;
-
-	dprintf_module(stddeb, "Looking for %s in %s, hint %x\n",
-		item ? item: "(no name)", dll->name, hint);
-	if(!dll)
-		return 0;
-        size = (int)(dll->last_func - dll->functions);
-
-	/* import by ordinal */
-	if(!item){
-		if(hint && hint < size)
-			return dll->functions[hint - *dll->base].definition;
-		return 0;
-	}
-	/* hint is correct */
-	if(hint && hint < size && 
-		dll->functions[hint].name &&
-		strcmp(item,dll->functions[hint].name)==0)
-		return dll->functions[hint].definition;
-	/* hint is incorrect, search for name */
-	for(i=0;i < size;i++)
-            if (dll->functions[i].name && !strcmp(item,dll->functions[i].name))
-                return dll->functions[i].definition;
-
-	/* function at hint has no name (unimplemented) */
-	if(hint && hint < size && !dll->functions[hint].name)
-	{
-		dll->functions[hint].name=xstrdup(item);
-		dprintf_module(stddeb, "Returning unimplemented function %s.%d\n",
-			dll->name,hint);
-		return dll->functions[hint].definition;
-	}
-	return 0;
-}
-
-LONG RELAY32_CallWindowProc( WNDPROC func, int hwnd, int message,
-             int wParam, int lParam )
-{
-	int ret;
-	__asm__ (
-		"push %1;"
-		"push %2;"
-		"push %3;"
-		"push %4;"
-		"call %5;"
-		: "=a" (ret)
-		: "g" (lParam), "g" (wParam), "g" (message), "g" (hwnd), "g" (func)
-	);
-	return ret;
+    /* function at hint has no name (unimplemented) */
+    if(hint && hint < info->size && !info->functions[hint].name)
+    {
+/*        info->functions[hint].name=xstrdup(item); */
+        dprintf_module(stddeb,"Returning unimplemented function %s.%d (%s?)\n",
+                       dll->name,hint,item);
+        return info->functions[hint].definition;
+    }
+    return 0;
 }
 
 LONG RELAY32_CallWindowProcConvStruct( WNDPROC func, int hwnd, int message,
@@ -149,18 +90,18 @@
 	LONG result;
 	void *lParam;
 	if(!lParam16)
-		return RELAY32_CallWindowProc(func,hwnd,message,wParam,(int)lParam16);
+		return CallWndProc32(func,hwnd,message,wParam,(int)lParam16);
 	lParam = PTR_SEG_TO_LIN(lParam16);
 	switch(message) {
 		case WM_GETMINMAXINFO:
 			STRUCT32_MINMAXINFO16to32(lParam,&st.mmi);
-			result=RELAY32_CallWindowProc(func,hwnd,message,wParam,(int)&st.mmi);
+			result=CallWndProc32(func,hwnd,message,wParam,(int)&st.mmi);
 			STRUCT32_MINMAXINFO32to16(&st.mmi,lParam);
 			return result;
 		case WM_WINDOWPOSCHANGING:
 		case WM_WINDOWPOSCHANGED:
 			STRUCT32_WINDOWPOS16to32(lParam,&wp);
-			result=RELAY32_CallWindowProc(func,hwnd,message,wParam,(int)&wp);
+			result=CallWndProc32(func,hwnd,message,wParam,(int)&wp);
 			STRUCT32_WINDOWPOS32to16(&wp,lParam);
 			return result;
 		case WM_NCCALCSIZE:
@@ -170,7 +111,7 @@
 				st.nccs.lppos=&wp;
 			} else
 				st.nccs.lppos= 0;
-			result=RELAY32_CallWindowProc(func,hwnd,message,wParam,(int)&st.nccs);
+			result=CallWndProc32(func,hwnd,message,wParam,(int)&st.nccs);
 			STRUCT32_NCCALCSIZE32to16Flat(&st.nccs,lParam);
 			if(((NCCALCSIZE_PARAMS*)lParam)->lppos)
 				STRUCT32_WINDOWPOS32to16(&wp,((NCCALCSIZE_PARAMS*)lParam)->lppos);
@@ -182,7 +123,7 @@
 				PTR_SEG_TO_LIN(lpcs->lpszName) : (char*)lpcs->lpszName;
 			st.cs.lpszClass = HIWORD(lpcs->lpszClass) ? 
 				PTR_SEG_TO_LIN(lpcs->lpszClass) : (char*)lpcs->lpszClass;
-			result=RELAY32_CallWindowProc(func,hwnd,message,wParam,(int)&st.cs);
+			result=CallWndProc32(func,hwnd,message,wParam,(int)&st.cs);
 			STRUCT32_CREATESTRUCT32to16(&st.cs,lParam);
 			lpcs->lpszName = HIWORD(st.cs.lpszName) ? 
 				MAKE_SEGPTR(st.cs.lpszName) : (SEGPTR)st.cs.lpszName;
@@ -191,71 +132,9 @@
 			return result;
 		case WM_GETTEXT:
 		case WM_SETTEXT:
-			return RELAY32_CallWindowProc(func,hwnd,message,wParam,(int)lParam);
+			return CallWndProc32(func,hwnd,message,wParam,(int)lParam);
 		default:
 			fprintf(stderr,"No conversion function for message %d\n",message);
 	}
-	return RELAY32_CallWindowProc(func,hwnd,message,wParam,(int)lParam);
+	return CallWndProc32(func,hwnd,message,wParam,(int)lParam);
 }
-
-static void RELAY32_MakeFakeModule(WIN32_builtin*dll)
-{
-	NE_MODULE *pModule;
-	struct w_files *wpnt;
-	int size;
-	HMODULE hModule;
-	OFSTRUCT *pFileInfo;
-	char *pStr;
-	wpnt=xmalloc(sizeof(struct w_files));
-	wpnt->hinstance=0;
-	wpnt->hModule=0;
-	wpnt->initialised=1;
-	wpnt->mz_header=wpnt->pe=0;
-	size=sizeof(NE_MODULE) +
-		/* loaded file info */
-		sizeof(*pFileInfo) - sizeof(pFileInfo->szPathName) +
-                strlen(dll->name) + 1 +
-		/* name table */
-		12 +
-		/* several empty tables */
-		8;
-	hModule = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, size );
-	wpnt->hModule = hModule;
-	FarSetOwner( hModule, hModule );
-	pModule = (NE_MODULE*)GlobalLock(hModule);
-	/* Set all used entries */
-	pModule->magic=NE_SIGNATURE;
-	pModule->count=1;
-	pModule->next=0;
-	pModule->flags=NE_FFLAGS_WIN32;
-	pModule->dgroup=0;
-	pModule->ss=0;
-	pModule->cs=0;
-	pModule->heap_size=0;
-	pModule->stack_size=0;
-	pModule->seg_count=0;
-	pModule->modref_count=0;
-	pModule->nrname_size=0;
-	pModule->seg_table=0;
-	pModule->fileinfo=sizeof(NE_MODULE);
-	pModule->os_flags=NE_OSFLAGS_WINDOWS;
-	pModule->expected_version=0x30A;
-	pFileInfo=(OFSTRUCT *)(pModule + 1);
-	pFileInfo->cBytes = sizeof(*pFileInfo) - sizeof(pFileInfo->szPathName)
-                            + strlen(dll->name);
-	strcpy( pFileInfo->szPathName, dll->name );
-	pStr = ((char*)pFileInfo) + pFileInfo->cBytes + 1;
-	pModule->name_table=(int)pStr-(int)pModule;
-	*pStr=strlen(dll->name);
-	strcpy(pStr+1,dll->name);
-	pStr += *pStr+1;
-	pModule->res_table=pModule->import_table=pModule->entry_table=
-		(int)pStr-(int)pModule;
-	MODULE_RegisterModule(hModule);
-	wpnt->builtin=dll;
-	wpnt->next=wine_files;
-	wine_files=wpnt;
-}
-
-
-
diff --git a/include/callback.h b/include/callback.h
index 2a33b6f..3eb529b 100644
--- a/include/callback.h
+++ b/include/callback.h
@@ -12,11 +12,12 @@
 
 #include "stackframe.h"
 
-extern int CallTo32_LargeStack( int (*func)(), int nbargs, ... );
+extern
+int CallTo32_LargeStack( int (*func)(), int nbargs, ... );
 
 
 /* List of the 16-bit callback functions. This list is used  */
-/* by the build program to generate the file if1632/call16.S */
+/* by the build program to generate the file if1632/callto16.S */
 
                                /* func     ds    parameters */
 extern WORD CallTo16_word_     ( FARPROC, WORD );
@@ -68,6 +69,22 @@
 #define CallWordBreakProc( func, lpch, ichCurrent, cch, code ) \
     CallTo16_word_lwww( func, CURRENT_DS, lpch, ichCurrent, cch, code )
 
+
+/* List of the 32-bit callback functions. This list is used  */
+/* by the build program to generate the file if1632/callto32.S */
+
+extern LONG CallTo32_0( FARPROC );
+extern LONG CallTo32_3( FARPROC, DWORD, DWORD, DWORD );
+extern LONG CallTo32_4( FARPROC, DWORD, DWORD, DWORD, DWORD );
+
+#define CallTaskStart32( func ) \
+    CallTo32_0( func )
+#define CallDLLEntryProc32( func, hmodule, a, b ) \
+    CallTo32_3( func, hmodule, a, b )
+#define CallWndProc32( func, hwnd, msg, wParam, lParam ) \
+    CallTo32_4( func, hwnd, msg, wParam, lParam )
+
+
 #else  /* WINELIB */
 
 #define CallEnumChildProc( func, hwnd, lParam ) \
diff --git a/include/debugger.h b/include/debugger.h
index 42b4206..1f1a7af 100644
--- a/include/debugger.h
+++ b/include/debugger.h
@@ -40,6 +40,10 @@
       DEBUG_PrintAddress(addr,dbg_mode), \
       fprintf(stderr,"\n"),0))
 
+#ifdef REG_SP  /* Some Sun includes define this */
+#undef REG_SP
+#endif
+
 enum debug_regs
 {
     REG_EAX, REG_EBX, REG_ECX, REG_EDX, REG_ESI,
diff --git a/include/dlls.h b/include/dlls.h
index 2e5bcbc..304b142 100644
--- a/include/dlls.h
+++ b/include/dlls.h
@@ -20,8 +20,9 @@
 } BUILTIN_DLL;
 
 /* DLL flags */
-#define DLL_FLAG_NOT_USED    1  /* Use original Windows DLL if possible */
-#define DLL_FLAG_WIN32       2  /* DLL is a Win32 DLL */
+#define DLL_FLAG_NOT_USED    0x01  /* Use original Windows DLL if possible */
+#define DLL_FLAG_ALWAYS_USED 0x02  /* Always use built-in DLL */
+#define DLL_FLAG_WIN32       0x04  /* DLL is a Win32 DLL */
 
 #define DECLARE_DLL(name) \
 extern const BYTE name##_Code_Start[]; \
diff --git a/include/local.h b/include/local.h
index 93b4cbe..d3f12f7 100644
--- a/include/local.h
+++ b/include/local.h
@@ -20,7 +20,7 @@
 extern WORD LOCAL_Size( HANDLE ds, HLOCAL handle );
 extern WORD LOCAL_Flags( HANDLE ds, HLOCAL handle );
 extern WORD LOCAL_HeapSize( HANDLE ds );
-extern NPVOID LOCAL_Lock( HANDLE ds, HLOCAL handle );
+extern LPSTR LOCAL_Lock( HANDLE ds, HLOCAL handle );
 extern BOOL LOCAL_Unlock( HANDLE ds, HLOCAL handle );
 
 #endif  /* __WINE_LOCAL_H */
diff --git a/include/module.h b/include/module.h
index bc23e1c..01561f1 100644
--- a/include/module.h
+++ b/include/module.h
@@ -51,6 +51,14 @@
     WORD    self_loading_sel; /* Selector used for self-loading apps. procs */
 } NE_MODULE;
 
+
+  /* Extra module info appended to NE_MODULE for Win32 modules */
+typedef struct
+{
+    DWORD   pe_module;
+} NE_WIN32_EXTRAINFO;
+
+
   /* In-memory segment table */
 typedef struct
 {
@@ -61,6 +69,7 @@
     HANDLE  selector;  /* Selector of segment in memory */
 } SEGTABLEENTRY;
 
+
   /* Self-loading modules contain this structure in their first segment */
 
 typedef struct
@@ -97,11 +106,17 @@
 #define NE_MODULE_NAME(pModule) \
     (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
 
+#define NE_WIN32_MODULE(pModule) \
+    ((struct pe_data *)(((pModule)->flags & NE_FFLAGS_WIN32) ? \
+                    ((NE_WIN32_EXTRAINFO *)((pModule) + 1))->pe_module : 0))
+
 #ifndef WINELIB
 #pragma pack(4)
 #endif
 
 extern BOOL MODULE_Init(void);
+extern void MODULE_DumpModule( HMODULE hmodule );
+extern void MODULE_WalkModules(void);
 extern int MODULE_OpenFile( HMODULE hModule );
 extern LPSTR MODULE_GetModuleName( HMODULE hModule );
 extern void MODULE_RegisterModule( HMODULE hModule );
diff --git a/include/pe_image.h b/include/pe_image.h
index 799392a..e97d418 100644
--- a/include/pe_image.h
+++ b/include/pe_image.h
@@ -3,6 +3,7 @@
 
 #include <sys/types.h>
 #include "windows.h"
+#include "dlls.h"
 
 struct pe_data {
 	struct pe_header_s *pe_header;
@@ -17,40 +18,7 @@
 	int resource_offset; /* offset to resource typedirectory in file */
 };
 
-typedef struct _WIN32_function{
-    char *name;
-    void *definition;
-} WIN32_function;
-
-typedef struct _WIN32_builtin{
-    char *name;
-    WIN32_function *functions;
-    WIN32_function *last_func;
-    const int *base;
-    struct _WIN32_builtin *next;
-} WIN32_builtin;
-
-struct w_files
-{
-    struct w_files  * next;
-    char * name;   /* Name, as it appears in the windows binaries */
-    char * filename; /* Actual name of the unix file that satisfies this */
-    int type;        /* DLL or EXE */
-    HINSTANCE hinstance;
-    HMODULE hModule;
-    int initialised;
-    struct mz_header_s *mz_header;
-    struct pe_data *pe;
-	OFSTRUCT ofs;
-    unsigned int load_addr;
-	WIN32_builtin* builtin;
-};
-
-
-extern int PE_unloadImage(struct w_files *wpnt);
-extern int PE_StartProgram(struct w_files *wpnt);
-extern void PE_InitDLL(HMODULE hModule);
+extern int PE_unloadImage(HMODULE hModule);
 extern void my_wcstombs(char * result, u_short * source, int len);
-extern struct w_files *wine_files;
 
 #endif /* __WINE_PE_IMAGE_H */
diff --git a/include/registers.h b/include/registers.h
index 93a9567..98f28ee 100644
--- a/include/registers.h
+++ b/include/registers.h
@@ -10,7 +10,7 @@
 #include <windows.h>
 #include "wine.h"
 
-#ifndef __svr4__
+#if !defined(__svr4__) && !defined(_SCO_DS)
 
 #define EAX_reg(context)     ((context)->sc_eax)
 #define EBX_reg(context)     ((context)->sc_ebx)
@@ -65,7 +65,11 @@
 #define SET_CFLAG(context)   (EFL_reg(context) |= 0x0001)
 #define RESET_CFLAG(context) (EFL_reg(context) &= 0xfffffffe)
 
-#else  /* __svr4__ */
+#else  /* __svr4__ || _SCO_DS */
+
+#ifdef _SCO_DS
+#define gregs regs
+#endif
 
 #define EAX_reg(context)      ((context)->uc_mcontext.gregs[EAX])
 #define EBX_reg(context)      ((context)->uc_mcontext.gregs[EBX])
@@ -122,6 +126,6 @@
 #define SET_CFLAG(context)   (EFL_reg(context) |= 0x0001)
 #define RESET_CFLAG(context) (EFL_reg(context) &= 0xfffffffe)
 
-#endif  /* __svr4__ */
+#endif  /* __svr4__ || _SCO_DS */
 
 #endif /* __WINE_REGISTERS_H */
diff --git a/include/relay32.h b/include/relay32.h
index c0cf499..06b8741 100644
--- a/include/relay32.h
+++ b/include/relay32.h
@@ -4,16 +4,13 @@
  * Copyright 1995 Martin von Loewis
  */
 
-#ifndef _RELAY32_H
-#define _RELAY32_H
-#include "pe_image.h"
+#ifndef __WINE_RELAY32_H
+#define __WINE_RELAY32_H
+
+#include "dlls.h"
 #include "struct32.h"
 
-void RELAY32_Unimplemented(char *dll, int item);
-WIN32_builtin *RELAY32_GetBuiltinDLL(char *name);
-void *RELAY32_GetEntryPoint(WIN32_builtin *dll, char *item, int hint);
-LONG RELAY32_CallWindowProc(WNDPROC,int,int,int,int);
-void RELAY32_DebugEnter(char *dll,char *name);
+void *RELAY32_GetEntryPoint(BUILTIN_DLL *dll, char *item, int hint);
 
 typedef struct tagWNDCLASSA{
 	UINT	style;
diff --git a/include/stackframe.h b/include/stackframe.h
index a9d4020..0b4451d 100644
--- a/include/stackframe.h
+++ b/include/stackframe.h
@@ -14,7 +14,7 @@
 #pragma pack(1)
 #endif
 
-  /* 16-bit stack layout after CallTo32() */
+  /* 16-bit stack layout after CallFrom16() */
 typedef struct
 {
     WORD    saved_ss;                /* saved previous 16-bit stack */
@@ -49,13 +49,15 @@
 #pragma pack(4)
 #endif
 
-  /* Saved 16-bit stack */
+  /* Saved 16-bit stack for current process (Win16 only) */
 extern WORD IF1632_Saved16_ss;
 extern WORD IF1632_Saved16_sp;
 
-  /* Saved 32-bit stack */
+  /* Saved 32-bit stack for current process (Win16 only) */
 extern DWORD IF1632_Saved32_esp;
 extern SEGPTR IF1632_Stack32_base;
+
+  /* Original Unix stack */
 extern DWORD IF1632_Original32_esp;
 
 #ifndef WINELIB
diff --git a/include/windows.h b/include/windows.h
index b823ad3..c25d916 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -2158,6 +2158,9 @@
 #define EM_SETWORDBREAKPROC    (WM_USER+32)
 #define EM_GETWORDBREAKPROC    (WM_USER+33)
 #define EM_GETPASSWORDCHAR     (WM_USER+34)
+/* Edit control undocumented messages */
+#define EM_SCROLL              (WM_USER+5)
+#define EM_GETTHUMB            (WM_USER+14)
 
 typedef int (CALLBACK *EDITWORDBREAKPROC)(LPSTR lpch, int ichCurrent,
 					  int cch, int code);
diff --git a/include/wine.h b/include/wine.h
index e8b4cfa..af1be18 100644
--- a/include/wine.h
+++ b/include/wine.h
@@ -46,8 +46,11 @@
 #define WINE_CODE_SELECTOR 0x17
 #endif
 
-#ifdef __svr4__
+#if defined(__svr4__) || defined(_SCO_DS)
 #include <signal.h>
+#ifdef _SCO_DS
+#include <sys/regset.h>
+#endif
 #include <sys/ucontext.h>
 #define sigcontext_struct ucontext
 #define WINE_DATA_SELECTOR 0x1f
diff --git a/library/miscstubs.c b/library/miscstubs.c
index 0c3f8c1..8ed3f24 100644
--- a/library/miscstubs.c
+++ b/library/miscstubs.c
@@ -57,7 +57,7 @@
   { return LocalAlloc(flags,size); }
 HLOCAL LOCAL_ReAlloc(WORD ds, HLOCAL handle, WORD size, WORD flags)
   { return LocalReAlloc(handle,size,flags); }
-NPVOID LOCAL_Lock( WORD ds, HLOCAL handle )
+LPSTR LOCAL_Lock( WORD ds, HLOCAL handle )
   { return LocalLock(handle); }
 BOOL LOCAL_Unlock( WORD ds, HLOCAL handle )
   { return LocalUnlock(handle); }
@@ -129,12 +129,7 @@
   return 0;
 }
 
-WIN32_builtin *RELAY32_GetBuiltinDLL(char *name)
-{
-    return NULL;
-}
-
-void *RELAY32_GetEntryPoint(WIN32_builtin *dll, char *item, int hint)
+void *RELAY32_GetEntryPoint(BUILTIN_DLL *dll, char *item, int hint)
 {
   return NULL;
 }
diff --git a/loader/main.c b/loader/main.c
index 0c49037..b06e261 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -49,7 +49,6 @@
 int MAIN_Init(void)
 {
     extern BOOL RELAY_Init(void);
-    extern BOOL RELAY32_Init(void); 
 
     int queueSize;
 
@@ -62,9 +61,6 @@
 #ifndef WINELIB
       /* Initialize relay code */
     if (!RELAY_Init()) return 0;
-
-      /* Initialize Win32 relay code */
-    if (!RELAY32_Init()) return 0;
 #endif
 
       /* Create built-in modules */
diff --git a/loader/module.c b/loader/module.c
index fce734c..060c286 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -47,7 +47,7 @@
     HMODULE hModule;
     NE_MODULE *pModule;
     SEGTABLEENTRY *pSegTable;
-    struct dll_table_s *table;
+    BUILTIN_DLL *table;
     char dllname[16], *p;
 
     /* Fix the name in case we have a full path and extension */
@@ -71,25 +71,31 @@
 
     dprintf_module( stddeb, "Built-in %s: hmodule=%04x\n",
                     table->name, hModule );
-
-    /* Allocate the code segment */
-
     pModule = (NE_MODULE *)GlobalLock( hModule );
-    pSegTable = NE_SEG_TABLE( pModule );
 
-    pSegTable->selector = GLOBAL_CreateBlock( GMEM_FIXED, table->code_start,
-                                              pSegTable->minsize, hModule,
-                                              TRUE, TRUE, FALSE, NULL );
-    if (!pSegTable->selector) return 0;
-    pSegTable++;
+    if (pModule->flags & NE_FFLAGS_WIN32)
+    {
+        ((NE_WIN32_EXTRAINFO*)(pModule+1))->pe_module = (DWORD)table;
+    }
+    else  /* Win16 module */
+    {
+        /* Allocate the code segment */
 
-    /* Allocate the data segment */
+        pSegTable = NE_SEG_TABLE( pModule );
+        pSegTable->selector = GLOBAL_CreateBlock(GMEM_FIXED, table->code_start,
+                                                 pSegTable->minsize, hModule,
+                                                 TRUE, TRUE, FALSE, NULL );
+        if (!pSegTable->selector) return 0;
+        pSegTable++;
 
-    pSegTable->selector = GLOBAL_Alloc( GMEM_FIXED, pSegTable->minsize,
-                                        hModule, FALSE, FALSE, FALSE );
-    if (!pSegTable->selector) return 0;
-    memcpy( GlobalLock( pSegTable->selector ),
-            table->data_start, pSegTable->minsize );
+        /* Allocate the data segment */
+
+        pSegTable->selector = GLOBAL_Alloc( GMEM_FIXED, pSegTable->minsize,
+                                            hModule, FALSE, FALSE, FALSE );
+        if (!pSegTable->selector) return 0;
+        memcpy( GlobalLock( pSegTable->selector ),
+                table->data_start, pSegTable->minsize );
+    }
 
     pModule->next = hFirstModule;
     hFirstModule = hModule;
@@ -104,13 +110,14 @@
  */
 BOOL MODULE_Init(void)
 {
-    /* For these, built-in modules are always used */
-
 #ifndef WINELIB32
-    if (!MODULE_LoadBuiltin( "KERNEL", TRUE ) ||
-        !MODULE_LoadBuiltin( "GDI", TRUE ) ||
-        !MODULE_LoadBuiltin( "USER", TRUE ) ||
-        !MODULE_LoadBuiltin( "WINPROCS", TRUE )) return FALSE;
+    BUILTIN_DLL *dll;
+
+    /* Load all modules marked as always used */
+
+    for (dll = dll_builtin_table; dll->name; dll++)
+        if (dll->flags & DLL_FLAG_ALWAYS_USED)
+            if (!MODULE_LoadBuiltin(dll->name, TRUE)) return FALSE;
 #endif
     /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
 
@@ -120,9 +127,9 @@
 
 
 /***********************************************************************
- *           MODULE_PrintModule
+ *           MODULE_DumpModule
  */
-void MODULE_PrintModule( HMODULE hmodule )
+void MODULE_DumpModule( HMODULE hmodule )
 {
     int i, ordinal;
     SEGTABLEENTRY *pSeg;
@@ -130,6 +137,12 @@
     WORD *pword;
     NE_MODULE *pModule = (NE_MODULE *)GlobalLock( hmodule );
 
+    if (!pModule || (pModule->magic != NE_SIGNATURE))
+    {
+        fprintf( stderr, "**** %04x is not a module handle\n", hmodule );
+        return;
+    }
+
       /* Dump the module info */
 
     printf( "Module %04x:\n", hmodule );
@@ -142,6 +155,8 @@
     printf( "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", (unsigned int)NE_WIN32_MODULE(pModule) );
 
       /* Dump the file info */
 
@@ -251,6 +266,31 @@
 
 
 /***********************************************************************
+ *           MODULE_WalkModules
+ *
+ * Walk the module list and print the modules.
+ */
+void MODULE_WalkModules(void)
+{
+    HMODULE hModule = hFirstModule;
+    fprintf( stderr, "Module Flags Name\n" );
+    while (hModule)
+    {
+        NE_MODULE *pModule = (NE_MODULE *)GlobalLock( hModule );
+        if (!pModule || (pModule->magic != NE_SIGNATURE))
+        {
+            fprintf( stderr, "**** Bad module %04x in list\n", hModule );
+            return;
+        }
+        fprintf( stderr, " %04x  %04x  %.*s\n", hModule, pModule->flags,
+                 *((char *)pModule + pModule->name_table),
+                 (char *)pModule + pModule->name_table + 1 );
+        hModule = pModule->next;
+    }
+}
+
+
+/***********************************************************************
  *           MODULE_OpenFile
  */
 int MODULE_OpenFile( HMODULE hModule )
@@ -591,7 +631,7 @@
     }
     else pModule->dlls_to_init = 0;
 
-    if (debugging_module) MODULE_PrintModule( hModule );
+    if (debugging_module) MODULE_DumpModule( hModule );
     pModule->next = hFirstModule;
     hFirstModule = hModule;
     return hModule;
diff --git a/loader/pe_image.c b/loader/pe_image.c
index ced45d0..ad82288 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -18,6 +18,7 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include "windows.h"
+#include "callback.h"
 #include "dlls.h"
 #include "neexe.h"
 #include "peexe.h"
@@ -33,8 +34,6 @@
 #include "debug.h"
 #include "xmalloc.h"
 
-struct w_files *wine_files = NULL;
-
 void my_wcstombs(char * result, u_short * source, int len)
 {
   while(len--) {
@@ -57,7 +56,7 @@
   if(r_size)
     v_size=r_size;
   else
-#ifdef __svr4__
+#if defined(__svr4__) || defined(_SCO_DS)
     fprintf(stderr,"xmmap: %s line %d doesn't support MAP_ANON\n",__FILE__, __LINE__);
 #else
     flags |= MAP_ANON;
@@ -104,10 +103,10 @@
     }
 }
 
-DWORD PE_FindExportedFunction(struct w_files* wpnt, char* funcName)
+static DWORD PE_FindExportedFunction(struct pe_data *pe, char* funcName)
 {
-	struct PE_Export_Directory * exports = wpnt->pe->pe_export;
-	unsigned load_addr = wpnt->pe->load_addr;
+	struct PE_Export_Directory * exports = pe->pe_export;
+	unsigned load_addr = pe->load_addr;
 	u_short * ordinal;
 	u_long * function;
 	u_char ** name, *ename;
@@ -136,25 +135,28 @@
 
 DWORD PE_GetProcAddress(HMODULE hModule, char* function)
 {
-	struct w_files *wpnt;
-	for(wpnt=wine_files;wpnt;wpnt=wpnt->next)
-		if(wpnt->hModule==hModule) break;
-	if(!wpnt)return 0;
-	if(wpnt->builtin)
-	{
-		if(HIWORD(function))
-			return RELAY32_GetEntryPoint(wpnt->builtin,function,0);
-		else
-			return RELAY32_GetEntryPoint(wpnt->builtin,0,(int)function);
-	}
-	return PE_FindExportedFunction(wpnt,function);
+    NE_MODULE *pModule;
+    struct pe_data *pe;
+
+    if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return 0;
+    if (!(pModule->flags & NE_FFLAGS_WIN32)) return 0;
+    if (pModule->flags & NE_FFLAGS_BUILTIN)
+    {
+        BUILTIN_DLL *dll = (BUILTIN_DLL *)NE_WIN32_MODULE(pModule);
+        if(HIWORD(function))
+            return RELAY32_GetEntryPoint(dll,function,0);
+        else
+            return RELAY32_GetEntryPoint(dll,0,(int)function);
+    }
+    if (!(pe = NE_WIN32_MODULE(pModule))) return 0;
+    return PE_FindExportedFunction( pe, function );
 }
 
-void fixup_imports(struct w_files* wpnt)
+void fixup_imports(struct pe_data *pe, HMODULE hModule)
 { 
   struct PE_Import_Directory * pe_imp;
   int fixup_failed=0;
-  unsigned int load_addr = wpnt->pe->load_addr;
+  unsigned int load_addr = pe->load_addr;
   int i;
   NE_MODULE *ne_mod;
   HMODULE *mod_ptr;
@@ -163,21 +165,19 @@
   dprintf_win32(stddeb, "\nDumping imports list\n");
 
   /* first, count the number of imported non-internal modules */
-  pe_imp = wpnt->pe->pe_import;
+  pe_imp = pe->pe_import;
   for(i=0;pe_imp->ModuleName;pe_imp++)
   	i++;
 
   /* Now, allocate memory for dlls_to_init */
-  ne_mod = GlobalLock(wpnt->hModule);
+  ne_mod = GlobalLock(hModule);
   ne_mod->dlls_to_init = GLOBAL_Alloc(GMEM_ZEROINIT,(i+1) * sizeof(HMODULE),
-  					wpnt->hModule, FALSE, FALSE, FALSE );
+                                      hModule, FALSE, FALSE, FALSE );
   mod_ptr = GlobalLock(ne_mod->dlls_to_init);
   /* load the modules and put their handles into the list */
-  for(i=0,pe_imp = wpnt->pe->pe_import;pe_imp->ModuleName;pe_imp++)
+  for(i=0,pe_imp = pe->pe_import;pe_imp->ModuleName;pe_imp++)
   {
   	char *name = (char*)load_addr+pe_imp->ModuleName;
-  	if(RELAY32_GetBuiltinDLL(name))
-		continue;
 	mod_ptr[i] = LoadModule(name,(LPVOID)-1);
 	if(mod_ptr[i]<=(HMODULE)32)
 	{
@@ -186,7 +186,7 @@
 	}
 	i++;
   }
-  pe_imp = wpnt->pe->pe_import;
+  pe_imp = pe->pe_import;
   while (pe_imp->ModuleName)
     {
       char * Module;
@@ -267,35 +267,35 @@
   if(fixup_failed)exit(1);
 }
 
-static void calc_vma_size(struct w_files *wpnt)
+static void calc_vma_size(struct pe_data *pe)
 {
   int i;
 
   dprintf_win32(stddeb, "Dump of segment table\n");
   dprintf_win32(stddeb, "   Name    VSz  Vaddr     SzRaw   Fileadr  *Reloc *Lineum #Reloc #Linum Char\n");
-  for(i=0; i< wpnt->pe->pe_header->coff.NumberOfSections; i++)
+  for(i=0; i< pe->pe_header->coff.NumberOfSections; i++)
     {
       dprintf_win32(stddeb, "%8s: %4.4lx %8.8lx %8.8lx %8.8lx %8.8lx %8.8lx %4.4x %4.4x %8.8lx\n", 
-	     wpnt->pe->pe_seg[i].Name, 
-	     wpnt->pe->pe_seg[i].Virtual_Size,
-	     wpnt->pe->pe_seg[i].Virtual_Address,
-	     wpnt->pe->pe_seg[i].Size_Of_Raw_Data,
-	     wpnt->pe->pe_seg[i].PointerToRawData,
-	     wpnt->pe->pe_seg[i].PointerToRelocations,
-	     wpnt->pe->pe_seg[i].PointerToLinenumbers,
-	     wpnt->pe->pe_seg[i].NumberOfRelocations,
-	     wpnt->pe->pe_seg[i].NumberOfLinenumbers,
-	     wpnt->pe->pe_seg[i].Characteristics);
-	  wpnt->pe->vma_size = max(wpnt->pe->vma_size,
-	  		wpnt->pe->pe_seg[i].Virtual_Address + 
-			wpnt->pe->pe_seg[i].Size_Of_Raw_Data);
+	     pe->pe_seg[i].Name, 
+	     pe->pe_seg[i].Virtual_Size,
+	     pe->pe_seg[i].Virtual_Address,
+	     pe->pe_seg[i].Size_Of_Raw_Data,
+	     pe->pe_seg[i].PointerToRawData,
+	     pe->pe_seg[i].PointerToRelocations,
+	     pe->pe_seg[i].PointerToLinenumbers,
+	     pe->pe_seg[i].NumberOfRelocations,
+	     pe->pe_seg[i].NumberOfLinenumbers,
+	     pe->pe_seg[i].Characteristics);
+	  pe->vma_size = max(pe->vma_size,
+	  		pe->pe_seg[i].Virtual_Address + 
+			pe->pe_seg[i].Size_Of_Raw_Data);
     }
 }
 
-static void do_relocations(struct w_files *wpnt)
+static void do_relocations(struct pe_data *pe)
 {
-	int delta = wpnt->pe->load_addr - wpnt->pe->base_addr;
-	struct PE_Reloc_Block *r = wpnt->pe->pe_reloc;
+	int delta = pe->load_addr - pe->base_addr;
+	struct PE_Reloc_Block *r = pe->pe_reloc;
 	int hdelta = (delta >> 16) & 0xFFFF;
 	int ldelta = delta & 0xFFFF;
 	/* int reloc_size = */
@@ -304,7 +304,7 @@
 		return;
 	while(r->PageRVA)
 	{
-		char *page = (char*)wpnt->pe->load_addr + r->PageRVA;
+		char *page = (char*)pe->load_addr + r->PageRVA;
 		int count = (r->BlockSize - 8)/2;
 		int i;
 		dprintf_fixup(stddeb, "%x relocations for page %lx\n",
@@ -357,179 +357,177 @@
  *			PE_LoadImage
  * Load one PE format executable into memory
  */
-static HINSTANCE PE_LoadImage( int fd, struct w_files *wpnt )
+static struct pe_data *PE_LoadImage( int fd, HMODULE hModule, WORD offset )
 {
-	int i, result;
+    struct pe_data *pe;
+    int i, result;
     unsigned int load_addr;
-	struct Directory dir;
+    struct Directory dir;
 
-	wpnt->pe = xmalloc(sizeof(struct pe_data));
-	memset(wpnt->pe,0,sizeof(struct pe_data));
-	wpnt->pe->pe_header = xmalloc(sizeof(struct pe_header_s));
+	pe = xmalloc(sizeof(struct pe_data));
+	memset(pe,0,sizeof(struct pe_data));
+	pe->pe_header = xmalloc(sizeof(struct pe_header_s));
 
 	/* read PE header */
-	lseek( fd, wpnt->mz_header->ne_offset, SEEK_SET);
-	read( fd, wpnt->pe->pe_header, sizeof(struct pe_header_s));
+	lseek( fd, offset, SEEK_SET);
+	read( fd, pe->pe_header, sizeof(struct pe_header_s));
 
 	/* read sections */
-	wpnt->pe->pe_seg = xmalloc(sizeof(struct pe_segment_table) * 
-				   wpnt->pe->pe_header->coff.NumberOfSections);
-	read( fd, wpnt->pe->pe_seg, sizeof(struct pe_segment_table) * 
-			wpnt->pe->pe_header->coff.NumberOfSections);
+	pe->pe_seg = xmalloc(sizeof(struct pe_segment_table) * 
+				   pe->pe_header->coff.NumberOfSections);
+	read( fd, pe->pe_seg, sizeof(struct pe_segment_table) * 
+			pe->pe_header->coff.NumberOfSections);
 
-	load_addr = wpnt->pe->pe_header->opt_coff.BaseOfImage;
-	wpnt->pe->base_addr=load_addr;
-	wpnt->pe->vma_size=0;
+	load_addr = pe->pe_header->opt_coff.BaseOfImage;
+	pe->base_addr=load_addr;
+	pe->vma_size=0;
 	dprintf_win32(stddeb, "Load addr is %x\n",load_addr);
-	calc_vma_size(wpnt);
+	calc_vma_size(pe);
 
 	/* We use malloc here, while a huge part of that address space does
 	   not be supported by actual memory. It has to be contiguous, though.
 	   I don't know if mmap("/dev/null"); would do any better.
 	   What I'd really like to do is a Win32 style VirtualAlloc/MapViewOfFile
 	   sequence */
-	load_addr = wpnt->pe->load_addr = malloc(wpnt->pe->vma_size);
+	load_addr = pe->load_addr = malloc(pe->vma_size);
 	dprintf_win32(stddeb, "Load addr is really %x, range %x\n",
-		wpnt->pe->load_addr, wpnt->pe->vma_size);
+		pe->load_addr, pe->vma_size);
 
 
-	for(i=0; i < wpnt->pe->pe_header->coff.NumberOfSections; i++)
+	for(i=0; i < pe->pe_header->coff.NumberOfSections; i++)
 	{
 		/* load only non-BSS segments */
-		if(wpnt->pe->pe_seg[i].Characteristics & 
+		if(pe->pe_seg[i].Characteristics & 
 			~ IMAGE_SCN_TYPE_CNT_UNINITIALIZED_DATA)
-		if(lseek(fd,wpnt->pe->pe_seg[i].PointerToRawData,SEEK_SET) == -1
-		|| read(fd,load_addr + wpnt->pe->pe_seg[i].Virtual_Address,
-				wpnt->pe->pe_seg[i].Size_Of_Raw_Data) 
-				!= wpnt->pe->pe_seg[i].Size_Of_Raw_Data)
+		if(lseek(fd,pe->pe_seg[i].PointerToRawData,SEEK_SET) == -1
+		|| read(fd,load_addr + pe->pe_seg[i].Virtual_Address,
+				pe->pe_seg[i].Size_Of_Raw_Data) 
+				!= pe->pe_seg[i].Size_Of_Raw_Data)
 		{
 			fprintf(stderr,"Failed to load section %x\n", i);
 			exit(0);
 		}
-		result = load_addr + wpnt->pe->pe_seg[i].Virtual_Address;
+		result = load_addr + pe->pe_seg[i].Virtual_Address;
 #if 0
 	if(!load_addr) {
 		
-		result = (int)xmmap((char *)0, wpnt->pe->pe_seg[i].Virtual_Size,
-			wpnt->pe->pe_seg[i].Size_Of_Raw_Data, 7,
-			MAP_PRIVATE, fd, wpnt->pe->pe_seg[i].PointerToRawData);
-		load_addr = (unsigned int) result -  wpnt->pe->pe_seg[i].Virtual_Address;
+		result = (int)xmmap((char *)0, pe->pe_seg[i].Virtual_Size,
+			pe->pe_seg[i].Size_Of_Raw_Data, 7,
+			MAP_PRIVATE, fd, pe->pe_seg[i].PointerToRawData);
+		load_addr = (unsigned int) result -  pe->pe_seg[i].Virtual_Address;
 	} else {
-		result = (int)xmmap((char *) load_addr + wpnt->pe->pe_seg[i].Virtual_Address, 
-			  wpnt->pe->pe_seg[i].Virtual_Size,
-		      wpnt->pe->pe_seg[i].Size_Of_Raw_Data, 7, MAP_PRIVATE | MAP_FIXED, 
-		      fd, wpnt->pe->pe_seg[i].PointerToRawData);
+		result = (int)xmmap((char *) load_addr + pe->pe_seg[i].Virtual_Address, 
+			  pe->pe_seg[i].Virtual_Size,
+		      pe->pe_seg[i].Size_Of_Raw_Data, 7, MAP_PRIVATE | MAP_FIXED, 
+		      fd, pe->pe_seg[i].PointerToRawData);
 	}
 	if(result==-1){
 		fprintf(stderr,"Could not load section %x to desired address %lx\n",
-			i, load_addr+wpnt->pe->pe_seg[i].Virtual_Address);
+			i, load_addr+pe->pe_seg[i].Virtual_Address);
 		fprintf(stderr,"Need to implement relocations now\n");
 		exit(0);
 	}
 #endif
 
-        if(strcmp(wpnt->pe->pe_seg[i].Name, ".bss") == 0)
+        if(strcmp(pe->pe_seg[i].Name, ".bss") == 0)
             memset((void *)result, 0, 
-                   wpnt->pe->pe_seg[i].Virtual_Size ?
-                   wpnt->pe->pe_seg[i].Virtual_Size :
-                   wpnt->pe->pe_seg[i].Size_Of_Raw_Data);
+                   pe->pe_seg[i].Virtual_Size ?
+                   pe->pe_seg[i].Virtual_Size :
+                   pe->pe_seg[i].Size_Of_Raw_Data);
 
-	if(strcmp(wpnt->pe->pe_seg[i].Name, ".idata") == 0)
-		wpnt->pe->pe_import = (struct PE_Import_Directory *) result;
+	if(strcmp(pe->pe_seg[i].Name, ".idata") == 0)
+		pe->pe_import = (struct PE_Import_Directory *) result;
 
-	if(strcmp(wpnt->pe->pe_seg[i].Name, ".edata") == 0)
-		wpnt->pe->pe_export = (struct PE_Export_Directory *) result;
+	if(strcmp(pe->pe_seg[i].Name, ".edata") == 0)
+		pe->pe_export = (struct PE_Export_Directory *) result;
 
-	if(strcmp(wpnt->pe->pe_seg[i].Name, ".rsrc") == 0) {
-	    wpnt->pe->pe_resource = (struct PE_Resource_Directory *) result;
+	if(strcmp(pe->pe_seg[i].Name, ".rsrc") == 0) {
+	    pe->pe_resource = (struct PE_Resource_Directory *) result;
 #if 0
 /* FIXME pe->resource_offset should be deleted from structure if this
  ifdef doesn't break anything */
 	    /* save offset for PE_FindResource */
-	    wpnt->pe->resource_offset = wpnt->pe->pe_seg[i].Virtual_Address - 
-					wpnt->pe->pe_seg[i].PointerToRawData;
+	    pe->resource_offset = pe->pe_seg[i].Virtual_Address - 
+					pe->pe_seg[i].PointerToRawData;
 #endif	
 	    }
-	if(strcmp(wpnt->pe->pe_seg[i].Name, ".reloc") == 0)
-		wpnt->pe->pe_reloc = (struct PE_Reloc_Block *) result;
+	if(strcmp(pe->pe_seg[i].Name, ".reloc") == 0)
+		pe->pe_reloc = (struct PE_Reloc_Block *) result;
 
 	}
 
 	/* There is word that the actual loader does not care about the
 	   section names, and only goes for the DataDirectory */
-	dir=wpnt->pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_EXPORT_DIRECTORY];
+	dir=pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_EXPORT_DIRECTORY];
 	if(dir.Size)
 	{
-		if(wpnt->pe->pe_export && 
-			wpnt->pe->pe_export!=load_addr+dir.Virtual_address)
+		if(pe->pe_export && 
+			pe->pe_export!=load_addr+dir.Virtual_address)
 			fprintf(stderr,"wrong export directory??\n");
 		/* always trust the directory */
-		wpnt->pe->pe_export = load_addr+dir.Virtual_address;
+		pe->pe_export = load_addr+dir.Virtual_address;
 	}
 
-	dir=wpnt->pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY];
+	dir=pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY];
 	if(dir.Size)
 	{
-		if(wpnt->pe->pe_import && 
-			wpnt->pe->pe_import!=load_addr+dir.Virtual_address)
+		if(pe->pe_import && 
+			pe->pe_import!=load_addr+dir.Virtual_address)
 			fprintf(stderr,"wrong import directory??\n");
-		wpnt->pe->pe_import = load_addr+dir.Virtual_address;
+		pe->pe_import = load_addr+dir.Virtual_address;
 	}
 
-	dir=wpnt->pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY];
+	dir=pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY];
 	if(dir.Size)
 	{
-		if(wpnt->pe->pe_resource && 
-			wpnt->pe->pe_resource!=load_addr+dir.Virtual_address)
+		if(pe->pe_resource && 
+			pe->pe_resource!=load_addr+dir.Virtual_address)
 			fprintf(stderr,"wrong resource directory??\n");
-		wpnt->pe->pe_resource = load_addr+dir.Virtual_address;
+		pe->pe_resource = load_addr+dir.Virtual_address;
 	}
 
-	dir=wpnt->pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_BASE_RELOCATION_TABLE];
+	dir=pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_BASE_RELOCATION_TABLE];
 	if(dir.Size)
 	{
-		if(wpnt->pe->pe_reloc && 
-			wpnt->pe->pe_reloc!=load_addr+dir.Virtual_address)
+		if(pe->pe_reloc && 
+			pe->pe_reloc!=load_addr+dir.Virtual_address)
 			fprintf(stderr,"wrong relocation list??\n");
-		wpnt->pe->pe_reloc = load_addr+dir.Virtual_address;
+		pe->pe_reloc = load_addr+dir.Virtual_address;
 	}
 
-	if(wpnt->pe->pe_header->opt_coff.DataDirectory
+	if(pe->pe_header->opt_coff.DataDirectory
 		[IMAGE_FILE_EXCEPTION_DIRECTORY].Size)
 		dprintf_win32(stdnimp,"Exception directory ignored\n");
 
-	if(wpnt->pe->pe_header->opt_coff.DataDirectory
+	if(pe->pe_header->opt_coff.DataDirectory
 		[IMAGE_FILE_SECURITY_DIRECTORY].Size)
 		dprintf_win32(stdnimp,"Security directory ignored\n");
 
-	if(wpnt->pe->pe_header->opt_coff.DataDirectory
+	if(pe->pe_header->opt_coff.DataDirectory
 		[IMAGE_FILE_DEBUG_DIRECTORY].Size)
 		dprintf_win32(stdnimp,"Debug directory ignored\n");
 
-	if(wpnt->pe->pe_header->opt_coff.DataDirectory
+	if(pe->pe_header->opt_coff.DataDirectory
 		[IMAGE_FILE_DESCRIPTION_STRING].Size)
 		dprintf_win32(stdnimp,"Description string ignored\n");
 
-	if(wpnt->pe->pe_header->opt_coff.DataDirectory
+	if(pe->pe_header->opt_coff.DataDirectory
 		[IMAGE_FILE_MACHINE_VALUE].Size)
 		dprintf_win32(stdnimp,"Machine Value ignored\n");
 
-	if(wpnt->pe->pe_header->opt_coff.DataDirectory
+	if(pe->pe_header->opt_coff.DataDirectory
 		[IMAGE_FILE_THREAD_LOCAL_STORAGE].Size)
 		 dprintf_win32(stdnimp,"Thread local storage ignored\n");
 
-	if(wpnt->pe->pe_header->opt_coff.DataDirectory
+	if(pe->pe_header->opt_coff.DataDirectory
 		[IMAGE_FILE_CALLBACK_DIRECTORY].Size)
 		dprintf_win32(stdnimp,"Callback directory ignored\n");
 
 
-	if(wpnt->pe->pe_import) fixup_imports(wpnt);
-	if(wpnt->pe->pe_export) dump_exports(wpnt->pe->pe_export,load_addr);
-	if(wpnt->pe->pe_reloc) do_relocations(wpnt);
-  
-	wpnt->hinstance = (HINSTANCE)0x8000;
-	wpnt->load_addr = load_addr;
-	return (wpnt->hinstance);
+	if(pe->pe_import) fixup_imports(pe, hModule);
+	if(pe->pe_export) dump_exports(pe->pe_export,load_addr);
+	if(pe->pe_reloc) do_relocations(pe);
+        return pe;
 }
 
 HINSTANCE MODULE_CreateInstance(HMODULE hModule,LOADPARAMS *params);
@@ -537,31 +535,27 @@
 
 HINSTANCE PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params )
 {
-	struct w_files *wpnt;
+        struct pe_data *pe;
 	int size, of_size;
 	NE_MODULE *pModule;
+        NE_WIN32_EXTRAINFO *pExtraInfo;
 	SEGTABLEENTRY *pSegment;
 	char *pStr;
 	DWORD cts;
 	HMODULE hModule;
 	HINSTANCE hInstance;
+        struct mz_header_s mz_header;
 
 	ALIAS_UseAliases=1;
 
-	wpnt=xmalloc(sizeof(struct w_files));
-	wpnt->ofs=*ofs;
-	wpnt->type=0;
-	wpnt->hinstance=0;
-	wpnt->hModule=0;
-	wpnt->initialised=0;
-	wpnt->builtin=0;
 	lseek(fd,0,SEEK_SET);
-	wpnt->mz_header=xmalloc(sizeof(struct mz_header_s));
-	read(fd,wpnt->mz_header,sizeof(struct mz_header_s));
+	read( fd, &mz_header, sizeof(mz_header) );
 
         of_size = sizeof(OFSTRUCT) - sizeof(ofs->szPathName)
                   + strlen(ofs->szPathName) + 1;
 	size = sizeof(NE_MODULE) +
+               /* extra module info */
+               sizeof(NE_WIN32_EXTRAINFO) +
                /* loaded file info */
                of_size +
                /* segment table: DS,CS */
@@ -572,7 +566,6 @@
                8;
 
 	hModule = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, size );
-	wpnt->hModule=hModule;
 	if (!hModule) return (HINSTANCE)11;  /* invalid exe */
 
 	FarSetOwner( hModule, hModule );
@@ -593,17 +586,19 @@
 	pModule->seg_count=1;
 	pModule->modref_count=0;
 	pModule->nrname_size=0;
-	pModule->seg_table=sizeof(NE_MODULE) + of_size;
-	pModule->fileinfo=sizeof(NE_MODULE);
+	pModule->fileinfo=sizeof(NE_MODULE) + sizeof(NE_WIN32_EXTRAINFO);
 	pModule->os_flags=NE_OSFLAGS_WINDOWS;
 	pModule->expected_version=0x30A;
 
-        /* Set loaded file information */
-        memcpy( pModule + 1, ofs, of_size );
-        ((OFSTRUCT *)(pModule+1))->cBytes = of_size - 1;
+        /* Set extra info */
+        pExtraInfo = (NE_WIN32_EXTRAINFO *)(pModule + 1);
 
-	pSegment=(SEGTABLEENTRY*)((char*)(pModule + 1) + of_size);
-	pModule->dgroup_entry=(int)pSegment-(int)pModule;
+        /* Set loaded file information */
+        memcpy( pExtraInfo + 1, ofs, of_size );
+        ((OFSTRUCT *)(pExtraInfo+1))->cBytes = of_size - 1;
+
+	pSegment=(SEGTABLEENTRY*)((char*)(pExtraInfo + 1) + of_size);
+	pModule->seg_table=pModule->dgroup_entry=(int)pSegment-(int)pModule;
 	pSegment->size=0;
 	pSegment->flags=NE_SEGFLAGS_DATA;
 	pSegment->minsize=0x1000;
@@ -630,32 +625,23 @@
 
         MODULE_RegisterModule(hModule);
 
-	PE_LoadImage( fd, wpnt );
+	pe = PE_LoadImage( fd, hModule, mz_header.ne_offset );
 
+        pExtraInfo->pe_module = (DWORD)pe;
 	pModule->heap_size=0x1000;
 	pModule->stack_size=0xE000;
 
 	/* CreateInstance allocates now 64KB */
 	hInstance=MODULE_CreateInstance(hModule,NULL /* FIX: NULL? really? */);
-	wpnt->hinstance=hInstance;
-
-	if (wpnt->pe->pe_export) {
-		pStr = ((unsigned char *)(wpnt->load_addr))+wpnt->pe->pe_export->Name;
-		wpnt->name = xstrdup(pStr);
-	} else {
-		wpnt->name = xstrdup( ofs->szPathName );
-	}
-
-	wpnt->next=wine_files;
-	wine_files=wpnt;
 
         /* FIXME: Is this really the correct place to initialise the DLL? */
-	if ((wpnt->pe->pe_header->coff.Characteristics & IMAGE_FILE_DLL)) {
-            PE_InitDLL(hModule);
+	if ((pe->pe_header->coff.Characteristics & IMAGE_FILE_DLL)) {
+/*            PE_InitDLL(hModule); */
         } else {
             TASK_CreateTask(hModule,hInstance,0,
 		params->hEnvironment,(LPSTR)PTR_SEG_TO_LIN(params->cmdLine),
 		*((WORD*)PTR_SEG_TO_LIN(params->showCmd)+1));
+            PE_InitializeDLLs(hModule);
 	}
 	return hInstance;
 }
@@ -665,41 +651,48 @@
 
 void PE_Win32CallToStart(struct sigcontext_struct context)
 {
-	int fs;
-	struct w_files *wpnt=wine_files;
-	dprintf_win32(stddeb,"Going to start Win32 program\n");	
-	InitTask(context);
-	USER_InitApp(wpnt->hModule);
-        fs=(int)GlobalAlloc(GHND,0x10000);
-        PE_InitTEB(fs);
-	__asm__ __volatile__("movw %w0,%%fs"::"r" (fs));
-	((void(*)())(wpnt->load_addr+wpnt->pe->pe_header->opt_coff.AddressOfEntryPoint))();
+    int fs;
+    HMODULE hModule;
+    struct pe_data *pe;
+
+    dprintf_win32(stddeb,"Going to start Win32 program\n");	
+    InitTask(context);
+    hModule = GetExePtr( GetCurrentTask() );
+    USER_InitApp( hModule );
+    fs=(int)GlobalAlloc(GHND,0x10000);
+    PE_InitTEB(fs);
+    pe = NE_WIN32_MODULE( (NE_MODULE *)GlobalLock(hModule) );
+    __asm__ __volatile__("movw %w0,%%fs"::"r" (fs));
+/*    ((void(*)())(pe->load_addr+pe->pe_header->opt_coff.AddressOfEntryPoint))(); */
+    CallTaskStart32( (FARPROC)(pe->load_addr + 
+                               pe->pe_header->opt_coff.AddressOfEntryPoint) );
 }
 
-int PE_UnloadImage(struct w_files *wpnt)
+int PE_UnloadImage( HMODULE hModule )
 {
 	printf("PEunloadImage() called!\n");
 	/* free resources, image, unmap */
 	return 1;
 }
 
-void PE_InitDLL(HMODULE hModule)
+static void PE_InitDLL(HMODULE hModule)
 {
-	struct w_files *wpnt;
-	hModule = GetExePtr(hModule);
-	for(wpnt = wine_files;wpnt && wpnt->hModule != hModule;
-		wpnt = wpnt->next) /*nothing*/;
-	if(!wpnt || wpnt->initialised)
-		return;
-        /* FIXME: What are the correct values for parameters 2 and 3? */
+    NE_MODULE *pModule;
+    struct pe_data *pe;
+    hModule = GetExePtr(hModule);
+    if (!(pModule = (NE_MODULE *)GlobalLock(hModule))) return;
+    if (!(pModule->flags & NE_FFLAGS_WIN32)) return;
+    if (!(pe = NE_WIN32_MODULE(pModule))) return;
+    /* FIXME: What are the correct values for parameters 2 and 3? */
         
-	/* Is this a library? */
-	if (wpnt->pe->pe_header->coff.Characteristics & IMAGE_FILE_DLL) {
-		/* Should call DLLEntryPoint here */
-		printf("InitPEDLL() called!\n");
-		wpnt->initialised = 1;
-                ((void(*)())(wpnt->load_addr+wpnt->pe->pe_header->opt_coff.AddressOfEntryPoint))(wpnt->hModule, 0, 0);
-	}
+    /* Is this a library? */
+    if (pe->pe_header->coff.Characteristics & IMAGE_FILE_DLL)
+    {
+        printf("InitPEDLL() called!\n");
+        CallDLLEntryProc32( (FARPROC)(pe->load_addr + 
+                                  pe->pe_header->opt_coff.AddressOfEntryPoint),
+                            hModule, 0, 0 );
+    }
 }
 
 
diff --git a/loader/signal.c b/loader/signal.c
index 8ebc0b6..d9b72ab 100644
--- a/loader/signal.c
+++ b/loader/signal.c
@@ -10,8 +10,10 @@
 #include <sys/time.h>
 #include <sys/timeb.h>
 
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__svr4__)
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__svr4__) || defined(_SCO_DS)
+#ifndef _SCO_DS
 #include <sys/syscall.h>
+#endif
 #include <sys/param.h>
 #else
 #include <syscall.h>
@@ -76,7 +78,7 @@
 static void win_fault(int signal, struct sigcontext_struct context_struct)
 {
     struct sigcontext_struct *context = &context_struct;
-#elif defined(__svr4__)
+#elif defined(__svr4__) || defined(_SCO_DS)
 static void win_fault(int signal, void *siginfo, ucontext_t *context)
 {
 #else
@@ -128,7 +130,7 @@
 
 #ifdef linux
     sig_act.sa_handler = func;
-    sig_act.sa_flags = SA_RESTART;
+    sig_act.sa_flags = SA_RESTART | SA_NOMASK;
     /* Point to the top of the stack, minus 4 just in case, and make
        it aligned  */
     sig_act.sa_restorer = 
@@ -145,14 +147,14 @@
     ret = sigaction( sig, &sig_act, NULL );
 #endif  /* __FreeBSD__ || __NetBSD__ */
 
-#if defined (__svr4__)
+#if defined (__svr4__) || defined(_SCO_DS)
     sigset_t sig_mask;
     sigemptyset(&sig_mask);
     sig_act.sa_handler = func;
     sig_act.sa_flags = SA_ONSTACK | SA_SIGINFO;
     sig_act.sa_mask = sig_mask;
     ret = sigaction( sig, &sig_act, NULL );
-#endif  /* __svr4__ */
+#endif  /* __svr4__ || _SCO_DS */
 
     if (ret < 0)
     {
@@ -189,7 +191,7 @@
     }
 #endif  /* __FreeBSD__ || __NetBSD__ */
 
-#if defined (__svr4__)
+#if defined (__svr4__) || defined(_SCO_DS)
     struct sigaltstack ss;
         
     if ((ss.ss_sp = malloc(SIGSTKSZ) ) == NULL) {
@@ -203,7 +205,7 @@
         perror("sigstack");
         exit(1);
     }
-#endif  /* __svr4__ */
+#endif  /* __svr4__ || _SCO_DS */
     
     SIGNAL_SetHandler( SIGALRM, (void (*)())wine_timer );
     SIGNAL_SetHandler( SIGSEGV, (void (*)())win_fault );
@@ -217,19 +219,21 @@
 #ifdef CONFIG_IPC
     SIGNAL_SetHandler( SIGUSR2, (void (*)())stop_wait ); /* For IPC */
 #endif
-    SIGNAL_StartBIOSTimer();
 }
 
 
 /**********************************************************************
- *		SIGNAL_StartTimer
+ *		SIGNAL_StartBIOSTimer
  *
  * Start the BIOS tick timer.
  */
 void SIGNAL_StartBIOSTimer(void)
 {
     struct itimerval vt_timer;
+    static int timer_started = 0;
 
+    if (timer_started) return;
+    timer_started = 1;
     vt_timer.it_interval.tv_sec = 0;
     vt_timer.it_interval.tv_usec = 54929;
     vt_timer.it_value = vt_timer.it_interval;
diff --git a/loader/task.c b/loader/task.c
index 0fc4a67..0a2a3b8 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -384,7 +384,7 @@
     char *stack16Top, *stack32Top;
     STACK16FRAME *frame16;
     STACK32FRAME *frame32;
-    extern DWORD CALL16_RetAddr_word;
+    extern DWORD CALLTO16_RetAddr_word;
 #endif
     
     if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return 0;
@@ -529,8 +529,8 @@
     frame16->ordinal_number = 24;  /* WINPROCS.24 is TASK_Reschedule */
     frame16->dll_id = 24; /* WINPROCS */
     frame16->bp = 0;
-    frame16->ip = LOWORD( CALL16_RetAddr_word );
-    frame16->cs = HIWORD( CALL16_RetAddr_word );
+    frame16->ip = LOWORD( CALLTO16_RetAddr_word );
+    frame16->cs = HIWORD( CALLTO16_RetAddr_word );
     pTask->sp -= sizeof(STACK16FRAME);
 
       /* If there's no 16-bit stack yet, use a part of the new task stack */
diff --git a/memory/ldt.c b/memory/ldt.c
index 86ab2ef..e5267d7 100644
--- a/memory/ldt.c
+++ b/memory/ldt.c
@@ -22,7 +22,7 @@
 
 _syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount)
 #endif  /* linux */
-#ifdef __svr4__
+#if defined(__svr4__) || defined(_SCO_DS)
 #include <sys/sysi86.h>
 #include <sys/seg.h>
 #endif
@@ -153,7 +153,7 @@
         }
     }
 #endif  /* __NetBSD__ || __FreeBSD__ */
-#ifdef __svr4__
+#if defined(__svr4__) || defined(_SCO_DS)
 {
     struct ssd ldt_mod;
     int i;
diff --git a/memory/local.c b/memory/local.c
index e113496..f249a80 100644
--- a/memory/local.c
+++ b/memory/local.c
@@ -823,16 +823,14 @@
 
 
 /***********************************************************************
- *           LOCAL_Lock
+ *           LOCAL_InternalLock
  */
-HANDLE LOCAL_Lock( HANDLE ds, HLOCAL handle )
+static HLOCAL LOCAL_InternalLock( LPSTR heap, HLOCAL handle )
 {
-    char *ptr = PTR_SEG_OFF_TO_LIN( ds, 0 );
-
     dprintf_local( stddeb, "LocalLock: %04x ", handle );
     if (HANDLE_MOVEABLE(handle))
     {
-        LOCALHANDLEENTRY *pEntry = (LOCALHANDLEENTRY *)(ptr + handle);
+        LOCALHANDLEENTRY *pEntry = (LOCALHANDLEENTRY *)(heap + handle);
         if (pEntry->lock < 255) pEntry->lock++;
         handle = pEntry->addr;
     }
@@ -842,6 +840,16 @@
 
 
 /***********************************************************************
+ *           LOCAL_Lock
+ */
+LPSTR LOCAL_Lock( HANDLE ds, HLOCAL handle )
+{
+    char *ptr = PTR_SEG_OFF_TO_LIN( ds, 0 );
+    return handle ? ptr + LOCAL_InternalLock( ptr, handle ) : NULL;
+}
+
+
+/***********************************************************************
  *           LOCAL_Unlock
  */
 BOOL LOCAL_Unlock( WORD ds, HLOCAL handle )
@@ -929,7 +937,8 @@
  */
 NPVOID LocalLock( HLOCAL handle )
 {
-    return LOCAL_Lock( CURRENT_DS, handle );
+    char *ptr = PTR_SEG_OFF_TO_LIN( CURRENT_DS, 0 );
+    return (NPVOID)LOCAL_InternalLock( ptr, handle );
 }
 
 
diff --git a/misc/comm.c b/misc/comm.c
index 467912d..d0dfef3 100644
--- a/misc/comm.c
+++ b/misc/comm.c
@@ -54,7 +54,7 @@
 			}
 			stat(temp, &st);
 			if (!S_ISCHR(st.st_mode)) 
-				fprintf(stderr,"comm: can 't use `%s' as %s !\n", temp, option);
+				fprintf(stderr,"comm: can't use `%s' as %s !\n", temp, option);
 			else
 				if ((COM[x].devicename = malloc(strlen(temp)+1)) == NULL) 
 					fprintf(stderr,"comm: can't malloc for device info!\n");
@@ -77,7 +77,7 @@
 		else {
 			stat(temp, &st);
 			if (!S_ISCHR(st.st_mode)) 
-				fprintf(stderr,"comm: can 't use `%s' as %s !\n", temp, option);
+				fprintf(stderr,"comm: can't use `%s' as %s !\n", temp, option);
 			else 
 				if ((LPT[x].devicename = malloc(strlen(temp)+1)) == NULL) 
 					fprintf(stderr,"comm: can't malloc for device info!\n");
@@ -352,15 +352,19 @@
 			return 0x80 + max;
 			break;
 
+#ifdef TIOCM_DTR
 		case CLRDTR:
 			port.c_cflag &= TIOCM_DTR;
 			break;
+#endif
 
+#ifdef TIOCM_RTS
 		case CLRRTS:
 			port.c_cflag &= TIOCM_RTS;
 			break;
+#endif
 	
-#ifndef __svr4__
+#ifdef CRTSCTS
 		case SETDTR:
 			port.c_cflag |= CRTSCTS;
 			break;
@@ -464,7 +468,11 @@
 	port.c_cc[VMIN] = 0;
 	port.c_cc[VTIME] = 1;
 
+#ifdef IMAXBEL
 	port.c_iflag &= ~(ISTRIP|BRKINT|IGNCR|ICRNL|INLCR|IMAXBEL);
+#else
+	port.c_iflag &= ~(ISTRIP|BRKINT|IGNCR|ICRNL|INLCR);
+#endif
 	port.c_iflag |= (IGNBRK);
 
 	port.c_oflag &= ~(OPOST);
@@ -622,7 +630,7 @@
 			commerror = IE_BYTESIZE;
 			return -1;
 	}
-#ifndef __svr4__
+#ifdef CRTSCTS
 
 	if (lpdcb->fDtrflow || lpdcb->fRtsflow || lpdcb->fOutxCtsFlow)
 		port.c_cflag |= CRTSCTS;
@@ -730,7 +738,7 @@
 	lpdcb->fBinary = 1;
 	lpdcb->fDtrDisable = 0;
 
-#ifndef __svr4__
+#ifdef CRTSCTS
 
 	if (port.c_cflag & CRTSCTS) {
 		lpdcb->fDtrflow = 1;
diff --git a/misc/main.c b/misc/main.c
index caa253f..e7bfdda 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -266,7 +266,7 @@
  */
 static BOOL MAIN_ParseDLLOptions(char *options)
 {
-    int i, l;
+    int l;
     BUILTIN_DLL *dll;
 
     if (strlen(options)<3) return FALSE;
@@ -280,7 +280,11 @@
             if (!lstrncmpi(options+1,dll->name,l-1))
             {
                 if (*options == '+') dll->flags &= ~DLL_FLAG_NOT_USED;
-                else dll->flags |= DLL_FLAG_NOT_USED;
+                else
+                {
+                    if (dll->flags & DLL_FLAG_ALWAYS_USED) return FALSE;
+                    dll->flags |= DLL_FLAG_NOT_USED;
+                }
                 break;
             }
         }
@@ -438,8 +442,9 @@
          fprintf(stderr,"%s: Syntax: -dll +xxx,... or -dll -xxx,...\n",argv[0]);
          fprintf(stderr,"Example: -dll -ole2    Do not use emulated OLE2.DLL\n");
          fprintf(stderr,"Available DLLs\n");
-         for (dll = dll_builtin_table; dll->name; dll++)
-             fprintf(stderr,"%-9s%c",dll->name, (((i+2)%8==0)?'\n':' '));
+         for (i = 0, dll = dll_builtin_table; dll->name; dll++)
+             if (!(dll->flags & DLL_FLAG_ALWAYS_USED))
+                 fprintf(stderr,"%-9s%c",dll->name, (((++i)%8==0)?'\n':' '));
          fprintf(stderr,"\n\n");
          exit(1);
        }
diff --git a/misc/port.c b/misc/port.c
index 751750c..165a6df 100644
--- a/misc/port.c
+++ b/misc/port.c
@@ -9,8 +9,7 @@
     delay.tv_sec = 0;
     delay.tv_usec = useconds;
 
-    (void) select (0, (fd_set *) NULL, (fd_set *) NULL, (fd_set *) NULL,
-		   &delay);
+    (void) select (0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, &delay);
     return 0;
 }
 
diff --git a/misc/registry.c b/misc/registry.c
index 1cff39f..6483078 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <ctype.h>
+#include <errno.h>
 #include "windows.h"
 #include "win.h"
 #include "winerror.h"
@@ -76,7 +77,7 @@
 }
 
 static LPKEYSTRUCT
-get_handle(hkey) {
+get_handle(HKEY hkey) {
 	int	i;
 
 	for (i=0;i<nrofopenhandles;i++)
diff --git a/misc/winsocket.c b/misc/winsocket.c
index cd69bc0..91652e8 100644
--- a/misc/winsocket.c
+++ b/misc/winsocket.c
@@ -11,7 +11,7 @@
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/ioctl.h>
-#ifdef __svr4__
+#if defined__svr4__
 #include <sys/filio.h>
 #include <sys/ioccom.h>
 #endif
@@ -29,6 +29,11 @@
 #include "stddebug.h"
 #include "debug.h"
 
+#ifdef _SCO_DS
+#define _IOR _IOSR
+#define _IOW _IOSW
+#endif
+
 static WORD wsa_errno;
 static int wsa_initted;
 static key_t wine_key = 0;
@@ -208,7 +213,9 @@
 #ifdef EPROCLIM
 	case EPROCLIM:		return WSAEPROCLIM;
 #endif
+#ifdef EUSERS
 	case EUSERS:		return WSAEUSERS;
+#endif
 #ifdef EDQUOT
 	case EDQUOT:		return WSAEDQUOT;
 #endif
diff --git a/miscemu/dosmem.c b/miscemu/dosmem.c
index d3d5fa9..a4c156a 100644
--- a/miscemu/dosmem.c
+++ b/miscemu/dosmem.c
@@ -138,7 +138,7 @@
  */
 void DOSMEM_Tick(void)
 {
-    pBiosData->Ticks++;
+    if (pBiosData) pBiosData->Ticks++;
 }
 
 
@@ -149,8 +149,6 @@
  */
 void DOSMEM_FillBiosSegment(void)
 {
-    extern void SIGNAL_StartBIOSTimer(void);
-
     pBiosData = (BIOSDATA *)GlobalLock( DOSMEM_BiosSeg );
 
       /* Clear all unused values */
@@ -175,7 +173,5 @@
     pBiosData->NbHardDisks          = 2;
     pBiosData->KbdBufferStart       = 0x1e;
     pBiosData->KbdBufferEnd         = 0x3e;
-
-    SIGNAL_StartBIOSTimer();
 }
 
diff --git a/miscemu/instr.c b/miscemu/instr.c
index 14ac461..767f4e8 100644
--- a/miscemu/instr.c
+++ b/miscemu/instr.c
@@ -28,8 +28,10 @@
 {
     if (sel == 0x40)
     {
+        extern void SIGNAL_StartBIOSTimer(void);
         fprintf( stderr, "Direct access to segment 0x40 (cs:ip=%04x:%04lx).\n",
                  CS_reg(context), EIP_reg(context) );
+        SIGNAL_StartBIOSTimer();
         return DOSMEM_BiosSeg;
     }
     return 0;  /* Can't replace selector */
diff --git a/miscemu/int21.c b/miscemu/int21.c
index 08f300e..53e0769 100644
--- a/miscemu/int21.c
+++ b/miscemu/int21.c
@@ -28,8 +28,8 @@
 #include "xmalloc.h"
 #include "stddebug.h"
 #include "debug.h"
-#ifdef __svr4__
-/* SVR4 DOESNTdo locking the same way must implement properly */
+#if defined(__svr4__) || defined(_SCO_DS)
+/* SVR4 DOESNT do locking the same way must implement properly */
 #define LOCK_EX 0
 #define LOCK_SH  1
 #define LOCK_NB  8
@@ -346,7 +346,7 @@
 
 	  int result,retries=sharing_retries;
 	  {
-#ifdef __svr4__
+#if defined(__svr4__) || defined(_SCO_DS)
               printf("Should call flock and needs porting to lockf\n");
               result = 0;
               retries = 0;
diff --git a/multimedia/time.c b/multimedia/time.c
index f0e21fe..b49dfb7 100644
--- a/multimedia/time.c
+++ b/multimedia/time.c
@@ -12,6 +12,7 @@
 #include "windows.h"
 #include "win.h"
 #include "ldt.h"
+#include "module.h"
 #include "callback.h"
 #include "user.h"
 #include "driver.h"
diff --git a/objects/font.c b/objects/font.c
index 114c8ea..41c8d38 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -3,6 +3,10 @@
  *
  * Copyright 1993 Alexandre Julliard
  *
+ * Enhacements by Juergen Marquardt 1996
+ *
+ * Implementation of a second font cache which 
+ * will be updated dynamically
  */
 
 #include <stdio.h>
@@ -17,6 +21,7 @@
 #include "stddebug.h"
 #include "debug.h"
 
+#define FONTCACHE 	32	/* dynamic font cache size */
 #define MAX_FONTS	256
 static LPLOGFONT lpLogFontList[MAX_FONTS] = { NULL };
 
@@ -139,10 +144,15 @@
     if (height == 0) height = 120;  /* Default height = 12 */
     else if (height < 0)
     {
-          /* If height is negative, it means the height of the characters */
-          /* *without* the internal leading. So we adjust it a bit to     */
-          /* compensate. 5/4 seems to give good results for small fonts.  */
-        height = 10 * (-height * 8 / 7);
+        /* If height is negative, it means the height of the characters */
+        /* *without* the internal leading. So we adjust it a bit to     */
+        /* compensate. 5/4 seems to give good results for small fonts.  */
+	/* 
+         * J.M.: This causes wrong font size for bigger fonts e.g. in Winword & Write 
+        height = 10 * (-height * 9 / 8);
+	 * may be we have to use an non linear function
+	*/
+        height *= -10;
     }
     else height *= 10;
     width  = 10 * (font->lfWidth * dc->w.VportExtY / dc->w.WndExtY);
@@ -151,10 +161,17 @@
 		      width, font->lfWidth );
 	width = -width;
     }
+
     spacing = (font->lfPitchAndFamily & FIXED_PITCH) ? 'm' :
 	      (font->lfPitchAndFamily & VARIABLE_PITCH) ? 'p' : '*';
+    
+  
     charset = (font->lfCharSet == ANSI_CHARSET) ? "iso8859-1" : "*-*";
-    if (*font->lfFaceName) family = FONT_TranslateName( font->lfFaceName );
+    if (*font->lfFaceName) {
+	family = FONT_TranslateName( font->lfFaceName );
+	/* FIX ME: I don't if that's correct but it works J.M. */
+	spacing = '*';
+	}
     else switch(font->lfPitchAndFamily & 0xf0)
     {
     case FF_ROMAN:
@@ -191,6 +208,7 @@
 	    names = XListFonts( display, pattern, 1, &count );
 	    if (count > 0) break;
             if (spacing == 'm') /* try 'c' if no 'm' found */ {
+
                 spacing = 'c';
                 continue;
             } else if (spacing == 'p') /* try '*' if no 'p' found */ {
@@ -367,6 +385,15 @@
 HFONT FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font )
 {
     static X_PHYSFONT stockFonts[LAST_STOCK_FONT-FIRST_STOCK_FONT+1];
+
+    static struct {
+		HFONT		id;
+		LOGFONT		logfont;
+		int		access;
+		int		used;
+		X_PHYSFONT	cacheFont; } cacheFonts[FONTCACHE], *cacheFontsMin;
+    int 	i;
+
     X_PHYSFONT * stockPtr;
     HFONT prevHandle = dc->w.hFont;
     XFontStruct * fontStruct;
@@ -393,9 +420,46 @@
 
     if ((hfont >= FIRST_STOCK_FONT) && (hfont <= LAST_STOCK_FONT))
 	stockPtr = &stockFonts[hfont - FIRST_STOCK_FONT];
-    else 
+    else {
 	stockPtr = NULL;
-    
+	/*
+	 * Ok, It's not a stock font but 
+	 * may be it's cached in dynamic cache
+	 */
+	for(i=0; i<FONTCACHE; i++) /* search for same handle */
+	     if (cacheFonts[i].id==hfont) { /* Got the handle */
+		/*
+		 * Check if Handle matches the font 
+		 */
+		if(memcmp(&cacheFonts[i].logfont,&(font->logfont), sizeof(LOGFONT))) {
+			/* No: remove handle id from dynamic font cache */
+			cacheFonts[i].access=0;
+			cacheFonts[i].used=0;
+			cacheFonts[i].id=0;
+			/* may be there is an unused handle which contains the font */
+			for(i=0; i<FONTCACHE; i++) {
+				if((cacheFonts[i].used == 0) &&
+				  (memcmp(&cacheFonts[i].logfont,&(font->logfont), sizeof(LOGFONT)))== 0) {
+					/* got it load from cache and set new handle id */
+					stockPtr = &cacheFonts[i].cacheFont;
+					cacheFonts[i].access=1;
+					cacheFonts[i].used=1;
+					cacheFonts[i].id=hfont;
+					dprintf_font(stddeb,"FONT_SelectObject: got font from unused handle\n");
+					break;
+					}
+				}
+	
+			}
+		else {
+			/* Yes: load from dynamic font cache */
+			stockPtr = &cacheFonts[i].cacheFont;
+			cacheFonts[i].access++;
+			cacheFonts[i].used++;
+			}
+		break;
+		}
+	}
     if (!stockPtr || !stockPtr->fstruct)
     {
 	if (!(fontStruct = FONT_MatchFont( &font->logfont, dc )))
@@ -422,16 +486,14 @@
 		     hfont, fontStruct );
     }	
 
-      /* Free previous font */
-
-    if ((prevHandle < FIRST_STOCK_FONT) || (prevHandle > LAST_STOCK_FONT))
-    {
-	if (dc->u.x.font.fstruct)
-	    XFreeFont( display, dc->u.x.font.fstruct );
-    }
+      /* Unuse previous font */
+	for (i=0; i < FONTCACHE; i++) {
+		if (cacheFonts[i].id == prevHandle) {
+			cacheFonts[i].used--;
+			}
+		}
 
       /* Store font */
-
     dc->w.hFont = hfont;
     if (stockPtr)
     {
@@ -444,8 +506,31 @@
     }
     else
     {
-	dc->u.x.font.fstruct = fontStruct;
-	FONT_GetMetrics( &font->logfont, fontStruct, &dc->u.x.font.metrics );
+	/* 
+	 * Check in cacheFont
+	 */
+	cacheFontsMin=NULL;
+	for (i=0; i < FONTCACHE; i++) {
+		if (cacheFonts[i].used==0) 
+			if ((!cacheFontsMin) || ((cacheFontsMin) && (cacheFontsMin->access > cacheFonts[i].access)))
+				cacheFontsMin=&cacheFonts[i];
+		}
+	if (!cacheFontsMin)
+		fprintf(stderr,"No unused font cache entry !!!!\n" );
+
+	if (cacheFontsMin->id!=0) {
+		dprintf_font(stddeb,
+			"FONT_SelectObject: Freeing %04x \n",cacheFontsMin->id );
+		XFreeFont( display, cacheFontsMin->cacheFont.fstruct );
+		}
+	cacheFontsMin->cacheFont.fstruct = fontStruct;
+	FONT_GetMetrics( &font->logfont, fontStruct, &cacheFontsMin->cacheFont.metrics );
+	cacheFontsMin->access=1;
+	cacheFontsMin->used=1;
+	cacheFontsMin->id=hfont;
+	memcpy( &dc->u.x.font, &(cacheFontsMin->cacheFont), sizeof(cacheFontsMin->cacheFont) );
+	memcpy(&cacheFontsMin->logfont,&(font->logfont), sizeof(LOGFONT));
+
     }
     return prevHandle;
 }
diff --git a/resources/TODO b/resources/TODO
index db771cc..e391bd3 100644
--- a/resources/TODO
+++ b/resources/TODO
@@ -1,20 +1,29 @@
-Due to the implementation of FindText() and ReplaceText() in /misc/commdlg.c
-I had to change the definition in sysres_En.rc of the dialogs FIND_TEXT and
-REPLACE_TEXT.  These changes should also be made for the other languages.
-Not only should the definitions in sysres_??.rc made up to date with the
-Enlish version, but also the dimensions of the controls should be changed so
-that they will be big enough to contain the text for every individual
-language.
+The dimensions of the controls should be changed so that they will be big 
+enough to contain the text for every individual language.
 
 Therefore:
 
-- Definitions of FIND_TEXT and REPLACE_TEXT in sysres_??.rc should match
-  those in sysres_En.rc
 - Dimensions of controls are based on sysres_En.rc.  Other languages should
   change these dimensions in order to make the text fit.
 
+I (krynos@qbc.clic.net) will try to make sysres_Fr.rc fit correctly, if 
+someone is interrested in others languages, message me. I may correct 
+others languages after, but not soon.
+
+Here are structure of each line (for example):
+PUSHBUTTON "&Help", 1038, 174, 75, 50, 14, WS_GROUP | WS_TABSTOP
+1038: The ID of this button, you shouldn't change this.
+174 : X-offset of the button with respect to the upper-left corner of
+      the dialog box.
+75  : Y-offset
+50  : The width of the button
+14  : The height
+flags (WS_??? etc): They control how the dialog behaves.  Things like:
+                    changing the focus with a TAB, scrolling to a list
+                    of radiobuttons with up/down keys, etc.  If you're
+                    not sure: leave them as they are (in the english
+                    version).
+ 
+
 Frans van Dorsselaer
 dorssel@rulhm1.LeidenUniv.nl
-
-
-Robert Pouliot (krynos@qbc.clic.net): Changes to sysres_Fr.rc have been made.
diff --git a/resources/sysres_Cz.rc b/resources/sysres_Cz.rc
index 9dc052f..e7129d6 100644
--- a/resources/sysres_Cz.rc
+++ b/resources/sysres_Cz.rc
@@ -165,36 +165,38 @@
 }
 
 
-FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84
+FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 236, 62
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Hledání"
 FONT 8, "Helv"
 {
- LTEXT "&Vyhledat:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- CHECKBOX "Pouze &celá slova", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "&Rozlišovat malá a velká písmena", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- GROUPBOX "Smìr", 1072, 90, 40, 80, 40, BS_GROUPBOX
- RADIOBUTTON "&Nahoru", 1056, 100, 50, 50, 12
- RADIOBUTTON "&Dolu", 1057, 150, 50, 50, 12
- DEFPUSHBUTTON "Vyhledat d&alší", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Zavøít", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Vyhledat:", -1, 4, 8, 42, 8
+ EDITTEXT 1152, 47, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Pouze &celá slova", 1040, 4, 26, 100, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Rozlišovat malá a velká písmena", 1041, 4, 42, 64, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ GROUPBOX "Smìr", 1072, 107, 26, 68, 28
+ CONTROL "N&ahoru", 1056, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 111, 38, 20, 12
+ CONTROL "&Dolu", 1057, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 138, 38, 30, 12
+ DEFPUSHBUTTON "Vyhledat d&alší", 1, 182, 5, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Zavøít", 2, 182, 23, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Nápovìda", 1038, 182, 45, 50, 14, WS_GROUP | WS_TABSTOP
 }
 
 
-REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114
+REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 230, 94
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Zámìna"
 FONT 8, "Helv"
 {
- LTEXT "&Vyhledat:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- LTEXT "&Zamìnit za:", 1090, 6, 26, 40, 9
- LTEXT "", 1091, 60, 26, 150, 9
- CHECKBOX "Pouze &celá slova", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "&Rozlišovat malá a velká písmena", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- DEFPUSHBUTTON "Vyhledat d&alší", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Za&mìnit", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Zamìnit ve vý&bìru", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Zavøít", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Vyhledat:", -1, 4, 9, 48, 8
+ EDITTEXT 1152, 54, 7, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT "&Zamìnit za:", -1, 4, 26, 48, 8
+ EDITTEXT 1153, 54, 24, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Pouze &celá slova", 1040, 5, 46, 104, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Rozlišovat malá a velká písmena", 1041, 5, 62, 59, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ DEFPUSHBUTTON "Vyhledat d&alší", 1, 174, 4, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Za&mìnit", 1024, 174, 21, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Zamìnit ve vý&bìru", 1025, 174, 38, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Zavøít", 2, 174, 55, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Nápovìda", 1038, 174, 75, 50, 14, WS_GROUP | WS_TABSTOP
 }
diff --git a/resources/sysres_Da.rc b/resources/sysres_Da.rc
index df9c11f..9a7c700 100644
--- a/resources/sysres_Da.rc
+++ b/resources/sysres_Da.rc
@@ -165,36 +165,38 @@
 }
 
 
-FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84
+FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 236, 62
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Find"
 FONT 8, "Helv"
 {
- LTEXT "&Find hvad:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- CHECKBOX "Kun &hele ord", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Forskel på store/små &bogstaver", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- GROUPBOX "Retning", 1072, 90, 40, 80, 40, BS_GROUPBOX
- RADIOBUTTON "&Op", 1056, 100, 50, 50, 12
- RADIOBUTTON "&Ned", 1057, 150, 50, 50, 12
- DEFPUSHBUTTON "&Find næste", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Annuller", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Find hvad:", -1, 4, 8, 42, 8
+ EDITTEXT 1152, 47, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Kun hele ord", 1040, 4, 26, 100, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Forskel på store/små &bogstaver", 1041, 4, 42, 64, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ GROUPBOX "Retning", 1072, 107, 26, 68, 28
+ CONTROL "&Op", 1056, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 111, 38, 20, 12
+ CONTROL "&Ned", 1057, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 138, 38, 30, 12
+ DEFPUSHBUTTON "&Find næste", 1, 182, 5, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Annuller", 2, 182, 23, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hjælp", 1038, 182, 45, 50, 14, WS_GROUP | WS_TABSTOP
 }
 
 
-REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114
+REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 230, 94
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Erstat"
 FONT 8, "Helv"
 {
- LTEXT "&Find hvad:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- LTEXT "&Erstat med:", 1090, 6, 26, 40, 9
- LTEXT "", 1091, 60, 26, 150, 9
- CHECKBOX "Kun &hele ord", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Forskel på store/små &bogstaver", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- DEFPUSHBUTTON "&Find næste", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Erstat", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Erstat &alle", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Afbryd", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Find hvad:",  -1, 4, 9, 48, 8
+ EDITTEXT 1152, 54, 7, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT "&Erstat med:", -1, 4, 26, 48, 8
+ EDITTEXT 1153, 54, 24, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Kun hele ord", 1040, 5, 46, 104, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ CHECKBOX "Forskel på store/små &bogstaver", 1041, 5, 62, 59, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ DEFPUSHBUTTON "&Find næste", 1, 174, 4, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Erstat", 1024, 174, 21, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Erstat &alle", 1025, 174, 38, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Annuller", 2, 174, 55, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hjælp", 1038, 174, 75, 50, 14, WS_GROUP | WS_TABSTOP
 }
diff --git a/resources/sysres_De.rc b/resources/sysres_De.rc
index 770d011..abb8f60 100644
--- a/resources/sysres_De.rc
+++ b/resources/sysres_De.rc
@@ -165,37 +165,38 @@
 }
 
 
-FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84
+FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 236, 62
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Suchen"
 FONT 8, "Helv"
 {
- LTEXT "S&uchen nach:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- CHECKBOX "Nur ganze &Worte", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Beachte Groß/Kleinschreibung", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- GROUPBOX "Richtung", 1072, 90, 40, 80, 40, BS_GROUPBOX
- RADIOBUTTON "&Hoch", 1056, 100, 50, 50, 12
- RADIOBUTTON "&Runter", 1057, 150, 50, 50, 12
- DEFPUSHBUTTON "&Nächsten finden", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Abbrechen", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "S&uchen nach:", -1, 4, 8, 42, 8
+ EDITTEXT 1152, 47, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Nur ganze &Worte", 1040, 4, 26, 100, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Beachte Groß/Kleinschreibung", 1041, 4, 42, 64, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ GROUPBOX "Richtung", 1072, 107, 26, 68, 28
+ CONTROL "H&och", 1056, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 111, 38, 20, 12
+ CONTROL "&Runter", 1057, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 138, 38, 30, 12
+ DEFPUSHBUTTON "&Nächsten finden", 1, 182, 5, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Abbrechen", 2, 182, 23, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hilfe", 1038, 182, 45, 50, 14, WS_GROUP | WS_TABSTOP
 }
 
 
-REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114
+REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 230, 94
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Ersetzen"
 FONT 8, "Helv"
 {
- LTEXT "S&uchen nach:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- LTEXT "Ersetzen &durch:", 1090, 6, 26, 40, 9
- LTEXT "", 1091, 60, 26, 150, 9
- CHECKBOX "Nur ganze &Worte", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Beachte Groß/Kleinschreibung", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- DEFPUSHBUTTON "&Nächsten finden", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Ersetzen", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Alle ersetzen", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Abbrechen", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "S&uchen nach:", -1, 4, 9, 48, 8
+ EDITTEXT 1152, 54, 7, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT "Ersetzen &durch:", -1, 4, 26, 48, 8
+ EDITTEXT 1153, 54, 24, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Nur ganze &Worte", 1040, 5, 46, 104, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Beachte Groß/Kleinschreibung", 1041, 5, 62, 59, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ DEFPUSHBUTTON "&Nächsten finden", 1, 174, 4, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Ersetzen", 1024, 174, 21, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Alle ersetzen", 1025, 174, 38, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Abbrechen", 2, 174, 55, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hilfe", 1038, 174, 75, 50, 14, WS_GROUP | WS_TABSTOP
 }
-
diff --git a/resources/sysres_Eo.rc b/resources/sysres_Eo.rc
index 09b3a93..da223ee 100644
--- a/resources/sysres_Eo.rc
+++ b/resources/sysres_Eo.rc
@@ -165,37 +165,38 @@
 }
 
 
-FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84
+FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 236, 62
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Seræu"
 FONT 8, "Helv"
 {
- LTEXT "&Seræu:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- CHECKBOX "Nur tutan &vorton", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Atentu &Usklecon", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- GROUPBOX "Direkto", 1072, 90, 40, 80, 40, BS_GROUPBOX
- RADIOBUTTON "&Retro", 1056, 100, 50, 50, 12
- RADIOBUTTON "&Antaýen", 1057, 150, 50, 50, 12
- DEFPUSHBUTTON "&Pluseræu", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Nuligu", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Seræu:", -1, 4, 8, 42, 8
+ EDITTEXT 1152, 47, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Nur tutan &vorton", 1040, 4, 26, 100, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Atentu &Usklecon", 1041, 4, 42, 64, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ GROUPBOX "Direkto", 1072, 107, 26, 68, 28
+ CONTROL "&Retro", 1056, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 111, 38, 20, 12
+ CONTROL "&Antaýen", 1057, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 138, 38, 30, 12
+ DEFPUSHBUTTON "&Pluseræu", 1, 182, 5, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Nuligu", 2, 182, 23, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Helpu", 1038, 182, 45, 50, 14, WS_GROUP | WS_TABSTOP
 }
 
 
-REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114
+REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 230, 94
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Anstataýigu"
 FONT 8, "Helv"
 {
- LTEXT "Anstataýigu:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- LTEXT "&per:", 1090, 6, 26, 40, 9
- LTEXT "", 1091, 60, 26, 150, 9
- CHECKBOX "Nur tutan &vorton", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Atentu &Usklecon", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- DEFPUSHBUTTON "Plu&seræu", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Anstataýigu", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Anstataýigu æ&iujn", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Nuligu", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "Anstataýigu:", -1, 4, 9, 48, 8
+ EDITTEXT 1152, 54, 7, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT "&per:", -1, 4, 26, 48, 8
+ EDITTEXT 1153, 54, 24, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Nur tutan &vorton", 1040, 5, 46, 104, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Atentu &Usklecon", 1041, 5, 62, 59, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ DEFPUSHBUTTON "Plu&seræu", 1, 174, 4, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Anstataýigu", 1024, 174, 21, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Anstataýigu æ&iujn", 1025, 174, 38, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Nuligu", 2, 174, 55, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Helpu", 1038, 174, 75, 50, 14, WS_GROUP | WS_TABSTOP
 }
-
diff --git a/resources/sysres_Es.rc b/resources/sysres_Es.rc
index c472ae9..235fdd9 100644
--- a/resources/sysres_Es.rc
+++ b/resources/sysres_Es.rc
@@ -166,37 +166,38 @@
 }
 
 
-FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84
+FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 236, 62
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Buscar"
 FONT 8, "Helv"
 {
- LTEXT "Buscar:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- CHECKBOX "&Comparar palabra entera solamente", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "&Mayúsculas/minúsculas", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- GROUPBOX "Dirección", 1072, 90, 40, 80, 40, BS_GROUPBOX
- RADIOBUTTON "A&rriba", 1056, 100, 50, 50, 12
- RADIOBUTTON "&Abajo", 1057, 150, 50, 50, 12
- DEFPUSHBUTTON "Buscar &siguiente", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Cancelar", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "Buscar:",  -1, 4, 8, 42, 8
+ EDITTEXT 1152, 47, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Comparar palabra entera solamente", 1040, 4, 26, 100, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Mayúsculas/minúsculas", 1041, 4, 42, 64, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ GROUPBOX "Dirección", 1072, 107, 26, 68, 28
+ CONTROL "A&rriba", 1056, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 111, 38, 20, 12
+ CONTROL "&Abajo", 1057, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 138, 38, 30, 12
+ DEFPUSHBUTTON "Buscar &siguiente", 1, 182, 5, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancelar", 2, 182, 23, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "A&yuda", 1038, 182, 45, 50, 14, WS_GROUP | WS_TABSTOP
 }
 
 
-REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114
+REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 230, 94
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "R&eemplazar"
 FONT 8, "Helv"
 {
- LTEXT "Buscar:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- LTEXT "Re&place With:", 1090, 6, 26, 40, 9
- LTEXT "", 1091, 60, 26, 150, 9
- CHECKBOX "&Comparar palabra entera solamente", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "&Mayúsculas/minúsculas", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- DEFPUSHBUTTON "Reemplazar &siguiente", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Reemplazar", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Reemplazar &todo", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Cancelar", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "Buscar:", -1, 4, 9, 48, 8
+ EDITTEXT 1152, 54, 7, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT "Re&emplazar por:", 1090, -1, 4, 26, 48, 8
+ EDITTEXT 1153, 54, 24, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Comparar palabra entera solamente", 1040, 5, 46, 104, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Mayúsculas/minúsculas", 1041, 5, 62, 59, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ DEFPUSHBUTTON "Reemplazar &siguiente", 1, 174, 4, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Reemplazar", 1024, 174, 21, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Reemplazar &todo", 1025, 174, 38, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancelar", 2, 174, 55, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "A&yuda", 1038, 174, 75, 50, 14, WS_GROUP | WS_TABSTOP
 }
-
diff --git a/resources/sysres_Fi.rc b/resources/sysres_Fi.rc
index 9a9f7a2..447f426 100644
--- a/resources/sysres_Fi.rc
+++ b/resources/sysres_Fi.rc
@@ -165,36 +165,38 @@
 }
 
 
-FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84
+FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 236, 62
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Etsi"
 FONT 8, "Helv"
 {
- LTEXT "&Etsittävä:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- CHECKBOX "&Koko sana", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Kirjaink&oko", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- GROUPBOX "Suunta", 1072, 90, 40, 80, 40, BS_GROUPBOX
- RADIOBUTTON "&Ylös", 1056, 100, 50, 50, 12
- RADIOBUTTON "&Alas", 1057, 150, 50, 50, 12
- DEFPUSHBUTTON "Etsi &seuraava", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Peruuta", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Etsittävä:", -1, 4, 8, 42, 8
+ EDITTEXT 1152, 47, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Koko sana", 1040, 4, 26, 100, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Kirjaink&oko", 1041, 4, 42, 64, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ GROUPBOX "Suunta", 1072, 107, 26, 68, 28
+ CONTROL "&Ylös", 1056, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 111, 38, 20, 12
+ CONTROL "&Alas", 1057, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 138, 38, 30, 12
+ DEFPUSHBUTTON "Etsi &seuraava", 1, 182, 5, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Peruuta", 2, 182, 23, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "O&hje", 1038, 182, 45, 50, 14, WS_GROUP | WS_TABSTOP
 }
 
 
-REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114
+REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 230, 94
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Korvaa"
 FONT 8, "Helv"
 {
- LTEXT "&Etsittävä:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- LTEXT "Ko&rvattava:", 1090, 6, 26, 40, 9
- LTEXT "", 1091, 60, 26, 150, 9
- CHECKBOX "&Koko sana", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Kirjaink&oko", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- DEFPUSHBUTTON "Etsi &seuraava", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Korv&aa", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Korvaa ka&ikki", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "S&ulje", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Etsittävä:", -1, 4, 9, 48, 8
+ EDITTEXT 1152, 54, 7, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT "Ko&rvattava:", -1, 4, 26, 48, 8
+ EDITTEXT 1153, 54, 24, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Koko sana", 1040, 5, 46, 104, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Kirjaink&oko", 1041, 5, 62, 59, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ DEFPUSHBUTTON "Etsi &seuraava", 1, 174, 4, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Korv&aa", 1024, 174, 21, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Korvaa ka&ikki", 1025, 174, 38, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "S&ulje", 2, 174, 55, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "O&hje", 1038, 174, 75, 50, 14, WS_GROUP | WS_TABSTOP
 }
diff --git a/resources/sysres_No.rc b/resources/sysres_No.rc
index f7ca625..f208f75 100644
--- a/resources/sysres_No.rc
+++ b/resources/sysres_No.rc
@@ -165,36 +165,38 @@
 }
 
 
-FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84
+FIND_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 236, 62
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Finn"
 FONT 8, "Helv"
 {
- LTEXT "&Finn hva:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- CHECKBOX "&Kun hele ord", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "&Skill på store/små bokstaver", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- GROUPBOX "Retning", 1072, 90, 40, 80, 40, BS_GROUPBOX
- RADIOBUTTON "&Opp", 1056, 100, 50, 50, 12
- RADIOBUTTON "&Ned", 1057, 150, 50, 50, 12
- DEFPUSHBUTTON "&Finn neste", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Avbryt", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Finn hva:", -1, 4, 8, 42, 8
+ EDITTEXT 1152, 47, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Kun hele ord", 1040, 4, 26, 100, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Skill på store/små bokstaver", 1041, 4, 42, 64, 12, BS_AUTOCHECKBOX | WS_TABSTOP
+ GROUPBOX "Retning", 1072, 107, 26, 68, 28
+ CONTROL "&Opp", 1056, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 111, 38, 20, 12
+ CONTROL "&Ned", 1057, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 138, 38, 30, 12
+ DEFPUSHBUTTON "&Finn neste", 1, 182, 5, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 182, 23, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hjelp", 1038, 182, 45, 50, 14, WS_GROUP | WS_TABSTOP
 }
 
 
-REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114
+REPLACE_TEXT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 230, 94
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Bytt"
 FONT 8, "Helv"
 {
- LTEXT "&Finn hva:", 1088, 6, 6, 40, 9
- LTEXT "", 1089, 60, 6, 150, 9
- LTEXT "&Bytt med:", 1090, 6, 26, 40, 9
- LTEXT "", 1091, 60, 26, 150, 9
- CHECKBOX "&Kun hele ord", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "&Skill på store/små bokstaver", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- DEFPUSHBUTTON "&Finn neste", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Bytt", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Bytt alt", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "Avbryt", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Finn hva:", -1, 4, 9, 48, 8
+ EDITTEXT 1152, 54, 7, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT "&Bytt med:", -1, 4, 26, 48, 8 
+ EDITTEXT 1153, 54, 24, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Kun hele ord", 1040, 5, 46, 104, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Skill på store/små bokstaver", 1041, 5, 62, 59, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ DEFPUSHBUTTON "&Finn neste", 1, 174, 4, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Bytt", 1024, 174, 21, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Bytt alt", 1025, 174, 38, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 174, 55, 50, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hjelp", 1038, 174, 75, 50, 14, WS_GROUP | WS_TABSTOP
 }
diff --git a/tools/build.c b/tools/build.c
index 04f7a68..9e994f0 100644
--- a/tools/build.c
+++ b/tools/build.c
@@ -1,21 +1,23 @@
 /*
  * Copyright 1993 Robert J. Amstadt
- * Copyright 1995 Alexandre Julliard
  * Copyright 1995 Martin von Loewis
+ * Copyright 1995, 1996 Alexandre Julliard
  */
 
+#ifndef WINELIB
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include "wine.h"
+#include "registers.h"
 #include "winerror.h"  /* for ERROR_CALL_NOT_IMPLEMENTED */
 #include "module.h"
 #include "neexe.h"
 #include "windows.h"
 
 /* ELF symbols do not have an underscore in front */
-#if defined (__ELF__) || defined (__svr4__)
+#if defined (__ELF__) || defined (__svr4__) || defined(_SCO_DS)
 #define PREFIX
 #else
 #define PREFIX "_"
@@ -91,19 +93,8 @@
 
   /* Offset of register relative to the end of the context struct */
 #define CONTEXTOFFSET(reg) \
-   ((int)&(((struct sigcontext_struct *)1)->reg) - 1 \
-    - sizeof(struct sigcontext_struct))
-#ifdef __svr4__
-#define sc_eax uc_mcontext.gregs[EAX]
-#define sc_ebx uc_mcontext.gregs[EBX]
-#define sc_ecx uc_mcontext.gregs[ECX]
-#define sc_edx uc_mcontext.gregs[EDX]
-#define sc_esi uc_mcontext.gregs[ESI]
-#define sc_edi uc_mcontext.gregs[EDI]
-#define sc_ds uc_mcontext.gregs[DS]
-#define sc_es uc_mcontext.gregs[ES]
-#define sc_eflags uc_mcontext.gregs[EFL]
-#endif
+  ((int)&reg##_reg((struct sigcontext_struct *)0) \
+   - sizeof(struct sigcontext_struct))
 
 static void *xmalloc (size_t size)
 {
@@ -527,39 +518,77 @@
 }
 
 
-static int OutputVariableCode( char *storage, ORDDEF *odp )
+/*******************************************************************
+ *         StoreVariableCode
+ *
+ * Store a list of ints into a byte array.
+ */
+static int StoreVariableCode( unsigned char *buffer, int size, ORDDEF *odp )
 {
     ORDVARDEF *vdp;
     int i;
 
     vdp = odp->additional_data;
-    printf( "\t.data\n" );
-    for (i = 0; i < vdp->n_values; i++)
+    switch(size)
     {
-	if ((i & 7) == 0)
-	    printf( "\t%s\t", storage);
-	    
-	printf( "%d", vdp->values[i]);
-	
-	if ((i & 7) == 7 || i == vdp->n_values - 1) printf( "\n");
-	else printf( ", ");
+    case 1:
+        for (i = 0; i < vdp->n_values; i++)
+            buffer[i] = vdp->values[i];
+        break;
+    case 2:
+        for (i = 0; i < vdp->n_values; i++)
+            ((unsigned short *)buffer)[i] = vdp->values[i];
+        break;
+    case 4:
+        for (i = 0; i < vdp->n_values; i++)
+            ((unsigned int *)buffer)[i] = vdp->values[i];
+        break;
     }
-    printf( "\n");
-    printf( "\t.text\n" );
-    return vdp->n_values;
+    return vdp->n_values * size;
 }
 
 
 /*******************************************************************
- *         BuildModule
+ *         DumpBytes
  *
- * Build the in-memory representation of the module, and dump it
+ * Dump a byte stream into the assembly code.
+ */
+static void DumpBytes( const unsigned char *data, int len,
+                       const char *section, const char *label_start,
+                       const char *label_end )
+{
+    int i;
+    if (section) printf( "\t%s\n", section );
+    if (label_start)
+    {
+        printf( "\t.globl " PREFIX "%s_%s\n", DLLName, label_start );
+        printf( PREFIX "%s_%s:\n", DLLName, label_start );
+    }
+    for (i = 0; i < len; i++)
+    {
+        if (!(i & 0x0f)) printf( "\t.byte " );
+        printf( "%d", *data++ );
+        if (i < len - 1) printf( "%c", ((i & 0x0f) != 0x0f) ? ',' : '\n' );
+    }
+    printf( "\n" );
+    if (label_end)
+    {
+        printf( "\t.globl " PREFIX "%s_%s\n", DLLName, label_end );
+        printf( PREFIX "%s_%s:\n", DLLName, label_end );
+    }
+}
+
+
+/*******************************************************************
+ *         BuildModule16
+ *
+ * Build the in-memory representation of a 16-bit NE module, and dump it
  * as a byte stream into the assembly code.
  */
-static void BuildModule( int max_code_offset, int max_data_offset )
+static void BuildModule16( int max_code_offset, int max_data_offset )
 {
     ORDDEF *odp;
-    int i, size;
+    int i;
     char *buffer;
     NE_MODULE *pModule;
     SEGTABLEENTRY *pSegment;
@@ -728,18 +757,120 @@
 
       /* Dump the module content */
 
-    printf( "\t.data\n" );
-    printf( "\t.globl " PREFIX "%s_Module_Start\n", DLLName );
-    printf( PREFIX "%s_Module_Start:\n", DLLName );
-    size = (int)pstr - (int)pModule;
-    for (i = 0, pstr = buffer; i < size; i++, pstr++)
-    {
-        if (!(i & 7)) printf( "\t.byte " );
-        printf( "%d%c", *pstr, ((i & 7) != 7) ? ',' : '\n' );
-    }
-    if (i & 7) printf( "0\n" );
-    printf( "\t.globl " PREFIX "%s_Module_End\n", DLLName );
-    printf( PREFIX "%s_Module_End:\n", DLLName );
+    DumpBytes( (char *)pModule, (int)pstr - (int)pModule,
+               ".data", "Module_Start", "Module_End" );
+}
+
+
+/*******************************************************************
+ *         BuildModule32
+ *
+ * Build the in-memory representation of a 32-bit pseudo-NE module, and dump it
+ * as a byte stream into the assembly code.
+ */
+static void BuildModule32(void)
+{
+    char *buffer;
+    NE_MODULE *pModule;
+    NE_WIN32_EXTRAINFO *pExtraInfo;
+    OFSTRUCT *pFileInfo;
+    BYTE *pstr;
+    WORD *pword;
+
+    /*   Module layout:
+     * NE_MODULE            Module
+     * NE_WIN32_EXTRAINFO   Win32 module extra info
+     * OFSTRUCT             File information
+     * SEGTABLEENTRY        Segment table (empty)
+     * WORD[2]              Resource table (empty)
+     * BYTE[2]              Imported names (empty)
+     * BYTE[n]              Resident names table (1 entry)
+     * BYTE[n]              Entry table (empty)
+     */
+
+    buffer = xmalloc( 0x10000 );
+
+    pModule = (NE_MODULE *)buffer;
+    pModule->magic = NE_SIGNATURE;
+    pModule->count = 1;
+    pModule->next = 0;
+    pModule->flags = NE_FFLAGS_SINGLEDATA | NE_FFLAGS_BUILTIN |
+                     NE_FFLAGS_LIBMODULE | NE_FFLAGS_WIN32;
+    pModule->dgroup = 0;
+    pModule->heap_size = 0;
+    pModule->stack_size = 0;
+    pModule->ip = 0;
+    pModule->cs = 0;
+    pModule->sp = 0;
+    pModule->ss = 0;
+    pModule->seg_count = 0;
+    pModule->modref_count = 0;
+    pModule->nrname_size = 0;
+    pModule->modref_table = 0;
+    pModule->nrname_fpos = 0;
+    pModule->moveable_entries = 0;
+    pModule->alignment = 0;
+    pModule->truetype = 0;
+    pModule->os_flags = NE_OSFLAGS_WINDOWS;
+    pModule->misc_flags = 0;
+    pModule->dlls_to_init  = 0;
+    pModule->nrname_handle = 0;
+    pModule->min_swap_area = 0;
+    pModule->expected_version = 0x030a;
+
+    /* Win32 extra info */
+
+    pExtraInfo = (NE_WIN32_EXTRAINFO *)(pModule + 1);
+    pExtraInfo->pe_module = 0;
+
+      /* File information */
+
+    pFileInfo = (OFSTRUCT *)(pExtraInfo + 1);
+    pModule->fileinfo = (int)pFileInfo - (int)pModule;
+    memset( pFileInfo, 0, sizeof(*pFileInfo) - sizeof(pFileInfo->szPathName) );
+    pFileInfo->cBytes = sizeof(*pFileInfo) - sizeof(pFileInfo->szPathName)
+                        + strlen(DLLName) + 4;
+    sprintf( pFileInfo->szPathName, "%s.DLL", DLLName );
+    pstr = (char *)pFileInfo + pFileInfo->cBytes + 1;
+        
+      /* Segment table */
+
+    pModule->seg_table = (int)pstr - (int)pModule;
+
+      /* Resource table */
+
+    pword = (WORD *)pstr;
+    pModule->res_table = (int)pword - (int)pModule;
+    *pword++ = 0;
+    *pword++ = 0;
+
+      /* Imported names table */
+
+    pstr = (char *)pword;
+    pModule->import_table = (int)pstr - (int)pModule;
+    *pstr++ = 0;
+    *pstr++ = 0;
+
+      /* Resident names table */
+
+    pModule->name_table = (int)pstr - (int)pModule;
+    /* First entry is module name */
+    *pstr = strlen(DLLName );
+    strcpy( pstr + 1, DLLName );
+    pstr += *pstr + 1;
+    *(WORD *)pstr = 0;
+    pstr += sizeof(WORD);
+    *pstr++ = 0;
+
+      /* Entry table */
+
+    pModule->entry_table = (int)pstr - (int)pModule;
+    *pstr++ = 0;
+
+      /* Dump the module content */
+
+    DumpBytes( (char *)pModule, (int)pstr - (int)pModule,
+               ".data", "Module_Start", "Module_End" );
 }
 
 
@@ -757,6 +888,7 @@
 
     printf( "/* File generated automatically; do not edit! */\n" );
     printf( "\t.text\n" );
+    printf( "\t.align 4\n" );
     printf( "\t.globl " PREFIX "%s_Code_Start\n", DLLName );
     printf( PREFIX "%s_Code_Start:\n\n", DLLName );
 
@@ -773,11 +905,9 @@
             printf( "\t.align 4\n" );
             printf( "%s_%d:\n", DLLName, i );
             printf( "\tpushl %%ebp\n" );
-            printf( "\tpushl $%s_%d_Name\n", DLLName, i );
+            printf( "\tpushl $Name_%d\n", i );
             printf( "\tpushl $" PREFIX "%s\n", STUB_CALLBACK );
-            printf( "\tjmp " PREFIX "Stdcall_0\n" );
-            printf( "%s_%d_Name:\n", DLLName, i );
-            printf( "\t.ascii \"%s_%d\\0\"\n", DLLName, i );
+            printf( "\tjmp " PREFIX "CallFrom32_0\n" );
             break;
 
         case TYPE_STDCALL:
@@ -787,11 +917,9 @@
             printf( "\t.align 4\n" );
             printf( "%s_%d:\n", DLLName, i );
             printf( "\tpushl %%ebp\n" );
-            printf( "\tpushl $%s_%d_Name\n", DLLName, i );
+            printf( "\tpushl $Name_%d\n", i );
             printf( "\tpushl $" PREFIX "%s\n", fdp->internal_name );
-            printf( "\tjmp " PREFIX "Stdcall_%d\n", strlen(fdp->arg_types) );
-            printf( "%s_%d_Name:\n", DLLName, i );
-            printf( "\t.ascii \"%s\\0\"\n", odp->export_name );
+            printf( "\tjmp " PREFIX "CallFrom32_%d\n", strlen(fdp->arg_types));
             break;
 
         case TYPE_RETURN:
@@ -804,8 +932,6 @@
             printf( "\tmovl $%d,%%eax\n", rdp->ret_value );
             if (rdp->arg_size) printf( "\tret $%d\n", rdp->arg_size );
             else printf( "\tret\n" );
-            printf( "%s_%d_Name:\n", DLLName, i );
-            printf( "\t.ascii \"%s\\0\"\n", odp->export_name );
             break;
 
         default:
@@ -815,9 +941,13 @@
         }
     }
 
+    BuildModule32();
+
+    printf( "\t.text\n" );
+    printf( "\t.globl " PREFIX "%s_Data_Start\n", DLLName );
+    printf( PREFIX "%s_Data_Start:\n", DLLName );
+    printf( "\t.long %d,%d\n", Base, Limit );
     printf( "\n/* Function table */\n" );
-    printf( "\t.globl " PREFIX "%s_Module_Start\n", DLLName );
-    printf( PREFIX "%s_Module_Start:\n", DLLName );
 
     odp = OrdinalDefinitions;
     for (i = 0; i <= Limit; i++, odp++)
@@ -825,17 +955,19 @@
         if (odp->type == TYPE_INVALID)
             printf( "\t.long 0,%s_%d\n", DLLName, i );
         else
-            printf( "\t.long %s_%d_Name,%s_%d\n",
-                    DLLName, i, DLLName, i );
+            printf( "\t.long Name_%d,%s_%d\n", i, DLLName, i );
     }
-
-    printf( "\t.globl " PREFIX "%s_Module_End\n", DLLName );
-    printf( PREFIX "%s_Module_End:\n", DLLName );
     printf( "\t.long 0,0\n" );
 
-    printf( "\t.globl " PREFIX "%s_Data_Start\n", DLLName );
-    printf( PREFIX "%s_Data_Start:\n", DLLName );
-    printf( "\t.long %d\n", Base );
+    printf( "\n/* Name table */\n" );
+    for (i = 0, odp = OrdinalDefinitions; i <= Limit; i++, odp++)
+    {
+        printf( "Name_%d:\t", i );
+        if (odp->type == TYPE_INVALID)
+            printf( ".ascii \"%s.%d\\0\"\n", DLLName, i );
+        else
+            printf( ".ascii \"%s\\0\"\n", odp->export_name );
+    }
 }
 
 
@@ -851,17 +983,13 @@
     ORDRETDEF *rdp;
     int i;
     int code_offset, data_offset;
+    unsigned char *data;
+
+    data = (unsigned char *)xmalloc( 0x10000 );
+    memset( data, 0, 16 );
+    data_offset = 16;
 
     printf( "/* File generated automatically; do not edit! */\n" );
-    printf( "\t.data\n" );
-    printf( "\t.globl " PREFIX "%s_Data_Start\n", DLLName );
-    printf( PREFIX "%s_Data_Start:\n", DLLName );
-#ifdef __svr4__
-    printf( "\t.4byte 0,0,0,0,0,0,0,0\n" );
-#else
-    printf( "\t.word 0,0,0,0,0,0,0,0\n" );
-#endif
-    data_offset = 16;
     printf( "\t.text\n" );
     printf( "\t.globl " PREFIX "%s_Code_Start\n", DLLName );
     printf( PREFIX "%s_Code_Start:\n", DLLName );
@@ -886,23 +1014,19 @@
           case TYPE_BYTE:
             printf( "/* %s.%d */\n", DLLName, i);
             odp->offset = data_offset;
-            data_offset += OutputVariableCode( ".byte", odp);
+            data_offset += StoreVariableCode( data, 1, odp);
             break;
 
           case TYPE_WORD:
             printf( "/* %s.%d */\n", DLLName, i);
             odp->offset = data_offset;
-#ifdef __svr4__
-            data_offset += 2 * OutputVariableCode( ".4byte", odp);
-#else
-            data_offset += 2 * OutputVariableCode( ".word", odp);
-#endif
+            data_offset += StoreVariableCode( data, 2, odp);
             break;
 
           case TYPE_LONG:
             printf( "/* %s.%d */\n", DLLName, i);
             odp->offset = data_offset;
-            data_offset += 4 * OutputVariableCode( ".long", odp);
+            data_offset += StoreVariableCode( data, 4, odp);
             break;
 
           case TYPE_RETURN:
@@ -911,12 +1035,15 @@
             printf( "\tmovw $%d,%%dx\n", (rdp->ret_value >> 16) & 0xffff);
             printf( "\t.byte 0x66\n");
             if (rdp->arg_size != 0)
-                printf( "\tlret $%d\n", rdp->arg_size);
+                printf( "\tlret $%d\n\n", rdp->arg_size);
             else
+            {
                 printf( "\tlret\n");
+                printf( "\tnop\n");
+                printf( "\tnop\n\n");
+            }
             odp->offset = code_offset;
-            code_offset += 10;  /* Assembly code is 10 bytes long */
-            if (rdp->arg_size != 0) code_offset += 2;
+            code_offset += 12;  /* Assembly code is 12 bytes long */
             break;
 
           case TYPE_REGISTER:
@@ -927,7 +1054,7 @@
             printf( "\tpushw %%bp\n" );
             printf( "\tpushl $0x%08x\n", (DLLId << 16) | i);
             printf( "\tpushl $" PREFIX "%s\n", fdp->internal_name );
-            printf( "\tljmp $0x%04x, $" PREFIX "CallTo32_%s_%s\n\n",
+            printf( "\tljmp $0x%04x, $" PREFIX "CallFrom16_%s_%s\n",
                     WINE_CODE_SELECTOR,
                     (odp->type == TYPE_REGISTER) ? "regs" :
                     (odp->type == TYPE_PASCAL) ? "long" : "word",
@@ -936,7 +1063,7 @@
             printf( "\tnop\n" );
             printf( "\tnop\n" );
             printf( "\tnop\n" );
-            printf( "\tnop\n" );
+            printf( "\tnop\n\n" );
             odp->offset = code_offset;
             code_offset += 24;  /* Assembly code is 24 bytes long */
             break;
@@ -954,7 +1081,13 @@
         code_offset++;
     }
 
-    BuildModule( code_offset, data_offset );
+    /* Output data segment */
+
+    DumpBytes( data, data_offset, NULL, "Data_Start", NULL );
+
+    /* Build the module */
+
+    BuildModule16( code_offset, data_offset );
 }
 
 
@@ -1166,22 +1299,18 @@
 
     /* Store the registers */
 
-    printf( "\tpopl %d(%%ebx)\n", CONTEXTOFFSET(sc_ebx) ); /* Get ebx from stack */
-    printf( "\tmovl %%eax,%d(%%ebx)\n", CONTEXTOFFSET(sc_eax) );
-    printf( "\tmovl %%ecx,%d(%%ebx)\n", CONTEXTOFFSET(sc_ecx) );
-    printf( "\tmovl %%edx,%d(%%ebx)\n", CONTEXTOFFSET(sc_edx) );
-    printf( "\tmovl %%esi,%d(%%ebx)\n", CONTEXTOFFSET(sc_esi) );
-    printf( "\tmovl %%edi,%d(%%ebx)\n", CONTEXTOFFSET(sc_edi) );
+    printf( "\tpopl %d(%%ebx)\n", CONTEXTOFFSET(EBX) ); /* Get ebx from stack*/
+    printf( "\tmovl %%eax,%d(%%ebx)\n", CONTEXTOFFSET(EAX) );
+    printf( "\tmovl %%ecx,%d(%%ebx)\n", CONTEXTOFFSET(ECX) );
+    printf( "\tmovl %%edx,%d(%%ebx)\n", CONTEXTOFFSET(EDX) );
+    printf( "\tmovl %%esi,%d(%%ebx)\n", CONTEXTOFFSET(ESI) );
+    printf( "\tmovl %%edi,%d(%%ebx)\n", CONTEXTOFFSET(EDI) );
     printf( "\tmovw -10(%%ebp),%%ax\n" );  /* Get saved ds from stack */
-    printf( "\tmovw %%ax,%d(%%ebx)\n", CONTEXTOFFSET(sc_ds) );
+    printf( "\tmovw %%ax,%d(%%ebx)\n", CONTEXTOFFSET(DS) );
     printf( "\tmovw -12(%%ebp),%%ax\n" );  /* Get saved es from stack */
-    printf( "\tmovw %%ax,%d(%%ebx)\n", CONTEXTOFFSET(sc_es) );
+    printf( "\tmovw %%ax,%d(%%ebx)\n", CONTEXTOFFSET(ES) );
     printf( "\tpushfl\n" );
-#ifndef __FreeBSD__
-    printf( "\tpopl %d(%%ebx)\n", CONTEXTOFFSET(sc_eflags) );
-#else    
-    printf( "\tpopl %d(%%ebx)\n", CONTEXTOFFSET(sc_efl) );
-#endif
+    printf( "\tpopl %d(%%ebx)\n", CONTEXTOFFSET(EFL) );
 }
 
 
@@ -1198,28 +1327,24 @@
 
     /* Restore the registers */
 
-    printf( "\tmovl %d(%%ebx),%%ecx\n", CONTEXTOFFSET(sc_ecx) );
-    printf( "\tmovl %d(%%ebx),%%edx\n", CONTEXTOFFSET(sc_edx) );
-    printf( "\tmovl %d(%%ebx),%%esi\n", CONTEXTOFFSET(sc_esi) );
-    printf( "\tmovl %d(%%ebx),%%edi\n", CONTEXTOFFSET(sc_edi) );
+    printf( "\tmovl %d(%%ebx),%%ecx\n", CONTEXTOFFSET(ECX) );
+    printf( "\tmovl %d(%%ebx),%%edx\n", CONTEXTOFFSET(EDX) );
+    printf( "\tmovl %d(%%ebx),%%esi\n", CONTEXTOFFSET(ESI) );
+    printf( "\tmovl %d(%%ebx),%%edi\n", CONTEXTOFFSET(EDI) );
     printf( "\tpopl %%eax\n" );  /* Remove old ds and es from stack */
-    printf( "\tpushw %d(%%ebx)\n", CONTEXTOFFSET(sc_ds) ); /* Push new ds */
-    printf( "\tpushw %d(%%ebx)\n", CONTEXTOFFSET(sc_es) ); /* Push new es */
-#ifndef __FreeBSD__
-    printf( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(sc_eflags) );
-#else    
-    printf( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(sc_efl) );
-#endif
+    printf( "\tpushw %d(%%ebx)\n", CONTEXTOFFSET(DS) ); /* Push new ds */
+    printf( "\tpushw %d(%%ebx)\n", CONTEXTOFFSET(ES) ); /* Push new es */
+    printf( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(EFL) );
     printf( "\tpopfl\n" );
-    printf( "\tmovl %d(%%ebx),%%eax\n", CONTEXTOFFSET(sc_eax) );
-    printf( "\tmovl %d(%%ebx),%%ebx\n", CONTEXTOFFSET(sc_ebx) );
+    printf( "\tmovl %d(%%ebx),%%eax\n", CONTEXTOFFSET(EAX) );
+    printf( "\tmovl %d(%%ebx),%%ebx\n", CONTEXTOFFSET(EBX) );
 }
 
 
 /*******************************************************************
- *         BuildCall32Func
+ *         BuildCallFrom16Func
  *
- * Build a 32-bit callback function. The syntax of the function
+ * Build a 16-bit-to-Wine callback function. The syntax of the function
  * profile is: type_xxxxx, where 'type' is one of 'regs', 'word' or
  * 'long' and each 'x' is an argument ('w'=word, 's'=signed word,
  * 'l'=long, 'p'=pointer).
@@ -1236,7 +1361,7 @@
  * (sp)     entrypoint (long)
  *
  */
-static void BuildCall32Func( char *profile )
+static void BuildCallFrom16Func( char *profile )
 {
     int argsize = 0;
     int short_ret = 0;
@@ -1256,11 +1381,11 @@
     /* Function header */
 
     printf( "/**********\n" );
-    printf( " * " PREFIX "CallTo32_%s\n", profile );
+    printf( " * " PREFIX "CallFrom16_%s\n", profile );
     printf( " **********/\n" );
     printf( "\t.align 4\n" );
-    printf( "\t.globl " PREFIX "CallTo32_%s\n\n", profile );
-    printf( PREFIX "CallTo32_%s:\n", profile );
+    printf( "\t.globl " PREFIX "CallFrom16_%s\n\n", profile );
+    printf( PREFIX "CallFrom16_%s:\n", profile );
 
     /* Setup bp to point to its copy on the stack */
 
@@ -1320,9 +1445,9 @@
     if (debugging)
     {
         printf( "\tpushl %%eax\n" );
-        printf( "\tpushl $CALL32_Str_%s\n", profile );
+        printf( "\tpushl $Profile_%s\n", profile );
         printf( "\tpushl $%d\n", reg_func ? 2 : (short_ret ? 1 : 0) );
-        printf( "\tcall " PREFIX "RELAY_DebugCall32\n" );
+        printf( "\tcall " PREFIX "RELAY_DebugCallFrom16\n" );
         printf( "\tpopl %%eax\n" );
         printf( "\tpopl %%eax\n" );
         printf( "\tpopl %%eax\n" );
@@ -1338,7 +1463,7 @@
     {
         printf( "\tpushl %%eax\n" );
         printf( "\tpushl $%d\n", reg_func ? 2 : (short_ret ? 1 : 0) );
-        printf( "\tcall " PREFIX "RELAY_DebugReturn\n" );
+        printf( "\tcall " PREFIX "RELAY_DebugCallFrom16Ret\n" );
         printf( "\tpopl %%eax\n" );
         printf( "\tpopl %%eax\n" );
     }
@@ -1436,9 +1561,9 @@
 
 
 /*******************************************************************
- *         BuildCall16Func
+ *         BuildCallTo16Func
  *
- * Build a 16-bit callback function.
+ * Build a Wine-to-16-bit callback function.
  *
  * Stack frame of the callback function:
  *  ...      ...
@@ -1457,7 +1582,7 @@
  *                               WORD ax, WORD bx, WORD cx, WORD dx,
  *                               WORD si, WORD di );
  */
-static void BuildCall16Func( char *profile )
+static void BuildCallTo16Func( char *profile )
 {
     int short_ret = 0;
     int reg_func = 0;
@@ -1514,7 +1639,7 @@
         printf( "\taddl $12,%%eax\n" );
         printf( "\tpushl $%d\n", reg_func ? 8 : strlen(args) );
         printf( "\tpushl %%eax\n" );
-        printf( "\tcall " PREFIX "RELAY_DebugCall16\n" );
+        printf( "\tcall " PREFIX "RELAY_DebugCallTo16\n" );
         printf( "\tpopl %%eax\n" );
         printf( "\tpopl %%eax\n" );
     }
@@ -1545,7 +1670,7 @@
     {
         int pos = 20;  /* first argument position */
 
-        /* Make %bp point to the previous stackframe (built by CallTo32) */
+        /* Make %bp point to the previous stackframe (built by CallFrom16) */
         printf( "\tmovw %%sp,%%bp\n" );
         printf( "\taddw $16,%%bp\n" );
 
@@ -1566,7 +1691,7 @@
 
     /* Push the return address */
 
-    printf( "\tpushl " PREFIX "CALL16_RetAddr_%s\n",
+    printf( "\tpushl " PREFIX "CALLTO16_RetAddr_%s\n",
             short_ret ? "word" : "long" );
 
     /* Push the called routine address */
@@ -1605,16 +1730,16 @@
  */
 static void BuildRet16Func()
 {
-    printf( "\t.globl " PREFIX "CALL16_Ret_word\n" );
-    printf( "\t.globl " PREFIX "CALL16_Ret_long\n" );
+    printf( "\t.globl " PREFIX "CALLTO16_Ret_word\n" );
+    printf( "\t.globl " PREFIX "CALLTO16_Ret_long\n" );
 
     /* Put return value into eax */
 
-    printf( PREFIX "CALL16_Ret_long:\n" );
+    printf( PREFIX "CALLTO16_Ret_long:\n" );
     printf( "\tpushw %%dx\n" );
     printf( "\tpushw %%ax\n" );
     printf( "\tpopl %%eax\n" );
-    printf( PREFIX "CALL16_Ret_word:\n" );
+    printf( PREFIX "CALLTO16_Ret_word:\n" );
 
     /* Restore 32-bit segment registers */
 
@@ -1653,18 +1778,19 @@
     /* Declare the return address variables */
 
     printf( "\t.data\n" );
-    printf( "\t.globl " PREFIX "CALL16_RetAddr_word\n" );
-    printf( "\t.globl " PREFIX "CALL16_RetAddr_long\n" );
-    printf( PREFIX "CALL16_RetAddr_word:\t.long 0\n" );
-    printf( PREFIX "CALL16_RetAddr_long:\t.long 0\n" );
+    printf( "\t.globl " PREFIX "CALLTO16_RetAddr_word\n" );
+    printf( "\t.globl " PREFIX "CALLTO16_RetAddr_long\n" );
+    printf( PREFIX "CALLTO16_RetAddr_word:\t.long 0\n" );
+    printf( PREFIX "CALLTO16_RetAddr_long:\t.long 0\n" );
     printf( "\t.text\n" );
 }
 
 
 /*******************************************************************
- *         BuildStdcallFunc
+ *         BuildCallFrom32Func
  *
- * Build a stdcall call-back function. 'args' is the number of dword arguments.
+ * Build a 32-bit-to-Wine call-back function.
+ * 'args' is the number of dword arguments.
  *
  * Stack layout:
  *   ...     ...
@@ -1675,35 +1801,27 @@
  * (ebp-4)   func name
  * (ebp-8)   entry point
  */
-static void BuildStdcallFunc( int args )
+static void BuildCallFrom32Func( int args )
 {
     /* Function header */
 
     printf( "/**********\n" );
-    printf( " * " PREFIX "Stdcall_%d\n", args );
+    printf( " * " PREFIX "CallFrom32_%d\n", args );
     printf( " **********/\n" );
     printf( "\t.align 4\n" );
-    printf( "\t.globl " PREFIX "Stdcall_%d\n\n", args );
-    printf( PREFIX "Stdcall_%d:\n", args );
+    printf( "\t.globl " PREFIX "CallFrom32_%d\n\n", args );
+    printf( PREFIX "CallFrom32_%d:\n", args );
 
     /* Entry code */
 
     printf( "\tleal 8(%%esp),%%ebp\n" );
 
-#if 0
-    /* Switch to the internal stack */
-
-    printf( "\tpushl " PREFIX "IF1632_Saved32_esp\n" );
-    printf( "\tmovl %%esp, " PREFIX "IF1632_Saved32_esp\n" );
-    printf( "\tmovl " PREFIX "IF1632_Original32_esp, %%esp\n" );
-#endif
-
     /* Print the debugging info */
 
     if (debugging)
     {
         printf( "\tpushl $%d\n", args );
-        printf( "\tcall " PREFIX "RELAY_DebugStdcall\n" );
+        printf( "\tcall " PREFIX "RELAY_DebugCallFrom32\n" );
         printf( "\tadd $4, %%esp\n" );
     }
 
@@ -1732,15 +1850,10 @@
     {
         printf( "\tadd $%d,%%esp\n", args ? (args * 4) : 4 );
         printf( "\tpushl %%eax\n" );
-        printf( "\tcall " PREFIX "RELAY_DebugStdcallRet\n" );
+        printf( "\tcall " PREFIX "RELAY_DebugCallFrom32Ret\n" );
         printf( "\tpopl %%eax\n" );
     }
 
-    /* Switch back to the normal stack */
-
-#if 0
-    printf( "\tmovl -12(%%ebp)," PREFIX "IF1632_Saved32_esp\n" );
-#endif
     printf( "\tmovl %%ebp,%%esp\n" );
     printf( "\tpopl %%ebp\n" );
 
@@ -1751,12 +1864,75 @@
 }
 
 
+/*******************************************************************
+ *         BuildCallTo32Func
+ *
+ * Build a Wine-to-32-bit callback function.
+ *
+ * Stack frame of the callback function:
+ *  ...      ...
+ * (ebp+16) arg2
+ * (ebp+12) arg1
+ * (ebp+8)  func to call
+ * (ebp+4)  return address
+ * (ebp)    previous ebp
+ *
+ * Prototype for the CallTo32 functions:
+ *   extern LONG CallTo32_nn( FARPROC func, args... );
+ */
+static void BuildCallTo32Func( int args )
+{
+    /* Function header */
+
+    printf( "/**********\n" );
+    printf( " * " PREFIX "CallTo32_%d\n", args );
+    printf( " **********/\n" );
+    printf( "\t.align 4\n" );
+    printf( "\t.globl " PREFIX "CallTo32_%d\n\n", args );
+    printf( PREFIX "CallTo32_%d:\n", args );
+
+    /* Entry code */
+
+    printf( "\tpushl %%ebp\n" );
+    printf( "\tmovl %%esp,%%ebp\n" );
+
+    /* Transfer arguments */
+
+    if (args)
+    {
+        int i;
+        for (i = args; i > 0; i--) printf( "\tpushl %d(%%ebp)\n", 4 * i + 8 );
+    }
+
+    /* Print the debugging output */
+
+    if (debugging)
+    {
+        printf( "\tpushl $%d\n", args );
+        printf( "\tpushl 8(%%ebp)\n" );
+        printf( "\tcall " PREFIX "RELAY_DebugCallTo32\n" );
+        printf( "\taddl $8,%%esp\n" );
+    }
+
+    /* Call the function */
+
+    printf( "\tcall 8(%%ebp)\n" );
+
+    /* Return to Wine */
+
+    printf( "\tmovl %%ebp,%%esp\n" );
+    printf( "\tpopl %%ebp\n" );
+    printf( "\tret\n" );
+}
+
+
 static void usage(void)
 {
     fprintf(stderr, "usage: build -spec SPECNAMES\n"
-                    "       build -call32 FUNCTION_PROFILES\n"
-                    "       build -call16 FUNCTION_PROFILES\n"
-                    "       build -stdcall FUNCTION_PROFILES\n" );
+                    "       build -callfrom16 FUNCTION_PROFILES\n"
+                    "       build -callto16 FUNCTION_PROFILES\n"
+                    "       build -callfrom32 FUNCTION_PROFILES\n"
+                    "       build -callto32 FUNCTION_PROFILES\n" );
     exit(1);
 }
 
@@ -1771,7 +1947,7 @@
     {
         for (i = 2; i < argc; i++) BuildSpecFiles( argv[i] );
     }
-    else if (!strcmp( argv[1], "-call32" ))  /* 32-bit callbacks */
+    else if (!strcmp( argv[1], "-callfrom16" ))  /* 16-bit-to-Wine callbacks */
     {
         /* File header */
 
@@ -1784,7 +1960,7 @@
 
         /* Build the callback functions */
 
-        for (i = 2; i < argc; i++) BuildCall32Func( argv[i] );
+        for (i = 2; i < argc; i++) BuildCallFrom16Func( argv[i] );
 
         /* Output the argument debugging strings */
 
@@ -1793,32 +1969,32 @@
             printf( "/* Argument strings */\n" );
             for (i = 2; i < argc; i++)
             {
-                printf( "CALL32_Str_%s:\n", argv[i] );
+                printf( "Profile_%s:\n", argv[i] );
                 printf( "\t.ascii \"%s\\0\"\n", argv[i] + 5 );
             }
         }
     }
-    else if (!strcmp( argv[1], "-call16" ))  /* 16-bit callbacks */
+    else if (!strcmp( argv[1], "-callto16" ))  /* Wine-to-16-bit callbacks */
     {
         /* File header */
 
         printf( "/* File generated automatically. Do not edit! */\n\n" );
         printf( "\t.text\n" );
-        printf( "\t.globl " PREFIX "CALL16_Start\n" );
-        printf( PREFIX "CALL16_Start:\n" );
+        printf( "\t.globl " PREFIX "CALLTO16_Start\n" );
+        printf( PREFIX "CALLTO16_Start:\n" );
 
         /* Build the callback functions */
 
-        for (i = 2; i < argc; i++) BuildCall16Func( argv[i] );
+        for (i = 2; i < argc; i++) BuildCallTo16Func( argv[i] );
 
         /* Output the 16-bit return code */
 
         BuildRet16Func();
 
-        printf( "\t.globl " PREFIX "CALL16_End\n" );
-        printf( PREFIX "CALL16_End:\n" );
+        printf( "\t.globl " PREFIX "CALLTO16_End\n" );
+        printf( PREFIX "CALLTO16_End:\n" );
     }
-    else if (!strcmp( argv[1], "-stdcall" ))  /* stdcall callbacks */
+    else if (!strcmp( argv[1], "-callfrom32" ))  /* 32-bit-to-Wine callbacks */
     {
         /* File header */
 
@@ -1827,9 +2003,22 @@
 
         /* Build the callback functions */
 
-        for (i = 2; i < argc; i++) BuildStdcallFunc( atoi(argv[i]) );
+        for (i = 2; i < argc; i++) BuildCallFrom32Func( atoi(argv[i]) );
+    }
+    else if (!strcmp( argv[1], "-callto32" ))  /* Wine-to-32-bit callbacks */
+    {
+        /* File header */
+
+        printf( "/* File generated automatically. Do not edit! */\n\n" );
+        printf( "\t.text\n" );
+
+        /* Build the callback functions */
+
+        for (i = 2; i < argc; i++) BuildCallTo32Func( atoi(argv[i]) );
     }
     else usage();
 
     return 0;
 }
+
+#endif  /* WINELIB */
diff --git a/win32/environment.c b/win32/environment.c
index a9152f1..eff9050 100644
--- a/win32/environment.c
+++ b/win32/environment.c
@@ -10,8 +10,8 @@
 #include "windows.h"
 #include "winerror.h"
 #include "kernel32.h"
+#include "module.h"
 #include "task.h"
-#include "pe_image.h"
 #include "stddebug.h"
 #include "debug.h"
 
@@ -26,7 +26,7 @@
     PDB *pdb = (PDB *)GlobalLock( GetCurrentPDB() );
 
 #ifndef WINELIB
-    strcpy(buffer, wine_files->name);
+    strcpy(buffer, MODULE_GetModuleName( GetExePtr(GetCurrentTask()) ) );
     cp = buffer+strlen(buffer);
     *cp++ = ' ';
 #else
diff --git a/win32/except.c b/win32/except.c
index e789cf8..93de02f 100644
--- a/win32/except.c
+++ b/win32/except.c
@@ -39,17 +39,14 @@
 #include "stddebug.h"
 #include "debug.h"
 #include "except.h"
-#include "relay32.h"
-
-WINAPI DWORD KERNEL32_537(PEXCEPTION_POINTERS ptrs);
 
 LPTOP_LEVEL_EXCEPTION_FILTER pTopExcHandler = NULL;
 
 void EXC_Init(void)
 {
-    WIN32_builtin *dll = RELAY32_GetBuiltinDLL("KERNEL32");
-    pTopExcHandler = (LPTOP_LEVEL_EXCEPTION_FILTER)RELAY32_GetEntryPoint( dll,
-                                             "UnhandledExceptionFilter", 537 );
+    pTopExcHandler = (LPTOP_LEVEL_EXCEPTION_FILTER)PE_GetProcAddress(
+                                                 GetModuleHandle("KERNEL32"),
+                                                 "UnhandledExceptionFilter" );
 }
 
 /*
diff --git a/win32/init.c b/win32/init.c
index 6de4c20..0d53749 100644
--- a/win32/init.c
+++ b/win32/init.c
@@ -12,7 +12,6 @@
 #include "kernel32.h"
 #include "handle32.h"
 #include "except.h"
-#include "pe_image.h"
 #include "task.h"
 #include "stddebug.h"
 #define DEBUG_WIN32
diff --git a/win32/resource.c b/win32/resource.c
index 19a9e41..7d55ec9 100644
--- a/win32/resource.c
+++ b/win32/resource.c
@@ -16,6 +16,7 @@
 #include "windows.h"
 #include "kernel32.h"
 #include "pe_image.h"
+#include "module.h"
 #include "handle32.h"
 #include "libres.h"
 #include "resource32.h"
@@ -92,7 +93,8 @@
 HANDLE32 FindResource32( HINSTANCE hModule, LPCWSTR name, LPCWSTR type )
 {
 #ifndef WINELIB
-    struct w_files *wptr = wine_files;
+    struct pe_data *pe;
+    NE_MODULE *pModule;
     PIMAGE_RESOURCE_DIRECTORY resdirptr;
     DWORD root;
 	HANDLE32 result;
@@ -103,11 +105,11 @@
     dprintf_resource( stddeb, " name=" );
     PrintId( name );
     dprintf_resource( stddeb, "\n" );
-    while (wptr != NULL && (wptr->hModule != hModule))
-	wptr = wptr->next;
-    if ((wptr == NULL) || (wptr->pe == NULL) || (wptr->pe->pe_resource == NULL))
-	return 0;
-    resdirptr = (PIMAGE_RESOURCE_DIRECTORY) wptr->pe->pe_resource;
+    if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return 0;
+    if (!(pModule->flags & NE_FFLAGS_WIN32)) return 0;  /* FIXME? */
+    if (!(pe = NE_WIN32_MODULE(pModule)) || !pe->pe_resource) return 0;
+
+    resdirptr = (PIMAGE_RESOURCE_DIRECTORY) pe->pe_resource;
     root = (DWORD) resdirptr;
     if ((resdirptr = GetResDirEntry(resdirptr, type, root)) == NULL)
 	return 0;
@@ -129,17 +131,18 @@
 HANDLE32 LoadResource32( HINSTANCE hModule, HANDLE32 hRsrc )
 {
 #ifndef WINELIB
-    struct w_files *wptr = wine_files;
+    struct pe_data *pe;
+    NE_MODULE *pModule;
 
     hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
     dprintf_resource(stddeb, "LoadResource: module=%04x res=%04x\n",
                      hModule, hRsrc );
     if (!hRsrc) return 0;
-    while (wptr != NULL && (wptr->hModule != hModule))
-	wptr = wptr->next;
-    if ((wptr == NULL) || (wptr->pe == NULL) || (wptr->pe->pe_resource == NULL))
-	return 0;
-    return (HANDLE32) (wptr->load_addr+((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
+
+    if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return 0;
+    if (!(pModule->flags & NE_FFLAGS_WIN32)) return 0;  /* FIXME? */
+    if (!(pe = NE_WIN32_MODULE(pModule)) || !pe->pe_resource) return 0;
+    return (HANDLE32) (pe->load_addr+((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
 #else
     return LIBRES_LoadResource( hModule, hRsrc );
 #endif
diff --git a/windows/defwnd.c b/windows/defwnd.c
index d081f22..5eccbf4 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -33,10 +33,9 @@
  *
  * Set the window text.
  */
-void DEFWND_SetText( HWND hwnd, LPSTR text )
+void DEFWND_SetText( WND *wndPtr, LPSTR text )
 {
     LPSTR textPtr;
-    WND *wndPtr = WIN_FindWndPtr( hwnd );
 
     if (!text) text = "";
     if (wndPtr->hText) USER_HEAP_FREE( wndPtr->hText );
@@ -66,7 +65,7 @@
 	{
 	    CREATESTRUCT *createStruct = (CREATESTRUCT*)PTR_SEG_TO_LIN(lParam);
 	    if (createStruct->lpszName)
-		DEFWND_SetText( hwnd,
+		DEFWND_SetText( wndPtr,
                                (LPSTR)PTR_SEG_TO_LIN(createStruct->lpszName) );
 	    return 1;
 	}
@@ -249,7 +248,7 @@
 	}
 
     case WM_SETTEXT:
-	DEFWND_SetText( hwnd, (LPSTR)PTR_SEG_TO_LIN(lParam) );
+	DEFWND_SetText( wndPtr, (LPSTR)PTR_SEG_TO_LIN(lParam) );
 	NC_HandleNCPaint( hwnd , (HRGN)1 );  /* Repaint caption */
 	return 0;
 
diff --git a/windows/msgbox.c b/windows/msgbox.c
index c8215fd..ebacf12 100644
--- a/windows/msgbox.c
+++ b/windows/msgbox.c
@@ -182,7 +182,6 @@
     HANDLE handle;
     MSGBOX mbox;
     int ret;
-    DWORD WineProc,Win16Proc,Win32Proc;
 
     mbox.title = title;
     mbox.text  = text;
diff --git a/windows/win.c b/windows/win.c
index 5c0b2ab..9a41b5d 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -272,7 +272,7 @@
     /* if lValue contains cursor coordinates they have to be
      * mapped to the client area of parent window */
 
-    if (bMouse) MapWindowPoints(0, hwnd, lppt, 2);
+    if (bMouse) MapWindowPoints(0, hwnd, lppt, 1);
 #ifndef WINELIB32
     else lValue = MAKELONG( LOWORD(lValue), idChild );
 #endif
diff --git a/wine.ini b/wine.ini
index 51a6745..f0690ec 100644
--- a/wine.ini
+++ b/wine.ini
@@ -40,6 +40,9 @@
 system=*-helvetica
 mssansserif=*-helvetica
 msserif=*-times
+courier new=adobe-courier
+times new roman=adobe-times
+symbol=adobe-symbol
 fixedsys=*-fixed
 arial=*-helvetica
 helv=*-helvetica