diff --git a/tools/winapi_check/modules.dat b/tools/winapi_check/modules.dat
index 06b6de0b497642442b44fa9417d19634075a8460..5114982bab505bee3c48c038702e4ba83ddb1774 100644
--- a/tools/winapi_check/modules.dat
+++ b/tools/winapi_check/modules.dat
@@ -1,6 +1,7 @@
 % dlls/advapi32/advapi32.spec
 
 dlls/advapi32
+misc
 
 % dlls/avifil32/avifil32.spec
 
@@ -25,6 +26,7 @@ dlls/commdlg
 % dlls/crtdll/crtdll.spec
 
 dlls/crtdll
+misc
 
 % dlls/dciman32/dciman32.spec
 
@@ -33,6 +35,7 @@ dlls/dciman32
 % dlls/ddraw/ddraw.spec
 
 dlls/ddraw
+dlls/ddraw/dclipper
 
 % dlls/dinput/dinput.spec
 
@@ -41,6 +44,7 @@ dlls/dinput
 % dlls/display/display.spec
 
 dlls/display
+objects
 
 % dlls/dplayx/dplay.spec
 
@@ -57,10 +61,21 @@ dlls/dsound
 % dlls/gdi/gdi.spec
 
 dlls/gdi
+graphics/metafiledrv
+graphics/win16drv
+graphics
+memory
+misc
+objects
 
 % dlls/gdi/gdi32.spec
 
 dlls/gdi
+graphics/enhmetafiledrv
+graphics/metafiledrv
+graphics
+misc
+objects
 
 % dlls/icmp/icmp.spec
 
@@ -113,6 +128,9 @@ dlls/msvideo
 % dlls/ntdll/ntdll.spec
 
 dlls/ntdll
+loader
+misc
+scheduler
 
 % dlls/odbc32/odbc32.spec
 
@@ -121,6 +139,7 @@ dlls/odbc32
 % dlls/ole32/compobj.spec
 
 dlls/ole32
+files
 
 % dlls/ole32/ole2.spec
 
@@ -189,14 +208,17 @@ dlls/setupx
 % dlls/shell32/shell.spec
 
 dlls/shell32
+misc
 
 % dlls/shell32/shell32.spec
 
 dlls/shell32
+memory
 
 % dlls/shell32/shlwapi.spec
 
 dlls/shell32
+memory
 
 % dlls/sound/sound.spec
 
@@ -214,17 +236,38 @@ dlls/tapi32
 
 dlls/ttydrv
 
+% dlls/urlmon/urlmon.spec
+
+dlls/urlmon
+
 % dlls/user/keyboard.spec
 
 dlls/user
+memory
+windows
 
 % dlls/user/user.spec
 
+controls
 dlls/user
+if1632
+loader
+objects
+memory
+misc
+windows
 
 % dlls/user/user32.spec
 
+controls
 dlls/user
+loader
+objects
+memory
+misc
+scheduler
+win32
+windows
 
 % dlls/version/ver.spec
 
@@ -237,6 +280,7 @@ dlls/version
 % dlls/win32s/w32skrnl.spec
 
 dlls/win32s
+loader
 
 % dlls/win32s/w32sys.spec
 
@@ -245,6 +289,8 @@ dlls/win32s
 % dlls/win32s/win32s16.spec
 
 dlls/win32s
+memory
+scheduler
 
 % dlls/win87em/win87em.spec
 
@@ -266,6 +312,10 @@ dlls/windebug
 
 dlls/wing
 
+% dlls/wininet/wininet.spec
+
+dlls/wininet
+
 % dlls/winmm/joystick/joystick.spec
 
 dlls/winmm/joystick
@@ -308,7 +358,8 @@ dlls/winmm
 
 % dlls/winmm/winmm.spec
 
-dlls/winmm/winmm
+dlls/winmm
+windows
 
 % dlls/winsock/winsock.spec
 
@@ -317,26 +368,87 @@ dlls/winsock
 % dlls/winsock/wsock32.spec
 
 dlls/winsock
+misc
 
 % dlls/winspool/winspool.spec
 
 dlls/winspool
+win32
 
 % dlls/x11drv/x11drv.spec
 
 dlls/x11drv
 
 % if1632/comm.spec
+
 % if1632/ddeml.spec
+
+misc
+
 % if1632/dispdib.spec
+
+graphics
+
 % if1632/kernel.spec
+
+files
+if1632
+loader/ne
+loader
+memory
+misc
+msdos
+relay32
+scheduler
+win32
+
 % if1632/ole2conv.spec
+
 % if1632/ole2nls.spec
+
+ole
+
 % if1632/ole2prox.spec
+
 % if1632/ole2thk.spec
+
 % if1632/system.spec
+
+misc
+
 % if1632/toolhelp.spec
+
+loader/ne
+loader
+memory
+misc
+windows
+
 % if1632/wineps.spec
+
+graphics/psdrv
+
 % if1632/wprocs.spec
+
+if1632
+loader/ne
+msdos
+relay32
+windows
+
 % relay32/kernel32.spec
+
+files
+loader/ne
+loader
+memory
+misc
+objects
+ole
+relay32
+scheduler
+win32
+
 % relay32/wow32.spec
+
+relay32
\ No newline at end of file
diff --git a/tools/winapi_check/modules.pm b/tools/winapi_check/modules.pm
index 0ac93bb3f635bda91b8e7ad5fd4c7b7e128d1310..f2a4f3305fca43a297825759e081abf208c63407 100644
--- a/tools/winapi_check/modules.pm
+++ b/tools/winapi_check/modules.pm
@@ -10,10 +10,13 @@ sub new {
 
     my $options = \${$self->{OPTIONS}};
     my $output = \${$self->{OUTPUT}};
+    my $spec_files = \%{$self->{SPEC_FILES}};
     my $modules = \%{$self->{MODULES}};
 
     $$options = shift;
     $$output = shift;
+    my $wine_dir = shift;
+    my $current_dir = shift;
     my $module_file = shift;
 
     $module_file =~ s/^\.\///;
@@ -38,12 +41,107 @@ sub new {
 	} else {
 	    $allowed_dir = $1;
 	}
+	$$spec_files{$allowed_dir}{$spec_file}++;
 
-	$$modules{$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");
+	} 
     }
     close(IN);
 
     return $self;
 }
 
+sub spec_file_module {
+    my $self = shift;
+
+    my $modules = \%{$self->{MODULES}};
+
+    my $spec_file = shift;
+    $spec_file =~ s/^\.\///;
+
+    my $module = shift;
+  
+    $$modules{$spec_file}{$module}++;
+}
+
+sub is_allowed_module_in_file {
+    my $self = shift;
+
+    my $spec_files = \%{$self->{SPEC_FILES}};
+    my $modules = \%{$self->{MODULES}};
+
+    my $module = shift;
+    my $file = shift;
+    $file =~ s/^\.\///;
+
+    my $dir = $file;
+    $dir =~ s/\/[^\/]*$//;
+
+    foreach my $spec_file (sort(keys(%{$$spec_files{$dir}}))) {
+	if($$modules{$spec_file}{$module}) {
+	    return 1;
+	}
+    }
+
+    return 0;
+}
+
+sub allowed_modules_in_file {
+    my $self = shift;
+
+    my $spec_files = \%{$self->{SPEC_FILES}};
+    my $modules = \%{$self->{MODULES}};
+
+    my $file = shift;
+    $file =~ s/^\.\///;
+
+    my $dir = $file;
+    $dir =~ s/\/[^\/]*$//;
+
+    my %allowed_modules = ();
+    foreach my $spec_file (sort(keys(%{$$spec_files{$dir}}))) {
+	foreach my $module (sort(keys(%{$$modules{$spec_file}}))) {
+	    $allowed_modules{$module}++;
+	}
+    }
+
+    return join(" & ", sort(keys(%allowed_modules)));
+}
+
+sub allowed_spec_files {
+    my $self = shift;
+
+    my $options = \${$self->{OPTIONS}};
+    my $output = \${$self->{OUTPUT}};
+    my $spec_files = \%{$self->{SPEC_FILES}};
+
+    my $wine_dir = shift;
+    my $current_dir = shift;
+
+    my @dirs = map {
+	s/^\.\/(.*)$/$1/;
+	if(/^\.$/) {
+	    $current_dir;
+	} else {
+	    if($current_dir ne ".") {
+		"$current_dir/$_";
+	    } else {
+		$_;
+	    }
+	}
+    } split(/\n/, `find . -type d ! -name CVS`);
+
+    my %allowed_spec_files = ();
+    foreach my $dir (sort(@dirs)) {
+	foreach my $spec_file (sort(keys(%{$$spec_files{$dir}}))) {
+	    $allowed_spec_files{$spec_file}++; 
+	}
+    }
+
+    return sort(keys(%allowed_spec_files));
+}
+
 1;
+
+
diff --git a/tools/winapi_check/win16/wprocs.api b/tools/winapi_check/win16/wprocs.api
index d195b22b08195dcaf8350ceb4212f8ba0778a208..0c694dc14a198d64e69d2925f8707bdf6a982c2e 100644
--- a/tools/winapi_check/win16/wprocs.api
+++ b/tools/winapi_check/win16/wprocs.api
@@ -5,9 +5,9 @@ DWORD
 %ptr
 
 CONTEXT86 *
-FARPROC
 LPVOID
 SEGPTR *
+UTGLUEPROC
 
 %segptr
 
diff --git a/tools/winapi_check/win32/dinput.api b/tools/winapi_check/win32/dinput.api
index 62996adcc3d703c75e02bc3caf053c4f928f39f9..f71e16507fd0170ee88e6926c9ddfca13d8e7bff 100644
--- a/tools/winapi_check/win32/dinput.api
+++ b/tools/winapi_check/win32/dinput.api
@@ -7,4 +7,7 @@ HRESULT
 %ptr
 
 LPDIRECTINPUTA *
+LPVOID *
 LPUNKNOWN
+REFCLSID
+REFIID
\ No newline at end of file
diff --git a/tools/winapi_check/win32/kernel32.api b/tools/winapi_check/win32/kernel32.api
index 8e90ed1f8b6f8a5b160b470e3d822020da2a9714..71d842c35a77ffc8c71aad8dfd48a00e76b7dd70 100644
--- a/tools/winapi_check/win32/kernel32.api
+++ b/tools/winapi_check/win32/kernel32.api
@@ -92,10 +92,10 @@ LPINPUT_RECORD
 LPLDT_ENTRY
 LPMEMORYSTATUS
 LPMEMORY_BASIC_INFORMATION
-LPMODULEENTRY
+LPMODULEENTRY32
 LPOVERLAPPED
 LPOVERLAPPED_COMPLETION_ROUTINE
-LPPROCESSENTRY
+LPPROCESSENTRY32
 LPPROCESS_HEAP_ENTRY
 LPPROCESS_INFORMATION
 LPPROGRESS_ROUTINE
@@ -108,7 +108,7 @@ LPSYSTEM_INFO
 LPSYSTEM_POWER_STATUS
 LPSYSTEMTIME
 LPTHREAD_START_ROUTINE
-LPTHREADENTRY
+LPTHREADENTRY32
 LPTIME_ZONE_INFORMATION
 LPTOP_LEVEL_EXCEPTION_FILTER
 LPVOID
diff --git a/tools/winapi_check/win32/urlmon.api b/tools/winapi_check/win32/urlmon.api
index fd5ef4bf9212924e2a9dd3706db0d7c83013e3a8..3bdae0185b7cd7d643dc5621b7d12c94e600e56e 100644
--- a/tools/winapi_check/win32/urlmon.api
+++ b/tools/winapi_check/win32/urlmon.api
@@ -1,12 +1,17 @@
 %long
 
+BOOL
 HRESULT
 
 %ptr
 
 IMoniker *
 IMoniker **
+LPVOID *
+REFCLSID
+REFIID
 
 %wstr
 
+LPCWSTR
 LPWSTR
diff --git a/tools/winapi_check/win32/wininet.api b/tools/winapi_check/win32/wininet.api
index 8665e4cce95fd6092811e5ac1aaa18941bb777de..73eb1c569af61c82c6486a2089c25498708343ae 100644
--- a/tools/winapi_check/win32/wininet.api
+++ b/tools/winapi_check/win32/wininet.api
@@ -3,6 +3,7 @@
 BOOL
 DWORD
 HINTERNET
+HRESULT
 INTERNET_PORT
 
 %ptr
@@ -18,3 +19,7 @@ INTERNET_STATUS_CALLBACK
 
 LPCSTR
 LPSTR
+
+%wstr
+
+LPCWSTR
diff --git a/tools/winapi_check/winapi.pm b/tools/winapi_check/winapi.pm
index 3a20328b429b0a2459578fd21b60a76653238b7e..18c468efe913e9e8758320e111f7bffd233e58b6 100644
--- a/tools/winapi_check/winapi.pm
+++ b/tools/winapi_check/winapi.pm
@@ -108,26 +108,55 @@ sub get_spec_file_type {
 
     my $file = shift;
 
+    my $module;
     my $type;
 
     open(IN, "< $file") || die "$file: $!\n";
-    $/ = "\n";
+    local $/ = "\n";
     while(<IN>) {
-	if(/^type\s*(\w+)/) {
-	    $type = $1;
-	    last;
-	}
+	s/^\s*(.*?)\s*$/$1/;
+	s/^(.*?)\s*#.*$/$1/;
+	/^$/ && next;
+
+	if(/^name\s*(\S*)/) { $module = $1; }
+	if(/^type\s*(\w+)/) { $type = $1; }
+
+	if(defined($module) && defined($type)) { last; }
     }
     close(IN);
 
-    return $type;
+    return ($type, $module);
 }
 
 sub read_spec_files {
     my $proto = shift;
     my $class = ref($proto) || $proto;
 
-    my $path = shift;
+    my $modules = shift;
+    my $wine_dir = shift;
+    my $current_dir = shift;
+    my $files = shift;
+    my $win16api = shift;
+    my $win32api = shift;
+
+    foreach my $file (@$files) {
+	(my $type, my $module) = 'winapi'->get_spec_file_type("$wine_dir/$file");
+	$modules->spec_file_module($file, $module);
+	if($type eq "win16") {
+	    $win16api->parse_spec_file("$wine_dir/$file");
+	} elsif($type eq "win32") {
+	    $win32api->parse_spec_file("$wine_dir/$file");
+	}
+    }
+}
+
+sub read_all_spec_files {
+    my $proto = shift;
+    my $class = ref($proto) || $proto;
+
+    my $modules = shift;    
+    my $wine_dir = shift;
+    my $current_dir = shift;
     my $file_type = shift;
     my $win16api = shift;
     my $win32api = shift;
@@ -139,16 +168,9 @@ sub read_spec_files {
 	} else {
 	    ();
 	}
-    } split(/\n/, `find $path -name \\*.spec`);
-
-    foreach my $file (@files) {
-	my $type = 'winapi'->get_spec_file_type($file);
-	if($type eq "win16") {
-	    $win16api->parse_spec_file($file);
-	} elsif($type eq "win32") {
-	    $win32api->parse_spec_file($file);
-	}
-    }
+    } split(/\n/, `find $wine_dir -name \\*.spec`);
+    
+    'winapi'->read_spec_files($modules, $wine_dir, $current_dir, \@files, $win16api, $win32api); 
 }
 
 sub parse_spec_file {
@@ -422,6 +444,15 @@ sub all_modules {
     return sort(keys(%$modules));
 }
 
+sub is_module {
+    my $self = shift;
+    my $modules = \%{$self->{MODULES}};
+
+    my $name = shift;
+
+    return $$modules{$name};
+}
+
 sub all_functions {
     my $self = shift;
     my $function_calling_convention = \%{$self->{FUNCTION_CALLING_CONVENTION}};
diff --git a/tools/winapi_check/winapi_check b/tools/winapi_check/winapi_check
index db3f276f244e13f8efe855f2d1e63ed2f304fe31..6fd4b3a400f8e633769538c3ce3e5494a6d74974 100755
--- a/tools/winapi_check/winapi_check
+++ b/tools/winapi_check/winapi_check
@@ -44,6 +44,16 @@ BEGIN {
     import winapi_parser;
 }
 
+my $current_dir = ".";
+if(length($wine_dir) != 1) {
+    my $pwd; chomp($pwd = `pwd`);
+    foreach my $n (1..((length($wine_dir) + 1) / 3)) {
+	$pwd =~ s/\/([^\/]*)$//;
+	$current_dir = "$1/$current_dir";
+    }
+    $current_dir =~ s/\/.$//;
+}
+
 my $options = winapi_options->new(\@ARGV, $wine_dir);
 if($options->help) {
     $options->show_help;
@@ -52,7 +62,7 @@ if($options->help) {
 
 my $output = 'output'->new;
 
-my $modules = 'modules'->new($options, $output, "$winapi_check_dir/modules.dat");
+my $modules = 'modules'->new($options, $output, $wine_dir, $current_dir, "$winapi_check_dir/modules.dat");
 
 my $win16api = 'winapi'->new($options, $output, "win16", "$winapi_check_dir/win16");
 my $win32api = 'winapi'->new($options, $output, "win32", "$winapi_check_dir/win32");
@@ -61,7 +71,7 @@ sub file_type {
     my $file = shift;
 
     my $file_dir = $file;
-    if(!($file_dir =~ s/(.*?)\/[^\/]*$/$1/)) {
+    if(!($file_dir =~ s/^(.*?)\/[^\/]*$/$1/)) {
 	$file_dir = ".";
     }
     
@@ -79,7 +89,12 @@ sub file_type {
     }
 }
 
-'winapi'->read_spec_files($wine_dir, \&file_type, $win16api, $win32api);
+if($options->global) {
+    'winapi'->read_all_spec_files($modules, $wine_dir, $current_dir, \&file_type, $win16api, $win32api);
+} else {
+    my @spec_files = $modules->allowed_spec_files($wine_dir, $current_dir);
+    'winapi'->read_spec_files($modules, $wine_dir, $current_dir, \@spec_files, $win16api, $win32api);
+}
 
 my $nativeapi = 'nativeapi'->new($options, $output, "$winapi_check_dir/nativeapi.dat", "$wine_dir/configure.in", "$wine_dir/include/config.h.in");
 
@@ -180,8 +195,9 @@ my %module_pseudo_stub_count32;
 
 foreach my $file ($options->c_files) {
     my %functions = ();
-    my $file_module16;
-    my $file_module32;
+
+    my $file_module16 = $modules->allowed_modules_in_file("$current_dir/$file");
+    my $file_module32 = $modules->allowed_modules_in_file("$current_dir/$file");
 
     $progress_current++;
     if($options->progress) {
@@ -200,7 +216,8 @@ foreach my $file ($options->c_files) {
 	my $linkage = shift;
 	my $return_type = shift;
 	my $calling_convention = shift;
-	my $name = shift;
+	my $internal_name = shift;
+	my $external_name = $internal_name;
 	my $refarguments = shift;
 	my @arguments = @$refarguments;
 	my $statements = shift;
@@ -213,23 +230,57 @@ foreach my $file ($options->c_files) {
 		$win32api->found_type($argument) if $options->win32;
 	    }
 	    
-	    $win16api->found_function($name) if $options->win16;
-	    $win32api->found_function($name) if $options->win32;
+	    $win16api->found_function($internal_name) if $options->win16;
+	    $win32api->found_function($internal_name) if $options->win32;
 	}
 	
 	if($file_type ne "application") {
-	    my $module16 = $win16api->function_module($name);
-	    my $module32 = $win32api->function_module($name);
+	    my $module16 = $win16api->function_module($internal_name);
+	    if(!defined($module16)) {
+		if($internal_name =~ /^(.*?)_(.*?)$/) {
+		    my $module2 = lc($1);
+		    my $name2 = $2;
+		    if($win16api->is_module($module2)) {
+			$module16 = $win16api->function_module($name2);
+			if(defined($module16)) {
+			    if(uc($module16) !~ /\U$module2\E/) {
+				$external_name = $name2;
+			    } else {
+				$module16 = undef;
+			    }
+			}
+		    }
+		}
+	    }
+
+	    my $module32 = $win32api->function_module($internal_name);
+	    if(!defined($module32)) {
+		if($internal_name =~ /^(.*?)_(.*?)$/) {
+		    my $module2 = lc($1);
+		    my $name2 = $2;
+		    if($win32api->is_module($module2)) {
+			$module32 = $win32api->function_module($name2);
+			if(defined($module32)) {
+			    if(uc($module32) =~ /\U$module2\E/) {
+				$external_name = $name2;
+			    } else {
+				$module32 = undef;
+			    }
+			}
+		    }
+		}
+	    }
 
 	    my $function = 'winapi_function'->new;
-	    $functions{$name} = $function;
+	    $functions{$internal_name} = $function;
 	   
  	    $function->documentation($documentation);
 	    $function->linkage($linkage);
 	    $function->file($file);
 	    $function->return_type($return_type); 
 	    $function->calling_convention($calling_convention);
-	    $function->name($name); 
+	    $function->external_name($external_name);
+	    $function->internal_name($internal_name);
 	    $function->arguments([@arguments]);
 	    $function->statements($statements);
 	    $function->module16($module16);
@@ -241,23 +292,15 @@ foreach my $file ($options->c_files) {
 		    my $msg = shift;
 		    $output->write("$file: $module: $return_type ");
 		    $output->write("$calling_convention ") if $calling_convention;
-		    $output->write("$name(" . join(",", @arguments) . "): $msg\n");
+		    $output->write("$internal_name(" . join(",", @arguments) . "): $msg\n");
 		}
 	    };
 	    my $output16 = &$output_module($module16);
 	    my $output32 = &$output_module($module32);
 
-	    # FIXME: Improve heuristics
-	    if(!defined($file_module16)) {
-		$file_module16 = $module16;
-	    }
-
-	    # FIXME: Improve heuristics
-	    if(!defined($file_module32)) {
-		$file_module32 = $module32;
-	    }
-
-	    if($options->local && $options->misplaced) {
+	    if($options->local && $options->misplaced &&
+	       $linkage ne "extern" && $statements) 
+	    {
 		if($options->win16 && $options->report_module($module16)) {
 		    my $match = 0;
 		    foreach my $module (split(/ & /, $module16)) {
@@ -268,7 +311,7 @@ foreach my $file ($options->c_files) {
 			}
 		    }
 		    if(!$match) {
-			&$output16("doesn't belong to file module ($file_module16)");
+			&$output16("is misplaced\n");
 		    }
 		}
 
@@ -282,13 +325,13 @@ foreach my $file ($options->c_files) {
 			}
 		    }
 		    if(!$match) {
-			&$output32("doesn't belong to file module ($file_module32)");
+			&$output32("is misplaced");
 		    }
 		}
 	    }
 
 	    if($options->local && $options->headers) {
-		if(!$declared_functions{$name}) {
+		if(!$declared_functions{$internal_name}) {
 		    if($options->win16 && $options->report_module($module16)) {
 			&$output16("no prototype");
 		    }
@@ -301,11 +344,11 @@ foreach my $file ($options->c_files) {
 	    if($options->local && $options->argument) {
 		if($options->win16 && $options->report_module($module16)) {
 		  winapi_local::check_function $options, $output16,
-		    $return_type, $calling_convention, $name, [@arguments], $win16api;
+		    $return_type, $calling_convention, $external_name, $internal_name, [@arguments], $win16api;
 		}	
 		if($options->win32 && $options->report_module($module32)) {
 		  winapi_local::check_function $options, $output32,
-		    $return_type, $calling_convention, $name, [@arguments], $win32api;
+		    $return_type, $calling_convention, $external_name, $internal_name, [@arguments], $win32api;
 		}
 	    }
 
@@ -317,11 +360,11 @@ foreach my $file ($options->c_files) {
 			$_ = $';
 			my $called_name = $1;
 			if($called_name !~ /^if|for|while|switch|sizeof$/) {
-			    $functions{$name}->function_called($called_name);
+			    $functions{$internal_name}->function_called($called_name);
 			    if(!defined($functions{$called_name})) {
 				$functions{$called_name} = 'winapi_function'->new;
 			    }
-			    $functions{$called_name}->function_called_by($name);
+			    $functions{$called_name}->function_called_by($internal_name);
 			}
 		    } else {
 		       undef $_
@@ -346,7 +389,7 @@ foreach my $file ($options->c_files) {
 	    
 	    if($options->local && $options->documentation &&
 	       (defined($module16) || defined($module32)) &&
-	       $linkage ne "extern" && $statements ne "")
+	       $linkage ne "extern" && $statements)
 	    {
 		my $name1;
 		my $name2;
@@ -355,7 +398,7 @@ foreach my $file ($options->c_files) {
 		    my @uc_modules16 = split(/\s*\&\s*/, uc($module16));
 		    push @uc_modules16, "WIN16";
 
-		    $name1 = $name;
+		    $name1 = $internal_name;
 		    foreach my $uc_module16 (@uc_modules16) {
 			if($name1 =~ s/^$uc_module16\_//) { last; }
 		    }
@@ -366,7 +409,7 @@ foreach my $file ($options->c_files) {
 		} elsif(!defined($module16) && defined($module32)) {
 		    my @uc_modules32 = split(/\s*\&\s*/, uc($module32));
 
-		    $name1 = $name;
+		    $name1 = $internal_name;
 		    foreach my $uc_module32 (@uc_modules32) {
 			if($name1 =~ s/^$uc_module32\_//) { last; }
 		    }
@@ -377,7 +420,7 @@ foreach my $file ($options->c_files) {
 		    my @uc_modules = split(/\s*\&\s*/, uc($module16));
 		    push @uc_modules, split(/\s*\&\s*/, uc($module32));
 
-		    $name1 = $name;
+		    $name1 = $internal_name;
 		    foreach my $uc_module (@uc_modules) {
 			if($name1 =~ s/^$uc_module\_//) { last; }
 		    }
@@ -385,8 +428,8 @@ foreach my $file ($options->c_files) {
 		    $name2 = $name1;
 		}
 
-		if($documentation !~ /\b($name|$name1|$name2)\b/) {
-		    $output->write("$file: $name: \\\n");
+		if($documentation !~ /\b($internal_name|$name1|$name2)\b/) {
+		    $output->write("$file: $internal_name: \\\n");
 		    $output->write("$documentation\n");
 		}
 
@@ -396,7 +439,7 @@ foreach my $file ($options->c_files) {
 			
 			$comment_width{$width}++;
 			if($width <= 65 || $width >= 81) {
-			    $output->write("$file: $name: comment is $width columns wide\n");
+			    $output->write("$file: $internal_name: comment is $width columns wide\n");
 			}
 		    }
 		}
diff --git a/tools/winapi_check/winapi_function.pm b/tools/winapi_check/winapi_function.pm
index ceb1b598c029d3781f9223b1dff3e16cb06b4a05..d70cf9c1829b11a771b8e48a50246d7bb55bc7c1 100644
--- a/tools/winapi_check/winapi_function.pm
+++ b/tools/winapi_check/winapi_function.pm
@@ -66,15 +66,26 @@ sub calling_convention {
     return $$calling_convention;
 }
 
-sub name {
+sub external_name {
     my $self = shift;
-    my $name = \${$self->{NAME}};
+    my $external_name = \${$self->{EXTERNAL_NAME}};
 
     local $_ = shift;
 
-    if(defined($_)) { $$name = $_; }
+    if(defined($_)) { $$external_name = $_; }
     
-    return $$name;
+    return $$external_name;
+}
+
+sub internal_name {
+    my $self = shift;
+    my $internal_name = \${$self->{INTERNAL_NAME}};
+
+    local $_ = shift;
+
+    if(defined($_)) { $$internal_name = $_; }
+    
+    return $$internal_name;
 }
 
 sub arguments {
diff --git a/tools/winapi_check/winapi_local.pm b/tools/winapi_check/winapi_local.pm
index df5ecfb5c9c775273614b9f6351c7c598eb4bcc1..1c7bf6cea8ae018a9547b0df43b6837820197b20 100644
--- a/tools/winapi_check/winapi_local.pm
+++ b/tools/winapi_check/winapi_local.pm
@@ -7,28 +7,29 @@ sub check_function {
     my $output = shift;
     my $return_type = shift;
     my $calling_convention = shift;
-    my $name = shift;
+    my $external_name = shift;
+    my $internal_name = shift;
     my $refargument_types = shift;
     my @argument_types = @$refargument_types;
     my $winapi = shift;
 
-    my $module = $winapi->function_module($name);
+    my $module = $winapi->function_module($external_name);
        
     if($winapi->name eq "win16") {
-	my $name16 = $name;
+	my $name16 = $external_name;
 	$name16 =~ s/16$//;
-	if($name16 ne $name && $winapi->function_stub($name16)) {
+	if($name16 ne $external_name && $winapi->function_stub($name16)) {
 	    if($options->implemented) {
 		&$output("function implemented but declared as stub in .spec file");
 	    }
 	    return;
-	} elsif($winapi->function_stub($name)) {
+	} elsif($winapi->function_stub($external_name)) {
 	    if($options->implemented_win32) {
 		&$output("32-bit variant of function implemented but declared as stub in .spec file");
 	    }
 	    return;
 	}
-    } elsif($winapi->function_stub($name)) {
+    } elsif($winapi->function_stub($external_name)) {
 	if($options->implemented) {
 	    &$output("function implemented but declared as stub in .spec file");
 	}
@@ -79,8 +80,8 @@ sub check_function {
 	}
     }
 
-    my $declared_calling_convention = $winapi->function_calling_convention($name);
-    my @declared_argument_kinds = split(/\s+/, $winapi->function_arguments($name));
+    my $declared_calling_convention = $winapi->function_calling_convention($external_name);
+    my @declared_argument_kinds = split(/\s+/, $winapi->function_arguments($external_name));
 
     if($declared_calling_convention =~ /^register|interrupt$/) {
 	push @declared_argument_kinds, "ptr";
@@ -111,12 +112,12 @@ sub check_function {
     }
 
     if($#argument_types != -1 && $argument_types[$#argument_types] eq "CONTEXT *" &&
-       $name !~ /^(Get|Set)ThreadContext$/)
+       $external_name !~ /^(Get|Set)ThreadContext$/) # FIXME: Kludge
     {
 	$#argument_types--;
     }
     
-    if($name =~ /^CRTDLL__ftol|CRTDLL__CIpow$/) {
+    if($internal_name =~ /^CRTDLL__ftol|CRTDLL__CIpow$/) { # FIXME: Kludge
 	# ignore
     } else {
 	my $n = 0;
@@ -167,7 +168,7 @@ sub check_function {
 
     }
 
-    if($segmented && $options->shared_segmented && $winapi->is_shared_function($name)) {
+    if($segmented && $options->shared_segmented && $winapi->is_shared_function($internal_name)) {
 	&$output("function using segmented pointers shared between Win16 och Win32");
     }
 }
diff --git a/tools/winapi_check/winapi_options.pm b/tools/winapi_check/winapi_options.pm
index ffbf6208fa9a103337cb47085c922a23cf0672a6..abdac383835595f07e0f9af918631b0bfda16537 100644
--- a/tools/winapi_check/winapi_options.pm
+++ b/tools/winapi_check/winapi_options.pm
@@ -59,7 +59,7 @@ my %options = (
 	description => "argument kind checking"
     },
     "calling-convention" => { default => 0, parent => "local", description => "calling convention checking" },
-    "misplaced" => { default => 0, parent => "local", description => "check for misplaced functions" },
+    "misplaced" => { default => 1, parent => "local", description => "check for misplaced functions" },
     "cross-call" => { default => 0, parent => "local", description => "check for cross calling functions" },
     "documentation" => { default => 1, parent => "local", description => "check for documentation inconsistances\n" },
     "documentation-width" => { default => 0, parent => "documentation", description => "check for documentation width inconsistances\n" },