#include <Scrap.h>
 #endif
 #include <MacTextEditor.h>
-#include "ATSUnicode.h"
-#include "TextCommon.h"
-#include "TextEncodingConverter.h"
+#include <ATSUnicode.h>
+#include <TextCommon.h>
+#include <TextEncodingConverter.h>
 #include "wx/mac/uma.h"
 
 #define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
 // moment is to avoid setting the true focus on the control, the proper solution at the end would be to have
 // an alternate path for carbon key events that routes automatically into the same wx flow of events
 
-#include "MacTextEditor.h"
-
 /* part codes */
 
 /* kmUPTextPart is the part code we return to indicate the user has clicked
         }
         else
         {
-            actualSize = GetHandleSize( theText ) ;
+            actualSize = GetHandleSize( theText ) / sizeof( UniChar) ;
             if ( actualSize > 0 )
             {
                 wxChar *ptr = result.GetWriteBuf(actualSize*sizeof(wxChar)) ;
                                HUnlock( theText ) ;
 #endif
                 ptr[actualSize] = 0 ;
-                result.UngetWriteBuf( actualSize ) ;
+                result.UngetWriteBuf( actualSize *sizeof(wxChar) ) ;
             }
             DisposeHandle( theText ) ;
         }
 
 #include <Scrap.h>
 #endif
 #include <MacTextEditor.h>
-#include "ATSUnicode.h"
-#include "TextCommon.h"
-#include "TextEncodingConverter.h"
+#include <ATSUnicode.h>
+#include <TextCommon.h>
+#include <TextEncodingConverter.h>
 #include "wx/mac/uma.h"
 
 #define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
 // moment is to avoid setting the true focus on the control, the proper solution at the end would be to have
 // an alternate path for carbon key events that routes automatically into the same wx flow of events
 
-#include "MacTextEditor.h"
-
 /* part codes */
 
 /* kmUPTextPart is the part code we return to indicate the user has clicked
         }
         else
         {
-            actualSize = GetHandleSize( theText ) ;
+            actualSize = GetHandleSize( theText ) / sizeof( UniChar) ;
             if ( actualSize > 0 )
             {
                 wxChar *ptr = result.GetWriteBuf(actualSize*sizeof(wxChar)) ;
                                HUnlock( theText ) ;
 #endif
                 ptr[actualSize] = 0 ;
-                result.UngetWriteBuf( actualSize ) ;
+                result.UngetWriteBuf( actualSize *sizeof(wxChar) ) ;
             }
             DisposeHandle( theText ) ;
         }