Created separate dlls for user,gdi,ttydrv,x11drv.
Fixed Winelib argc handling (thanks to Eric Pouech).

diff --git a/Make.rules.in b/Make.rules.in
index 0fdd734..48a5caf 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -89,6 +89,7 @@
 	dinput \
 	dplayx \
 	dsound \
+	gdi32 \
 	icmp \
 	imagehlp \
 	imm32 \
@@ -120,6 +121,8 @@
 	sound \
 	stress \
 	tapi32 \
+	ttydrv \
+	user32 \
 	version \
 	w32skrnl \
 	win87em \
@@ -129,7 +132,8 @@
 	winmm \
 	winspool \
 	wnaspi32 \
-	wsock32
+	wsock32 \
+	x11drv
 
 # Implicit rules
 
diff --git a/configure b/configure
index 06a8fdd..ae8d908 100755
--- a/configure
+++ b/configure
@@ -6190,6 +6190,7 @@
 dlls/display/Makefile
 dlls/dplayx/Makefile
 dlls/dsound/Makefile
+dlls/gdi/Makefile
 dlls/icmp/Makefile
 dlls/imagehlp/Makefile
 dlls/imm32/Makefile
@@ -6215,6 +6216,8 @@
 dlls/sound/Makefile
 dlls/stress/Makefile
 dlls/tapi32/Makefile
+dlls/ttydrv/Makefile
+dlls/user/Makefile
 dlls/version/Makefile
 dlls/win32s/Makefile
 dlls/win87em/Makefile
@@ -6233,6 +6236,8 @@
 dlls/winmm/wineoss/Makefile
 dlls/winsock/Makefile
 dlls/winspool/Makefile
+dlls/ttydrv/Makefile
+dlls/x11drv/Makefile
 documentation/Makefile
 documentation/wine.conf.man
 documentation/wine.man
@@ -6408,6 +6413,7 @@
 dlls/display/Makefile
 dlls/dplayx/Makefile
 dlls/dsound/Makefile
+dlls/gdi/Makefile
 dlls/icmp/Makefile
 dlls/imagehlp/Makefile
 dlls/imm32/Makefile
@@ -6433,6 +6439,8 @@
 dlls/sound/Makefile
 dlls/stress/Makefile
 dlls/tapi32/Makefile
+dlls/ttydrv/Makefile
+dlls/user/Makefile
 dlls/version/Makefile
 dlls/win32s/Makefile
 dlls/win87em/Makefile
@@ -6451,6 +6459,8 @@
 dlls/winmm/wineoss/Makefile
 dlls/winsock/Makefile
 dlls/winspool/Makefile
+dlls/ttydrv/Makefile
+dlls/x11drv/Makefile
 documentation/Makefile
 documentation/wine.conf.man
 documentation/wine.man
diff --git a/configure.in b/configure.in
index b7391c9..fcb43d2 100644
--- a/configure.in
+++ b/configure.in
@@ -952,6 +952,7 @@
 dlls/display/Makefile
 dlls/dplayx/Makefile
 dlls/dsound/Makefile
+dlls/gdi/Makefile
 dlls/icmp/Makefile
 dlls/imagehlp/Makefile
 dlls/imm32/Makefile
@@ -977,6 +978,8 @@
 dlls/sound/Makefile
 dlls/stress/Makefile
 dlls/tapi32/Makefile
+dlls/ttydrv/Makefile
+dlls/user/Makefile
 dlls/version/Makefile
 dlls/win32s/Makefile
 dlls/win87em/Makefile
@@ -995,6 +998,8 @@
 dlls/winmm/wineoss/Makefile
 dlls/winsock/Makefile
 dlls/winspool/Makefile
+dlls/ttydrv/Makefile
+dlls/x11drv/Makefile
 documentation/Makefile
 documentation/wine.conf.man
 documentation/wine.man
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index 82696c5..f78abdc 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -12,6 +12,7 @@
 	dinput/libdinput.@LIBEXT@ \
 	dplayx/libdplayx.@LIBEXT@ \
 	dsound/libdsound.@LIBEXT@ \
+	gdi/libgdi32.@LIBEXT@ \
 	icmp/libicmp.@LIBEXT@ \
 	imagehlp/libimagehlp.@LIBEXT@ \
 	imm32/libimm32.@LIBEXT@ \
@@ -35,6 +36,8 @@
 	sound/libsound.@LIBEXT@ \
 	stress/libstress.@LIBEXT@ \
 	tapi32/libtapi32.@LIBEXT@ \
+	ttydrv/libttydrv.@LIBEXT@ \
+	user/libuser32.@LIBEXT@ \
 	version/libversion.@LIBEXT@ \
 	win32s/libw32skrnl.@LIBEXT@ \
 	win87em/libwin87em.@LIBEXT@ \
@@ -52,7 +55,8 @@
 	winmm/wavemap/libmsacm.drv.@LIBEXT@ \
 	winmm/wineoss/libwineoss.drv.@LIBEXT@ \
 	winsock/libwsock32.@LIBEXT@ \
-	winspool/libwinspool.@LIBEXT@
+	winspool/libwinspool.@LIBEXT@ \
+	x11drv/libx11drv.@LIBEXT@
 
 # extra names for dlls containing multiple spec files
 EXTRADLLNAMES = \
@@ -60,6 +64,7 @@
 	commdlg \
 	compobj \
 	dplay \
+	gdi \
 	lzexpand \
 	mmsystem \
 	msvideo \
@@ -72,6 +77,7 @@
 	shlwapi \
 	storage \
 	typelib \
+	user \
 	ver \
 	w32sys \
 	win32s16 \
@@ -108,6 +114,9 @@
 libdsound.@LIBEXT@: dsound/libdsound.@LIBEXT@
 	$(RM) $@ && $(LN_S) dsound/libdsound.@LIBEXT@ $@
 
+libgdi32.@LIBEXT@ libgdi.@LIBEXT@: gdi/libgdi32.@LIBEXT@
+	$(RM) $@ && $(LN_S) gdi/libgdi32.@LIBEXT@ $@
+
 libicmp.@LIBEXT@: icmp/libicmp.@LIBEXT@
 	$(RM) $@ && $(LN_S) icmp/libicmp.@LIBEXT@ $@
 
@@ -201,6 +210,12 @@
 libtapi32.@LIBEXT@: tapi32/libtapi32.@LIBEXT@
 	$(RM) $@ && $(LN_S) tapi32/libtapi32.@LIBEXT@ $@
 
+libttydrv.@LIBEXT@: ttydrv/libttydrv.@LIBEXT@
+	$(RM) $@ && $(LN_S) ttydrv/libttydrv.@LIBEXT@ $@
+
+libuser32.@LIBEXT@ libuser.@LIBEXT@: user/libuser32.@LIBEXT@
+	$(RM) $@ && $(LN_S) user/libuser32.@LIBEXT@ $@
+
 libversion.@LIBEXT@ libver.@LIBEXT@: version/libversion.@LIBEXT@
 	$(RM) $@ && $(LN_S) version/libversion.@LIBEXT@ $@
 
@@ -231,6 +246,9 @@
 libwsock32.@LIBEXT@ libwinsock.@LIBEXT@: winsock/libwsock32.@LIBEXT@
 	$(RM) $@ && $(LN_S) winsock/libwsock32.@LIBEXT@ $@
 
+libx11drv.@LIBEXT@: x11drv/libx11drv.@LIBEXT@
+	$(RM) $@ && $(LN_S) x11drv/libx11drv.@LIBEXT@ $@
+
 $(DLLFILES): dummy
 	@cd `dirname $@` && $(MAKE)
 
diff --git a/dlls/gdi/.cvsignore b/dlls/gdi/.cvsignore
new file mode 100644
index 0000000..6c6f41e
--- /dev/null
+++ b/dlls/gdi/.cvsignore
@@ -0,0 +1,4 @@
+*.spec.c
+*.spec.glue.s
+Makefile
+libgdi32.so.1.0
diff --git a/dlls/gdi/Makefile.in b/dlls/gdi/Makefile.in
new file mode 100644
index 0000000..b6648db
--- /dev/null
+++ b/dlls/gdi/Makefile.in
@@ -0,0 +1,17 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = gdi32
+SOVERSION = 1.0
+ALTNAMES  = gdi
+
+SPEC_SRCS = gdi32.spec gdi.spec
+
+C_SRCS = \
+	gdi_main.c
+
+@MAKE_DLL_RULES@
+
+### Dependencies:
+
diff --git a/if1632/gdi.spec b/dlls/gdi/gdi.spec
similarity index 100%
rename from if1632/gdi.spec
rename to dlls/gdi/gdi.spec
diff --git a/relay32/gdi32.spec b/dlls/gdi/gdi32.spec
similarity index 100%
rename from relay32/gdi32.spec
rename to dlls/gdi/gdi32.spec
diff --git a/dlls/gdi/gdi_main.c b/dlls/gdi/gdi_main.c
new file mode 100644
index 0000000..e6d0132
--- /dev/null
+++ b/dlls/gdi/gdi_main.c
@@ -0,0 +1,51 @@
+/*
+ * GDI initialization code
+ */
+
+#include "windef.h"
+#include "wingdi.h"
+#include "wine/winbase16.h"
+
+#include "gdi.h"
+#include "global.h"
+#include "module.h"
+#include "psdrv.h"
+#include "tweak.h"
+#include "win16drv.h"
+
+
+/***********************************************************************
+ *           GDI initialisation routine
+ */
+BOOL WINAPI MAIN_GdiInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    NE_MODULE *pModule;
+
+    if ( GDI_HeapSel ) return TRUE;
+
+    /* Create GDI heap */
+    pModule = NE_GetPtr( GetModuleHandle16( "GDI" ) );
+    if ( pModule )
+    {
+        GDI_HeapSel = GlobalHandleToSel16( (NE_SEG_TABLE( pModule ) + 
+                                          pModule->dgroup - 1)->hSeg );
+    }
+    else
+    {
+        GDI_HeapSel = GlobalAlloc16( GMEM_FIXED, GDI_HEAP_SIZE );
+        LocalInit16( GDI_HeapSel, 0, GDI_HEAP_SIZE-1 );
+    }
+
+    if (!TWEAK_Init()) return FALSE;
+
+    /* GDI initialisation */
+    if(!GDI_Init()) return FALSE;
+
+    /* Create the Win16 printer driver */
+    if (!WIN16DRV_Init()) return FALSE;
+
+    /* PSDRV initialization */
+    if(!PSDRV_Init()) return FALSE;
+
+    return TRUE;
+}
diff --git a/dlls/ttydrv/.cvsignore b/dlls/ttydrv/.cvsignore
new file mode 100644
index 0000000..19812f5
--- /dev/null
+++ b/dlls/ttydrv/.cvsignore
@@ -0,0 +1,4 @@
+*.spec.c
+*.spec.glue.s
+Makefile
+libttydrv.so.1.0
diff --git a/dlls/ttydrv/Makefile.in b/dlls/ttydrv/Makefile.in
new file mode 100644
index 0000000..8cd7230
--- /dev/null
+++ b/dlls/ttydrv/Makefile.in
@@ -0,0 +1,16 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = ttydrv
+SOVERSION = 1.0
+
+SPEC_SRCS = ttydrv.spec
+
+C_SRCS = \
+	ttydrv_main.c
+
+@MAKE_DLL_RULES@
+
+### Dependencies:
+
diff --git a/dlls/ttydrv/ttydrv.spec b/dlls/ttydrv/ttydrv.spec
new file mode 100644
index 0000000..1236a69
--- /dev/null
+++ b/dlls/ttydrv/ttydrv.spec
@@ -0,0 +1,3 @@
+name	ttydrv
+type	win32
+init	TTYDRV_Init
diff --git a/dlls/ttydrv/ttydrv_main.c b/dlls/ttydrv/ttydrv_main.c
new file mode 100644
index 0000000..d2ab703
--- /dev/null
+++ b/dlls/ttydrv/ttydrv_main.c
@@ -0,0 +1,22 @@
+/*
+ * TTYDRV initialization code
+ */
+#include <stdio.h>
+
+#include "winbase.h"
+#include "gdi.h"
+#include "user.h"
+#include "ttydrv.h"
+
+/***********************************************************************
+ *           TTYDRV initialisation routine
+ */
+BOOL WINAPI TTYDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
+{
+    if (reason == DLL_PROCESS_ATTACH)
+    {
+        GDI_Driver = &TTYDRV_GDI_Driver;
+        USER_Driver = &TTYDRV_USER_Driver;
+    }
+    return TRUE;
+}
diff --git a/dlls/user/.cvsignore b/dlls/user/.cvsignore
new file mode 100644
index 0000000..b7feeb2
--- /dev/null
+++ b/dlls/user/.cvsignore
@@ -0,0 +1,4 @@
+*.spec.c
+*.spec.glue.s
+Makefile
+libuser32.so.1.0
diff --git a/dlls/user/Makefile.in b/dlls/user/Makefile.in
new file mode 100644
index 0000000..978bfc6
--- /dev/null
+++ b/dlls/user/Makefile.in
@@ -0,0 +1,17 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = user32
+SOVERSION = 1.0
+ALTNAMES  = user
+
+SPEC_SRCS = user32.spec user.spec
+
+C_SRCS = \
+	user_main.c
+
+@MAKE_DLL_RULES@
+
+### Dependencies:
+
diff --git a/if1632/user.spec b/dlls/user/user.spec
similarity index 100%
rename from if1632/user.spec
rename to dlls/user/user.spec
diff --git a/relay32/user32.spec b/dlls/user/user32.spec
similarity index 99%
rename from relay32/user32.spec
rename to dlls/user/user32.spec
index ffe001e..58a3332 100644
--- a/relay32/user32.spec
+++ b/dlls/user/user32.spec
@@ -1,6 +1,6 @@
 name	user32
 type	win32
-init	MAIN_UserInit
+init	USER_Init
 rsrc	user32
 
   1 stdcall ActivateKeyboardLayout(long long) ActivateKeyboardLayout
diff --git a/dlls/user/user_main.c b/dlls/user/user_main.c
new file mode 100644
index 0000000..83b154c
--- /dev/null
+++ b/dlls/user/user_main.c
@@ -0,0 +1,108 @@
+/*
+ * USER initialization code
+ */
+
+#include "windef.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "wine/winbase16.h"
+
+#include "cursoricon.h"
+#include "dce.h"
+#include "dialog.h"
+#include "display.h"
+#include "global.h"
+#include "input.h"
+#include "keyboard.h"
+#include "menu.h"
+#include "message.h"
+#include "module.h"
+#include "mouse.h"
+#include "queue.h"
+#include "spy.h"
+#include "sysmetrics.h"
+#include "user.h"
+#include "win.h"
+
+
+/***********************************************************************
+ *           USER initialisation routine
+ */
+BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    NE_MODULE *pModule;
+    int queueSize;
+
+    if ( USER_HeapSel ) return TRUE;
+
+    /* Create USER heap */
+    pModule = NE_GetPtr( GetModuleHandle16( "USER" ) );
+    if ( pModule )
+    {
+        USER_HeapSel = GlobalHandleToSel16( (NE_SEG_TABLE( pModule ) + 
+                                           pModule->dgroup - 1)->hSeg );
+    }
+    else
+    {
+        USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 0x10000 );
+        LocalInit16( USER_HeapSel, 0, 0xffff );
+    }
+
+     /* Global atom table initialisation */
+    if (!ATOM_Init( USER_HeapSel )) return FALSE;
+
+    /* Initialize window handling (critical section) */
+    WIN_Init();
+
+    /* Initialize system colors and metrics*/
+    SYSMETRICS_Init();
+    SYSCOLOR_Init();
+
+    /* Create the DCEs */
+    DCE_Init();
+
+    /* Initialize timers */
+    if (!TIMER_Init()) return FALSE;
+    
+    /* Initialize window procedures */
+    if (!WINPROC_Init()) return FALSE;
+
+    /* Initialize cursor/icons */
+    CURSORICON_Init();
+
+    /* Initialize built-in window classes */
+    if (!WIDGETS_Init()) return FALSE;
+
+    /* Initialize dialog manager */
+    if (!DIALOG_Init()) return FALSE;
+
+    /* Initialize menus */
+    if (!MENU_Init()) return FALSE;
+
+    /* Initialize message spying */
+    if (!SPY_Init()) return FALSE;
+
+    /* Create system message queue */
+    queueSize = GetProfileIntA( "windows", "TypeAhead", 120 );
+    if (!QUEUE_CreateSysMsgQueue( queueSize )) return FALSE;
+
+    /* Set double click time */
+    SetDoubleClickTime( GetProfileIntA("windows","DoubleClickSpeed",452) );
+
+    /* Create message queue of initial thread */
+    InitThreadInput16( 0, 0 );
+
+    /* Create desktop window */
+    if (!WIN_CreateDesktopWindow()) return FALSE;
+
+    /* Initialize keyboard driver */
+    KEYBOARD_Enable( keybd_event, InputKeyStateTable );
+
+    /* Initialize mouse driver */
+    MOUSE_Enable( mouse_event );
+
+    /* Start processing X events */
+    UserRepaintDisable16( FALSE );
+
+    return TRUE;
+}
diff --git a/dlls/x11drv/.cvsignore b/dlls/x11drv/.cvsignore
new file mode 100644
index 0000000..7fcc39a
--- /dev/null
+++ b/dlls/x11drv/.cvsignore
@@ -0,0 +1,4 @@
+*.spec.c
+*.spec.glue.s
+Makefile
+libx11drv.so.1.0
diff --git a/dlls/x11drv/Makefile.in b/dlls/x11drv/Makefile.in
new file mode 100644
index 0000000..4a75671
--- /dev/null
+++ b/dlls/x11drv/Makefile.in
@@ -0,0 +1,16 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = x11drv
+SOVERSION = 1.0
+
+SPEC_SRCS = x11drv.spec
+
+C_SRCS = \
+	x11drv_main.c
+
+@MAKE_DLL_RULES@
+
+### Dependencies:
+
diff --git a/dlls/x11drv/x11drv.spec b/dlls/x11drv/x11drv.spec
new file mode 100644
index 0000000..e0c00a4
--- /dev/null
+++ b/dlls/x11drv/x11drv.spec
@@ -0,0 +1,3 @@
+name	x11drv
+type	win32
+init	X11DRV_Init
diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c
new file mode 100644
index 0000000..d198614
--- /dev/null
+++ b/dlls/x11drv/x11drv_main.c
@@ -0,0 +1,22 @@
+/*
+ * X11DRV initialization code
+ */
+#include <stdio.h>
+
+#include "winbase.h"
+#include "gdi.h"
+#include "user.h"
+#include "x11drv.h"
+
+/***********************************************************************
+ *           X11DRV initialisation routine
+ */
+BOOL WINAPI X11DRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
+{
+    if (reason == DLL_PROCESS_ATTACH)
+    {
+        GDI_Driver = &X11DRV_GDI_Driver;
+        USER_Driver = &X11DRV_USER_Driver;
+    }
+    return TRUE;
+}
diff --git a/if1632/.cvsignore b/if1632/.cvsignore
index 0a9c7fb..0ab7d92 100644
--- a/if1632/.cvsignore
+++ b/if1632/.cvsignore
@@ -3,7 +3,6 @@
 comm.spec.c
 ddeml.spec.c
 dispdib.spec.c
-gdi.spec.c
 kernel.spec.c
 keyboard.spec.c
 ole2conv.spec.c
@@ -13,7 +12,5 @@
 system.spec.c
 thunk.glue.c
 toolhelp.spec.c
-user.spec.c
 wineps.spec.c
-winsock.spec.c
 wprocs.spec.c
diff --git a/if1632/Makefile.in b/if1632/Makefile.in
index 076a07a..f8ad3f4 100644
--- a/if1632/Makefile.in
+++ b/if1632/Makefile.in
@@ -9,7 +9,6 @@
 	comm.spec \
 	ddeml.spec \
 	dispdib.spec \
-	gdi.spec \
 	kernel.spec \
 	keyboard.spec \
 	ole2conv.spec \
@@ -18,7 +17,6 @@
 	ole2thk.spec \
 	system.spec \
 	toolhelp.spec \
-	user.spec \
 	wineps.spec \
 	wprocs.spec
 
diff --git a/include/main.h b/include/main.h
index 4bb9879..76b920b 100644
--- a/include/main.h
+++ b/include/main.h
@@ -7,8 +7,8 @@
 
 #include "windef.h"
 
-extern BOOL MAIN_MainInit( int *argc, char *argv[], BOOL win32 );
-extern BOOL MAIN_WineInit( int *argc, char *argv[] );
+extern BOOL MAIN_MainInit( int argc, char *argv[], BOOL win32 );
+extern BOOL MAIN_WineInit( int argc, char *argv[] );
 extern HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] );
 extern int MAIN_GetLanguageID(char*lang, char*country, char*charset, char*dialect);
 extern void MAIN_ParseDebugOptions(const char *options);
diff --git a/loader/main.c b/loader/main.c
index 3ee01d4..96c3913 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -60,7 +60,7 @@
 /***********************************************************************
  *           Main initialisation routine
  */
-BOOL MAIN_MainInit( int *argc, char *argv[], BOOL win32 )
+BOOL MAIN_MainInit( int argc, char *argv[], BOOL win32 )
 {
     /* store the program name */
     argv0 = argv[0];
@@ -108,6 +108,8 @@
     if (!LoadLibrary16( "KRNL386.EXE" )) return FALSE;
     if (!LoadLibraryA( "KERNEL32" )) return FALSE;
 
+    if (!LoadLibraryA( "x11drv" )) return FALSE;
+
     /* Initialize event handling */
     if (!EVENT_Init()) return FALSE;
 
@@ -168,124 +170,6 @@
     return TRUE;
 }
 
-/***********************************************************************
- *           GDI initialisation routine
- */
-BOOL WINAPI MAIN_GdiInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
-    NE_MODULE *pModule;
-
-    if ( GDI_HeapSel ) return TRUE;
-
-    /* Create GDI heap */
-    pModule = NE_GetPtr( GetModuleHandle16( "GDI" ) );
-    if ( pModule )
-    {
-        GDI_HeapSel = GlobalHandleToSel16( (NE_SEG_TABLE( pModule ) + 
-                                          pModule->dgroup - 1)->hSeg );
-    }
-    else
-    {
-        GDI_HeapSel = GlobalAlloc16( GMEM_FIXED, GDI_HEAP_SIZE );
-        LocalInit16( GDI_HeapSel, 0, GDI_HEAP_SIZE-1 );
-    }
-
-    if (!TWEAK_Init()) return FALSE;
-
-    /* GDI initialisation */
-    if(!GDI_Init()) return FALSE;
-
-    /* Create the Win16 printer driver */
-    if (!WIN16DRV_Init()) return FALSE;
-
-    /* PSDRV initialization */
-    if(!PSDRV_Init()) return FALSE;
-
-    return TRUE;
-}
-
-/***********************************************************************
- *           USER initialisation routine
- */
-BOOL WINAPI MAIN_UserInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
-    NE_MODULE *pModule;
-    int queueSize;
-
-    if ( USER_HeapSel ) return TRUE;
-
-    /* Create USER heap */
-    pModule = NE_GetPtr( GetModuleHandle16( "USER" ) );
-    if ( pModule )
-    {
-        USER_HeapSel = GlobalHandleToSel16( (NE_SEG_TABLE( pModule ) + 
-                                           pModule->dgroup - 1)->hSeg );
-    }
-    else
-    {
-        USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 0x10000 );
-        LocalInit16( USER_HeapSel, 0, 0xffff );
-    }
-
-     /* Global atom table initialisation */
-    if (!ATOM_Init( USER_HeapSel )) return FALSE;
-
-    /* Initialize window handling (critical section) */
-    WIN_Init();
-
-    /* Initialize system colors and metrics*/
-    SYSMETRICS_Init();
-    SYSCOLOR_Init();
-
-    /* Create the DCEs */
-    DCE_Init();
-
-    /* Initialize timers */
-    if (!TIMER_Init()) return FALSE;
-    
-    /* Initialize window procedures */
-    if (!WINPROC_Init()) return FALSE;
-
-    /* Initialize cursor/icons */
-    CURSORICON_Init();
-
-    /* Initialize built-in window classes */
-    if (!WIDGETS_Init()) return FALSE;
-
-    /* Initialize dialog manager */
-    if (!DIALOG_Init()) return FALSE;
-
-    /* Initialize menus */
-    if (!MENU_Init()) return FALSE;
-
-    /* Initialize message spying */
-    if (!SPY_Init()) return FALSE;
-
-    /* Create system message queue */
-    queueSize = GetProfileIntA( "windows", "TypeAhead", 120 );
-    if (!QUEUE_CreateSysMsgQueue( queueSize )) return FALSE;
-
-    /* Set double click time */
-    SetDoubleClickTime( GetProfileIntA("windows","DoubleClickSpeed",452) );
-
-    /* Create message queue of initial thread */
-    InitThreadInput16( 0, 0 );
-
-    /* Create desktop window */
-    if (!WIN_CreateDesktopWindow()) return FALSE;
-
-    /* Initialize keyboard driver */
-    KEYBOARD_Enable( keybd_event, InputKeyStateTable );
-
-    /* Initialize mouse driver */
-    MOUSE_Enable( mouse_event );
-
-    /* Start processing X events */
-    UserRepaintDisable16( FALSE );
-
-    return TRUE;
-}
-
 
 /***********************************************************************
  *           Winelib initialisation routine
@@ -296,7 +180,8 @@
     HMODULE16 hModule;
 
     /* Main initialization */
-    if (!MAIN_MainInit( argc, argv, TRUE )) return 0;
+    if (!MAIN_MainInit( *argc, argv, TRUE )) return 0;
+    *argc = Options.argc;
 
     /* Load WineLib EXE module */
     if ( (hModule = BUILTIN32_LoadExeModule()) < 32 ) return 0;
diff --git a/misc/main.c b/misc/main.c
index a8f4697..a23838b 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -654,8 +654,8 @@
  *
  * Wine initialisation and command-line parsing
  */
-BOOL MAIN_WineInit( int *argc, char *argv[] )
-{    
+BOOL MAIN_WineInit( int argc, char *argv[] )
+{
     struct timeval tv;
 
 #ifdef MALLOC_DEBUGGING
@@ -680,17 +680,7 @@
     gettimeofday( &tv, NULL);
     MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
     
-    OPTIONS_ParseOptions( *argc, argv );
-
-#ifndef X_DISPLAY_MISSING
-    USER_Driver = &X11DRV_USER_Driver;
-#else /* !defined(X_DISPLAY_MISSING) */
-    USER_Driver = &TTYDRV_USER_Driver;
-#endif /* !defined(X_DISPLAY_MISSING) */
-
-    USER_Driver->pInitialize();
-
-    MONITOR_Initialize(&MONITOR_PrimaryMonitor);
+    OPTIONS_ParseOptions( argc, argv );
 
     atexit(called_at_exit);
     return TRUE;
diff --git a/miscemu/main.c b/miscemu/main.c
index 8d413c8..f141ba4 100644
--- a/miscemu/main.c
+++ b/miscemu/main.c
@@ -109,7 +109,7 @@
     NE_MODULE *pModule;
 
     /* Initialize everything */
-    if (!MAIN_MainInit( &argc, argv, FALSE )) return 1;
+    if (!MAIN_MainInit( argc, argv, FALSE )) return 1;
 
     /* Create initial task */
     if ( !(pModule = NE_GetPtr( GetModuleHandle16( "KERNEL" ) )) ) return 1;
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 1eaff13..7295647 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -6,12 +6,6 @@
 
 #include "config.h"
 
-#ifndef X_DISPLAY_MISSING
-#include "x11drv.h"
-#else /* !defined(X_DISPLAY_MISSING) */
-#include "ttydrv.h"
-#endif /* !defined(X_DISPLAY_MISSING */
-
 #include <stdlib.h>
 #include <stdio.h>
 
@@ -346,12 +340,6 @@
 
     /* Initialize drivers */
 
-#ifndef X_DISPLAY_MISSING
-    GDI_Driver = &X11DRV_GDI_Driver;
-#else /* !defined(X_DISPLAY_MISSING) */
-    GDI_Driver = &TTYDRV_GDI_Driver;
-#endif /* !defined(X_DISPLAY_MISSING */
-
     GDI_Driver->pInitialize();
 
     /* Create default palette */
diff --git a/relay32/.cvsignore b/relay32/.cvsignore
index 201dd38..7d594e1 100644
--- a/relay32/.cvsignore
+++ b/relay32/.cvsignore
@@ -1,9 +1,4 @@
 Makefile
 call32.s
-ddraw.spec.c
-dinput.spec.c
-gdi32.spec.c
 kernel32.spec.c
-user32.spec.c
 wow32.spec.c
-wsock32.spec.c
diff --git a/relay32/Makefile.in b/relay32/Makefile.in
index abcf3a6..34ebc47 100644
--- a/relay32/Makefile.in
+++ b/relay32/Makefile.in
@@ -6,9 +6,7 @@
 MODULE    = relay32
 
 SPEC_SRCS = \
-	gdi32.spec \
 	kernel32.spec \
-	user32.spec \
 	wow32.spec
 
 C_SRCS = \
diff --git a/windows/event.c b/windows/event.c
index 52d6ab5..cfe650e 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -6,6 +6,10 @@
  */
 
 #include "message.h"
+#include "user.h"
+#include "x11drv.h"
+#include "ttydrv.h"
+#include "monitor.h"
 #include "debugtools.h"
 
 DECLARE_DEBUG_CHANNEL(event)
@@ -21,6 +25,10 @@
  */
 BOOL EVENT_Init(void)
 {
+    USER_Driver->pInitialize();
+
+    MONITOR_Initialize(&MONITOR_PrimaryMonitor);
+
     return EVENT_Driver->pInit();
 }