Minor reorganisation and a few bug fixes.

diff --git a/tools/winapi/winapi_extract b/tools/winapi/winapi_extract
index 3680bdb..de72ae0 100755
--- a/tools/winapi/winapi_extract
+++ b/tools/winapi/winapi_extract
@@ -10,7 +10,7 @@
 }
 
 use config qw(
-    &file_type &file_skip &files_skip &get_spec_files
+    &file_type &files_skip &files_filter &get_spec_files
     $current_dir $wine_dir $winapi_dir $winapi_check_dir
 );
 use modules;
diff --git a/tools/winapi_check/win32/shell32.api b/tools/winapi_check/win32/shell32.api
index 6f23aca..d4afdf2 100644
--- a/tools/winapi_check/win32/shell32.api
+++ b/tools/winapi_check/win32/shell32.api
@@ -38,7 +38,6 @@
 IShellFolder **
 IStream *
 ITEMIDLIST *
-IUnknown *
 LPBROWSEINFOA
 LPBYTE
 LPCITEMIDLIST
@@ -79,7 +78,6 @@
 LPWORD
 LPWSTR *
 PAPPBARDATA
-PLONG
 PNOTIFYICONDATAA
 PNOTIFYICONDATAW
 POINT *
diff --git a/tools/winapi_check/win32/user32.api b/tools/winapi_check/win32/user32.api
index 56fe178..54d57b9 100644
--- a/tools/winapi_check/win32/user32.api
+++ b/tools/winapi_check/win32/user32.api
@@ -38,6 +38,7 @@
 LRESULT
 SHORT
 UINT
+ULONG_PTR
 WCHAR
 WORD
 WPARAM
@@ -70,7 +71,6 @@
 DWORD *
 DLGPROC
 DRAWSTATEPROC
-FARPROC
 GRAYSTRINGPROC
 HANDLE *
 HICON *
@@ -127,6 +127,7 @@
 RECT *
 SCROLLINFO *
 SECURITY_QUALITY_OF_SERVICE *
+SENDASYNCPROC
 TIMERPROC
 UINT *
 WINDOWPLACEMENT *
diff --git a/tools/winapi_check/winapi_check b/tools/winapi_check/winapi_check
index 22d2ee9..d79be72 100755
--- a/tools/winapi_check/winapi_check
+++ b/tools/winapi_check/winapi_check
@@ -180,8 +180,7 @@
 
 foreach my $file (@c_files) {
     my %functions = ();
-    my @includes = ();
-    my %needed_includes = ();
+    my %includes = ();
 
     my $file_module16 = $modules->allowed_modules_in_file("$current_dir/$file");
     my $file_module32 = $modules->allowed_modules_in_file("$current_dir/$file");
@@ -241,8 +240,14 @@
 	    }
 	}
 
-	if(defined($declared_function)) {
-	    $needed_includes{$declared_function->file}++;
+	if($options->headers_needed && defined($declared_function)) {
+	    my $needed_include = $declared_function->file;
+
+	    if(!defined($includes{$needed_include})) {
+		my $header = $needed_include;
+		$header =~ s%^(include|$file_dir)/%%;
+		$output->write("prototype not included: #include \"$header\" is needed\n");
+	    }
 	}
 
 	if(1) {
@@ -399,21 +404,29 @@
 		}
 
 		if(defined($header)) {
+		    my $include;
 		    if(-e "$wine_dir/include/$header") {
-			push @includes, "include/$header";
+			$include = "include/$header";
 		    } elsif(-e "$file_dir/$header") {
-			push @includes, "$file_dir/$header";
+			$include = "$file_dir/$header";
 		    } elsif(-e "$file_dir/../$header") {
 			if($file_dir =~ m%^(.*?)/[^/]+$%) {
-			    push @includes, "$1/$header";
+			    $include = "$1/$header";
 			} else {
-			    push @includes, "$header";
+			    $include = "$header";
 			}
 		    } elsif($header eq "controls.h") { # FIXME: Kludge
-			push @includes, "dlls/user/controls.h";
+			$include = "dlls/user/controls.h";
 		    } elsif($check_local) {
 			$output->write("$file: #include \"$header\": file not found\n");
 		    }
+
+		    if(defined($include)) {
+			$includes{$include}++;
+			foreach my $include (keys(%{$include2info{$include}{includes}})) {
+			    $includes{$include}++;
+			}
+		    }
 		}
 
 		if($check_protection && $header) {
@@ -495,28 +508,6 @@
 	}
     }
 
-    if($options->headers_needed) {
-	my %includes2;
-	foreach my $include (@includes) {
-	    $includes2{$include}++;
-	    foreach my $include (keys(%{$include2info{$include}{includes}})) {
-		$includes2{$include}++;
-	    }
-	}
-	foreach my $needed_include (sort(keys(%needed_includes))) {
-	    my $found = 0;
-	    foreach my $include (sort(keys(%includes2))) {
-		if($needed_include eq $include) {
-		    $found = 1;
-		}
-	    }
-	    if(!$found) {
-		$output->write("$file: file '$needed_include' needed but not included\n");
-	    }
-	}
-    }
-	
-
     winapi_local::check_file $options, $output, $file, \%functions;
 }