diff --git a/tools/winapi_check/modules.dat b/tools/winapi_check/modules.dat
index b8795e01e06de0e01fc2c8ab946fc1492a494e04..41f2d89e78dca10fb275dabcc1e0ee48daea2dbb 100644
--- a/tools/winapi_check/modules.dat
+++ b/tools/winapi_check/modules.dat
@@ -10,8 +10,6 @@ dlls/avifil32
 
 % dlls/avifil32/avifile.spec
 
-dlls/avifil32
-
 % dlls/comctl32/comctl32.spec
 
 dlls/comctl32
@@ -31,8 +29,6 @@ misc
 
 % dlls/dciman32/dciman32.spec
 
-dlls/dciman32
-
 % dlls/ddraw/ddraw.spec
 
 dlls/ddraw
@@ -44,8 +40,6 @@ dlls/dinput
 
 % dlls/dplay/dplay.spec
 
-dlls/dplay
-
 % dlls/dplayx/dplayx.spec
 
 dlls/dplayx
@@ -65,7 +59,6 @@ graphics/metafiledrv
 graphics/win16drv
 graphics
 memory
-misc
 objects
 
 % dlls/gdi/gdi32.spec
@@ -74,7 +67,6 @@ dlls/gdi
 graphics/enhmetafiledrv
 graphics/metafiledrv
 graphics
-misc
 objects
 
 % dlls/gdi/wing.spec
@@ -105,7 +97,6 @@ loader
 memory
 misc
 msdos
-relay32
 scheduler
 win32
 
@@ -117,9 +108,7 @@ loader/ne
 loader
 memory
 misc
-objects
 ole
-relay32
 scheduler
 win32
 
@@ -133,20 +122,17 @@ misc
 
 % dlls/kernel/toolhelp.spec
 
+dlls/kernel
 loader/ne
 loader
 memory
-misc
 windows
 
 % dlls/kernel/wprocs.spec
 
 dlls/kernel
-if1632
 loader/ne
 msdos
-relay32
-windows
 
 % dlls/kernel/win87em.spec
 
@@ -178,8 +164,6 @@ dlls/msacm
 
 % dlls/msnet32/msnet32.spec
 
-dlls/msnet32
-
 % dlls/msvideo/msvfw32.spec
 
 dlls/msvideo
@@ -191,8 +175,6 @@ dlls/msvideo
 % dlls/ntdll/ntdll.spec
 
 dlls/ntdll
-loader
-misc
 scheduler
 
 % dlls/odbc32/odbc32.spec
@@ -273,8 +255,6 @@ dlls/psapi
 
 % dlls/rasapi32/rasapi16.spec
 
-dlls/rasapi32
-
 % dlls/rasapi32/rasapi32.spec
 
 dlls/rasapi32
@@ -302,20 +282,15 @@ dlls/setupapi
 % dlls/shell32/shell.spec
 
 dlls/shell32
-misc
 
 % dlls/shell32/shell32.spec
 
 dlls/shell32
-memory
 
 % dlls/shfolder/shfolder.spec
 
-dlls/shfolder
-
 % dlls/shlwapi/shlwapi.spec
 
-dlls/shell32
 dlls/shlwapi
 
 % dlls/tapi32/tapi32.spec
@@ -324,8 +299,6 @@ dlls/tapi32
 
 % dlls/ttydrv/ttydrv.spec
 
-dlls/ttydrv
-
 % dlls/urlmon/urlmon.spec
 
 dlls/urlmon
@@ -333,7 +306,6 @@ dlls/urlmon
 % dlls/user/ddeml.spec
 
 dlls/user
-misc
 
 % dlls/user/display.spec
 
@@ -342,7 +314,6 @@ objects
 
 % dlls/user/keyboard.spec
 
-dlls/user
 memory
 windows
 
@@ -355,8 +326,6 @@ dlls/user
 controls
 dlls/user
 if1632
-loader
-objects
 memory
 misc
 windows
@@ -366,11 +335,8 @@ windows
 controls
 dlls/user
 loader
-objects
 memory
 misc
-scheduler
-win32
 windows
 
 % dlls/version/ver.spec
@@ -406,8 +372,6 @@ dlls/winaspi
 
 % dlls/wineps/wineps.spec
 
-dlls/wineps
-
 % dlls/wineps/wineps16.spec
 
 dlls/wineps
@@ -486,9 +450,5 @@ win32
 
 % dlls/wow32/wow32.spec
 
-dlls/kernel
-relay32
-
 % dlls/x11drv/x11drv.spec
 
-dlls/x11drv
diff --git a/tools/winapi_check/modules.pm b/tools/winapi_check/modules.pm
index e1d2cb4ad10fc76516bb428de8a3eb8833dcb2c2..b2130e440af75f3bb6626612f55024ca1e0d4d1f 100644
--- a/tools/winapi_check/modules.pm
+++ b/tools/winapi_check/modules.pm
@@ -11,13 +11,13 @@ sub new {
     my $options = \${$self->{OPTIONS}};
     my $output = \${$self->{OUTPUT}};
     my $spec_files = \%{$self->{SPEC_FILES}};
-    my $modules = \%{$self->{MODULES}};
+    my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}};
 
     $$options = shift;
     $$output = shift;
     my $wine_dir = shift;
     my $current_dir = shift;
-    my $file_type = shift;
+    my $file_type = shift;    
     my $module_file = shift;
 
     $module_file =~ s/^\.\///;
@@ -37,7 +37,7 @@ sub new {
     }
 
     if($$options->progress) {
-	$$output->progress("$module_file");
+	$$output->progress("modules.dat");
     }
 
     my $allowed_dir;
@@ -54,7 +54,7 @@ sub new {
 	    $spec_file = $1;
 	   
 	    if(!-f "$wine_dir/$spec_file") {
-		$$output->write("$module_file: $spec_file: file ($spec_file) doesn't exist or is no file\n");
+		$$output->write("modules.dat: $spec_file: file ($spec_file) doesn't exist or is no file\n");
 	    } 
 
 	    if($wine_dir eq ".") {
@@ -70,14 +70,14 @@ sub new {
 	$$spec_files{$allowed_dir}{$spec_file}++;
 
 	if(!-d "$wine_dir/$allowed_dir") {
-	    $$output->write("$module_file: $spec_file: directory ($allowed_dir) doesn't exist or is no directory\n");
+	    $$output->write("modules.dat: $spec_file: directory ($allowed_dir) doesn't exist or is no directory\n");
 	} 
     }
     close(IN);
 
     foreach my $spec_file (sort(keys(%all_spec_files))) {
 	if($all_spec_files{$spec_file} > 0) {
-	    $$output->write("$module_file: $spec_file: exists but is not specified\n");
+	    $$output->write("modules.dat: $spec_file: exists but is not specified\n");
 	}
     }
 
@@ -87,21 +87,23 @@ sub new {
 sub spec_file_module {
     my $self = shift;
 
-    my $modules = \%{$self->{MODULES}};
+    my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}};
+    my $module2spec_file = \%{$self->{MODULE2SPEC_FILE}};
 
     my $spec_file = shift;
     $spec_file =~ s/^\.\///;
 
     my $module = shift;
   
-    $$modules{$spec_file}{$module}++;
+    $$spec_file2module{$spec_file}{$module}++;
+    $$module2spec_file{$module}{$spec_file}++;
 }
 
 sub is_allowed_module_in_file {
     my $self = shift;
 
     my $spec_files = \%{$self->{SPEC_FILES}};
-    my $modules = \%{$self->{MODULES}};
+    my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}};
 
     my $module = shift;
     my $file = shift;
@@ -111,7 +113,7 @@ sub is_allowed_module_in_file {
     $dir =~ s/\/[^\/]*$//;
 
     foreach my $spec_file (sort(keys(%{$$spec_files{$dir}}))) {
-	if($$modules{$spec_file}{$module}) {
+	if($$spec_file2module{$spec_file}{$module}) {
 	    return 1;
 	}
     }
@@ -123,7 +125,7 @@ sub allowed_modules_in_file {
     my $self = shift;
 
     my $spec_files = \%{$self->{SPEC_FILES}};
-    my $modules = \%{$self->{MODULES}};
+    my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}};
 
     my $file = shift;
     $file =~ s/^\.\///;
@@ -133,7 +135,7 @@ sub allowed_modules_in_file {
 
     my %allowed_modules = ();
     foreach my $spec_file (sort(keys(%{$$spec_files{$dir}}))) {
-	foreach my $module (sort(keys(%{$$modules{$spec_file}}))) {
+	foreach my $module (sort(keys(%{$$spec_file2module{$spec_file}}))) {
 	    $allowed_modules{$module}++;
 	}
     }
@@ -174,6 +176,40 @@ sub allowed_spec_files {
     return sort(keys(%allowed_spec_files));
 }
 
-1;
+sub found_module_in_dir {
+    my $self = shift;
+
+    my $module = shift;
+    my $dir = shift;
+
+    my $used_module_dirs = \%{$self->{USED_MODULE_DIRS}};
+
+    $$used_module_dirs{$module}{$dir}++;
+}
+
+sub global_report {
+    my $self = shift;
+
+    my $output = \${$self->{OUTPUT}};
+    my $spec_files = \%{$self->{SPEC_FILES}};
+    my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}};
+    my $used_module_dirs = \%{$self->{USED_MODULE_DIRS}};
+
+    my @messages;
+    foreach my $dir (sort(keys(%$spec_files))) {
+	if($dir eq "") { next; }
+	foreach my $spec_file (sort(keys(%{$$spec_files{$dir}}))) {
+	    foreach my $module (sort(keys(%{$$spec_file2module{$spec_file}}))) {
+		if(!$$used_module_dirs{$module}{$dir}) {
+		    push @messages, "modules.dat: $spec_file: directory ($dir) is not used\n";
+		}
+	    }
+	}
+    }
 
+    foreach my $message (sort(@messages)) {
+	$$output->write($message);
+    }
+}
 
+1;
diff --git a/tools/winapi_check/nativeapi.dat b/tools/winapi_check/nativeapi.dat
index 6e0c0af5c2f19fd1b681e43952154fb5309dd31c..512ed1ab9d28a623f8833b8ca1805375f8a053d7 100644
--- a/tools/winapi_check/nativeapi.dat
+++ b/tools/winapi_check/nativeapi.dat
@@ -241,6 +241,7 @@ unlink
 usleep
 utime
 vfprintf
+vsnprintf
 vsprintf
 wait4
 write
diff --git a/tools/winapi_check/nativeapi.pm b/tools/winapi_check/nativeapi.pm
index fae13919679db659592e2d9f92ff6f5e5d95f49f..1c6e23a0133ffa8fcaeef81573f9a2494df01d95 100644
--- a/tools/winapi_check/nativeapi.pm
+++ b/tools/winapi_check/nativeapi.pm
@@ -85,7 +85,7 @@ sub new {
     open(IN, "< $config_h_in_file");
     local $/ = "\n";
     while(<IN>) {
-	if(/^\#undef\s+(\S+)$/) {
+	if(/^\#undef\s+(\S+)\s*$/) {
 	    $$conditionals{$1}++;
 	}
     }
diff --git a/tools/winapi_check/win32/comctl32.api b/tools/winapi_check/win32/comctl32.api
index 16f38886f9eb1276f50eaff715311ab637349ca9..7b2c5b61e363ec32c32e7d0264867893142dd46e 100644
--- a/tools/winapi_check/win32/comctl32.api
+++ b/tools/winapi_check/win32/comctl32.api
@@ -45,6 +45,7 @@ LPUINT
 LPVOID
 LPWSTR *
 POINT *
+SMOOTHSCROLLSTRUCT *
 
 %ptr
 
diff --git a/tools/winapi_check/win32/oleaut32.api b/tools/winapi_check/win32/oleaut32.api
index b2bad2f04599e0595c4670337f8532da6ed91f02..6a2ca65bef617539a1913778e19fed8ae742078d 100644
--- a/tools/winapi_check/win32/oleaut32.api
+++ b/tools/winapi_check/win32/oleaut32.api
@@ -47,6 +47,7 @@ DATE *
 FLOAT *
 ITypeLib *
 ITypeLib **
+IUnknown **
 LONG *
 LPBSTR
 LPCLSID
@@ -81,8 +82,8 @@ void **
 %str # ???
 
 LPCOLESTR
+LPCSTR
 LPOLESTR
-LPSTR
 
 %void
 
diff --git a/tools/winapi_check/win32/ws2_32.api b/tools/winapi_check/win32/ws2_32.api
index 24c28ea1e3d7bd20d2a1c5447e8f9ff571e6e1dc..9a20ad9941fd6f2953a175883a00ee74f002e06e 100644
--- a/tools/winapi_check/win32/ws2_32.api
+++ b/tools/winapi_check/win32/ws2_32.api
@@ -30,10 +30,10 @@ LPWSAOVERLAPPED_COMPLETION_ROUTINE
 LPWSANETWORKEVENTS
 LPWSAPROTOCOL_INFOA
 ULONG *
+WIN_hostent *
+WIN_protoent *
+WIN_servent *
 char *
-struct WIN_hostent *
-struct WIN_protoent *
-struct WIN_servent *
 struct sockaddr *
 struct timeval *
 ws_fd_set32 *
diff --git a/tools/winapi_check/win32/wsock32.api b/tools/winapi_check/win32/wsock32.api
index 25c93386aa44e2140289391a3460271d6ddbee1f..3e64a66db29faaf6a7434f5c99374ff30be05d4d 100644
--- a/tools/winapi_check/win32/wsock32.api
+++ b/tools/winapi_check/win32/wsock32.api
@@ -24,10 +24,10 @@ LPDWORD
 LPVOID
 LPWSADATA
 ULONG *
+WIN_hostent *
+WIN_protoent *
+WIN_servent *
 char *
-struct WIN_hostent *
-struct WIN_protoent *
-struct WIN_servent *
 struct netent *
 struct sockaddr *
 struct timeval *
diff --git a/tools/winapi_check/winapi_check b/tools/winapi_check/winapi_check
index 407400f607d934a90e62bbb8918450877a8abca5..27f3d0a75125725fb2b85d88b62579407667f938 100755
--- a/tools/winapi_check/winapi_check
+++ b/tools/winapi_check/winapi_check
@@ -294,6 +294,13 @@ foreach my $file ($options->c_files) {
 	    my $module16 = $win16api->function_module($internal_name);
 	    my $module32 = $win32api->function_module($internal_name);
 
+	    if(defined($module16)) {
+		$modules->found_module_in_dir($module16, $file_dir);
+	    }
+	    if(defined($module32)) {
+		$modules->found_module_in_dir($module32, $file_dir);
+	    }
+
 	    my $function = 'winapi_function'->new;
 	    $functions{$internal_name} = $function;
 	   
@@ -693,4 +700,6 @@ if($options->global) {
 
     winapi_global::check $options, $output, $win16api, $nativeapi if $options->win16;
     winapi_global::check $options, $output, $win32api, $nativeapi if $options->win32;
+
+    $modules->global_report;
 }