Fixed sequence of DLL_PROCESS_DETACH notification calls.
Moved PE_MODREF flags to WINE_MODREF level.
Better handling of LoadLibraryEx flags.
PE_InitTls() changed to work only on the current thread.

diff --git a/include/module.h b/include/module.h
index 9a81bd7..4ae9d7b 100644
--- a/include/module.h
+++ b/include/module.h
@@ -111,6 +111,7 @@
 typedef struct _wine_modref
 {
 	struct _wine_modref	*next;
+	struct _wine_modref	*prev;
 	MODULE32_TYPE		type;
 	union {
 		PE_MODREF	pe;
@@ -121,13 +122,24 @@
 
 	int			nDeps;
 	struct _wine_modref	**deps;
-	int			initDone;
+
+	int			flags;
+	int			refCount;
 
 	char			*modname;
 	char			*shortname;
 	char 			*longname;
 } WINE_MODREF;
 
+#define WINE_MODREF_INTERNAL              0x00000001
+#define WINE_MODREF_NO_DLL_CALLS          0x00000002
+#define WINE_MODREF_PROCESS_ATTACHED      0x00000004
+#define WINE_MODREF_PROCESS_DETACHED      0x00000008
+#define WINE_MODREF_LOAD_AS_DATAFILE      0x00000010
+#define WINE_MODREF_DONT_RESOLVE_REFS     0x00000020
+#define WINE_MODREF_MARKER                0x80000000
+
+
 
 /* Resource types */
 typedef struct resource_typeinfo_s NE_TYPEINFO;