Moved a few more functions to dlls/kernel.

diff --git a/dlls/kernel/local16.c b/dlls/kernel/local16.c
index 6f588f5..7baf01f 100644
--- a/dlls/kernel/local16.c
+++ b/dlls/kernel/local16.c
@@ -393,8 +393,6 @@
 }
 
 
-#if 0  /* FIXME: LocalInit16 must still be in ntdll for now */
-
 /***********************************************************************
  *           LocalInit   (KERNEL.4)
  */
@@ -404,7 +402,6 @@
     WORD heapInfoArena, freeArena, lastArena;
     LOCALHEAPINFO *pHeapInfo;
     LOCALARENA *pArena, *pFirstArena, *pLastArena;
-    NE_MODULE *pModule;
     BOOL16 ret = FALSE;
 
       /* The initial layout of the heap is: */
@@ -416,7 +413,7 @@
     TRACE("%04x %04x-%04x\n", selector, start, end);
     if (!selector) selector = CURRENT_DS;
 
-    if (TRACE_ON(heap))
+    if (TRACE_ON(local))
     {
         /* If TRACE_ON(heap) is set, the global heap blocks are */
         /* cleared before use, so we can test for double initialization. */
@@ -436,27 +433,6 @@
         if ( end > 0xfffe ) end = 0xfffe;
         start -= end;
         end += start;
-
-        /* Paranoid check */
-
-	if ((pModule = NE_GetPtr( GlobalHandle16( selector ) )))
-	{
-	    SEGTABLEENTRY *pSeg = NE_SEG_TABLE( pModule );
-            int segNr;
-
-            for ( segNr = 0; segNr < pModule->seg_count; segNr++, pSeg++ )
-                if ( GlobalHandleToSel16(pSeg->hSeg) == selector )
-                    break;
-
-            if ( segNr < pModule->seg_count )
-            {
-                WORD minsize = pSeg->minsize;
-                if ( pModule->ss == segNr+1 )
-                    minsize += pModule->stack_size;
-
-		TRACE(" new start %04x, minstart: %04x\n", start, minsize);
-	    }
-	}
     }
     ptr = MapSL( MAKESEGPTR( selector, 0 ) );
 
@@ -526,7 +502,7 @@
     CURRENT_STACK16->ecx = ret;  /* must be returned in cx too */
     return ret;
 }
-#endif
+
 
 /***********************************************************************
  *           LOCAL_GrowHeap
diff --git a/loader/task.c b/loader/task.c
index e954081..031167b 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -51,10 +51,6 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(task);
 
-  /* Min. number of thunks allocated when creating a new segment */
-#define MIN_THUNKS  32
-
-
 static THHOOK DefaultThhook;
 THHOOK *pThhook = &DefaultThhook;
 
@@ -79,47 +75,6 @@
 
 
 /***********************************************************************
- *           PostEvent  (KERNEL.31)
- */
-void WINAPI PostEvent16( HTASK16 hTask )
-{
-    TDB *pTask;
-
-    if (!hTask) hTask = GetCurrentTask();
-    if (!(pTask = TASK_GetPtr( hTask ))) return;
-
-    if (pTask->flags & TDBF_WIN32)
-    {
-        FIXME("called for Win32 thread (%04x)!\n", pTask->teb->teb_sel );
-        return;
-    }
-
-    pTask->nEvents++;
-
-    if (pTask->nEvents == 1) NtSetEvent( pTask->hEvent, NULL );
-}
-
-
-/***********************************************************************
- *           OldYield  (KERNEL.117)
- */
-void WINAPI OldYield16(void)
-{
-   DWORD count;
-
-   ReleaseThunkLock(&count);
-   RestoreThunkLock(count);
-}
-
-/***********************************************************************
- *           DirectedYield  (KERNEL.150)
- */
-void WINAPI DirectedYield16( HTASK16 hTask )
-{
-    OldYield16();
-}
-
-/***********************************************************************
  *           GetCurrentTask   (KERNEL32.@)
  */
 HTASK16 WINAPI GetCurrentTask(void)
diff --git a/memory/local.c b/memory/local.c
index 8161985..5615e08 100644
--- a/memory/local.c
+++ b/memory/local.c
@@ -30,192 +30,7 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include "wine/winbase16.h"
-#include "instance.h"
-#include "local.h"
-#include "module.h"
-#include "stackframe.h"
-#include "toolhelp.h"
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(local);
-
-typedef struct
-{
-/* Arena header */
-    WORD prev;          /* Previous arena | arena type */
-    WORD next;          /* Next arena */
-/* Start of the memory block or free-list info */
-    WORD size;          /* Size of the free block */
-    WORD free_prev;     /* Previous free block */
-    WORD free_next;     /* Next free block */
-} LOCALARENA;
-
-#define ARENA_HEADER_SIZE      4
-#define ARENA_HEADER( handle) ((handle) - ARENA_HEADER_SIZE)
-
-  /* Arena types (stored in 'prev' field of the arena) */
-#define LOCAL_ARENA_FREE       0
-#define LOCAL_ARENA_FIXED      1
-
-#include "pshpack1.h"
-
-typedef struct
-{
-    WORD check;                 /* 00 Heap checking flag */
-    WORD freeze;                /* 02 Heap frozen flag */
-    WORD items;                 /* 04 Count of items on the heap */
-    WORD first;                 /* 06 First item of the heap */
-    WORD pad1;                  /* 08 Always 0 */
-    WORD last;                  /* 0a Last item of the heap */
-    WORD pad2;                  /* 0c Always 0 */
-    BYTE ncompact;              /* 0e Compactions counter */
-    BYTE dislevel;              /* 0f Discard level */
-    DWORD distotal;             /* 10 Total bytes discarded */
-    WORD htable;                /* 14 Pointer to handle table */
-    WORD hfree;                 /* 16 Pointer to free handle table */
-    WORD hdelta;                /* 18 Delta to expand the handle table */
-    WORD expand;                /* 1a Pointer to expand function (unused) */
-    WORD pstat;                 /* 1c Pointer to status structure (unused) */
-    FARPROC16 notify WINE_PACKED; /* 1e Pointer to LocalNotify() function */
-    WORD lock;                  /* 22 Lock count for the heap */
-    WORD extra;                 /* 24 Extra bytes to allocate when expanding */
-    WORD minsize;               /* 26 Minimum size of the heap */
-    WORD magic;                 /* 28 Magic number */
-} LOCALHEAPINFO;
-
-#include "poppack.h"
-
-#define LOCAL_HEAP_MAGIC  0x484c  /* 'LH' */
-
-  /* All local heap allocations are aligned on 4-byte boundaries */
-#define LALIGN(word)          (((word) + 3) & ~3)
-
-#define ARENA_PTR(ptr,arena)       ((LOCALARENA *)((char*)(ptr)+(arena)))
-#define ARENA_PREV(ptr,arena)      (ARENA_PTR((ptr),(arena))->prev & ~3)
-#define ARENA_NEXT(ptr,arena)      (ARENA_PTR((ptr),(arena))->next)
-#define ARENA_FLAGS(ptr,arena)     (ARENA_PTR((ptr),(arena))->prev & 3)
-
-
-/***********************************************************************
- *           LocalInit   (KERNEL.4)
- */
-BOOL16 WINAPI LocalInit16( HANDLE16 selector, WORD start, WORD end )
-{
-    char *ptr;
-    WORD heapInfoArena, freeArena, lastArena;
-    LOCALHEAPINFO *pHeapInfo;
-    LOCALARENA *pArena, *pFirstArena, *pLastArena;
-    NE_MODULE *pModule;
-    BOOL16 ret = FALSE;
-
-      /* The initial layout of the heap is: */
-      /* - first arena         (FIXED)      */
-      /* - heap info structure (FIXED)      */
-      /* - large free block    (FREE)       */
-      /* - last arena          (FREE)       */
-
-    TRACE("%04x %04x-%04x\n", selector, start, end);
-    if (!selector) selector = CURRENT_DS;
-
-    if (start == 0)
-    {
-        /* start == 0 means: put the local heap at the end of the segment */
-
-        DWORD size = GlobalSize16( GlobalHandle16( selector ) );
-	start = (WORD)(size > 0xffff ? 0xffff : size) - 1;
-        if ( end > 0xfffe ) end = 0xfffe;
-        start -= end;
-        end += start;
-
-        /* Paranoid check */
-
-	if ((pModule = NE_GetPtr( GlobalHandle16( selector ) )))
-	{
-	    SEGTABLEENTRY *pSeg = NE_SEG_TABLE( pModule );
-            int segNr;
-
-            for ( segNr = 0; segNr < pModule->seg_count; segNr++, pSeg++ )
-                if ( GlobalHandleToSel16(pSeg->hSeg) == selector )
-                    break;
-
-            if ( segNr < pModule->seg_count )
-            {
-                WORD minsize = pSeg->minsize;
-                if ( pModule->ss == segNr+1 )
-                    minsize += pModule->stack_size;
-
-		TRACE(" new start %04x, minstart: %04x\n", start, minsize);
-	    }
-	}
-    }
-    ptr = MapSL( MAKESEGPTR( selector, 0 ) );
-
-    start = LALIGN( max( start, sizeof(INSTANCEDATA) ) );
-    heapInfoArena = LALIGN(start + sizeof(LOCALARENA) );
-    freeArena = LALIGN( heapInfoArena + ARENA_HEADER_SIZE
-                        + sizeof(LOCALHEAPINFO) );
-    lastArena = (end - sizeof(LOCALARENA)) & ~3;
-
-      /* Make sure there's enough space.       */
-
-    if (freeArena + sizeof(LOCALARENA) >= lastArena) goto done;
-
-      /* Initialise the first arena */
-
-    pFirstArena = ARENA_PTR( ptr, start );
-    pFirstArena->prev      = start | LOCAL_ARENA_FIXED;
-    pFirstArena->next      = heapInfoArena;
-    pFirstArena->size      = LALIGN(sizeof(LOCALARENA));
-    pFirstArena->free_prev = start;  /* this one */
-    pFirstArena->free_next = freeArena;
-
-      /* Initialise the arena of the heap info structure */
-
-    pArena = ARENA_PTR( ptr, heapInfoArena );
-    pArena->prev = start | LOCAL_ARENA_FIXED;
-    pArena->next = freeArena;
-
-      /* Initialise the heap info structure */
-
-    pHeapInfo = (LOCALHEAPINFO *) (ptr + heapInfoArena + ARENA_HEADER_SIZE );
-    memset( pHeapInfo, 0, sizeof(LOCALHEAPINFO) );
-    pHeapInfo->items   = 4;
-    pHeapInfo->first   = start;
-    pHeapInfo->last    = lastArena;
-    pHeapInfo->htable  = 0;
-    pHeapInfo->hdelta  = 0x20;
-    pHeapInfo->extra   = 0x200;
-    pHeapInfo->minsize = lastArena - freeArena;
-    pHeapInfo->magic   = LOCAL_HEAP_MAGIC;
-
-      /* Initialise the large free block */
-
-    pArena = ARENA_PTR( ptr, freeArena );
-    pArena->prev      = heapInfoArena | LOCAL_ARENA_FREE;
-    pArena->next      = lastArena;
-    pArena->size      = lastArena - freeArena;
-    pArena->free_prev = start;
-    pArena->free_next = lastArena;
-
-      /* Initialise the last block */
-
-    pLastArena = ARENA_PTR( ptr, lastArena );
-    pLastArena->prev      = freeArena | LOCAL_ARENA_FREE;
-    pLastArena->next      = lastArena;  /* this one */
-    pLastArena->size      = LALIGN(sizeof(LOCALARENA));
-    pLastArena->free_prev = freeArena;
-    pLastArena->free_next = lastArena;  /* this one */
-
-      /* Store the local heap address in the instance data */
-
-    ((INSTANCEDATA *)ptr)->heap = heapInfoArena + ARENA_HEADER_SIZE;
-    ret = TRUE;
-
- done:
-    CURRENT_STACK16->ecx = ret;  /* must be returned in cx too */
-    return ret;
-}
+#include "winbase.h"
 
 
 /***********************************************************************