diff --git a/src/main/cpp/locationinfo.cpp b/src/main/cpp/locationinfo.cpp
index e76ea29c..edcc05f5 100644
--- a/src/main/cpp/locationinfo.cpp
+++ b/src/main/cpp/locationinfo.cpp
@@ -148,7 +148,7 @@ void LocationInfo::write(ObjectOutputStream& os, Pool& p) const {
     if (lineNumber == -1 && fileName == NA && methodName == NA_METHOD) {
          os.writeNull(p);
     } else {
-        char prolog[] = {
+        uint8_t prolog[] = {
          0x72, 0x00, 0x21, 0x6F, 0x72, 0x67, 0x2E, 
          0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E, 0x6C, 
          0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, 
@@ -161,7 +161,7 @@ void LocationInfo::write(ObjectOutputStream& os, Pool& p) const {
                 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 
                 0x2F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B,
          0x78, 0x70 };
-      os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, prolog, sizeof(prolog), p);
+      os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, (char *)prolog, sizeof(prolog), p);
         char* line = p.itoa(lineNumber);
         //
         //   construct Java-like fullInfo (replace "::" with ".")
diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp
index 1c0d4be7..ba662147 100644
--- a/src/main/cpp/loggingevent.cpp
+++ b/src/main/cpp/loggingevent.cpp
@@ -236,7 +236,7 @@ void LoggingEvent::setProperty(const LogString& key, const LogString& value)
 
 
 void LoggingEvent::writeProlog(ObjectOutputStream& os, Pool& p)  {
-     char classDesc[] = {
+     uint8_t classDesc[] = {
         0x72, 0x00, 0x21, 
         0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 
         0x68, 0x65, 0x2E, 0x6C, 0x6F, 0x67, 0x34, 0x6A, 
@@ -292,7 +292,7 @@ void LoggingEvent::writeProlog(ObjectOutputStream& os, Pool& p)  {
         0x3B, 0x78, 0x70 }; 
 
      os.writeProlog("org.apache.log4j.spi.LoggingEvent", 
-        8, classDesc, sizeof(classDesc), p);
+        8, (char *)classDesc, sizeof(classDesc), p);
 }
 
 void LoggingEvent::write(helpers::ObjectOutputStream& os, Pool& p) const {
diff --git a/src/main/cpp/objectoutputstream.cpp b/src/main/cpp/objectoutputstream.cpp
index 7cd696b8..f80261d9 100644
--- a/src/main/cpp/objectoutputstream.cpp
+++ b/src/main/cpp/objectoutputstream.cpp
@@ -36,8 +36,8 @@ ObjectOutputStream::ObjectOutputStream(OutputStreamPtr outputStream, Pool& p)
        objectHandle(0x7E0000),
        classDescriptions(new ClassDescriptionMap())
 {
-   char start[] = { 0xAC, 0xED, 0x00, 0x05 };
-   ByteBuffer buf(start, sizeof(start));
+   uint8_t start[] = { 0xAC, 0xED, 0x00, 0x05 };
+   ByteBuffer buf((char *)start, sizeof(start));
    os->write(buf, p);
 }
 
@@ -81,7 +81,7 @@ void ObjectOutputStream::writeObject(const MDC::Map& val, Pool& p) {
     //
     //  TC_OBJECT and the classDesc for java.util.Hashtable
     //
-    char prolog[] = {
+    uint8_t prolog[] = {
         0x72, 0x00, 0x13, 0x6A, 0x61, 0x76, 0x61, 
         0x2E, 0x75, 0x74, 0x69, 0x6C, 0x2E, 0x48, 0x61, 
         0x73, 0x68, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x13, 
@@ -90,12 +90,12 @@ void ObjectOutputStream::writeObject(const MDC::Map& val, Pool& p) {
         0x64, 0x46, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x49, 
         0x00, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 
         0x6F, 0x6C, 0x64, 0x78, 0x70  };
-    writeProlog("java.util.Hashtable", 1, prolog, sizeof(prolog), p);
+    writeProlog("java.util.Hashtable", 1, (char *)prolog, sizeof(prolog), p);
     //
     //   loadFactor = 0.75, threshold = 5, blockdata start, buckets.size = 7
-    char data[] = { 0x3F, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 
+    uint8_t data[] = { 0x3F, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 
         TC_BLOCKDATA, 0x08, 0x00, 0x00, 0x00, 0x07 };
-    ByteBuffer dataBuf(data, sizeof(data));
+    ByteBuffer dataBuf((char *)data, sizeof(data));
     os->write(dataBuf, p);
     char size[4];
     size_t sz = val.size();
diff --git a/src/main/cpp/simpledateformat.cpp b/src/main/cpp/simpledateformat.cpp
index f18dfc75..cbce2db9 100644
--- a/src/main/cpp/simpledateformat.cpp
+++ b/src/main/cpp/simpledateformat.cpp
@@ -126,7 +126,7 @@ namespace log4cxx
                         size_t start = 0;
                         std::basic_ostringstream<wchar_t> os;
                         for(; valueIter != values.end(); valueIter++) {
-                            PUT_FACET(facet, os, &time, (wchar_t) wspec);
+                            PUT_FACET(facet, os, &time, wspec);
                             Transcoder::decode(os.str().substr(start), *valueIter);
                             start = os.str().length();
                             (*inc)(time, aprtime);
diff --git a/src/main/cpp/stringhelper.cpp b/src/main/cpp/stringhelper.cpp
index ca4b1ace..b89dc65d 100644
--- a/src/main/cpp/stringhelper.cpp
+++ b/src/main/cpp/stringhelper.cpp
@@ -21,6 +21,7 @@
 #include <log4cxx/helpers/transcoder.h>
 #include <algorithm>
 #include <vector>
+#include <iterator>
 #include <apr_strings.h>
 #include <log4cxx/helpers/pool.h>
 #if !defined(LOG4CXX)
diff --git a/src/main/include/log4cxx/asyncappender.h b/src/main/include/log4cxx/asyncappender.h
index cbe9b3c7..86a7371c 100644
--- a/src/main/include/log4cxx/asyncappender.h
+++ b/src/main/include/log4cxx/asyncappender.h
@@ -35,6 +35,7 @@
 
 namespace log4cxx
 {
+        LOG4CXX_LIST_DEF(LoggingEventList, log4cxx::spi::LoggingEventPtr);
 
         /**
         The AsyncAppender lets users log events asynchronously. It uses a
@@ -194,7 +195,6 @@ namespace log4cxx
                 /**
                  * Event buffer.
                 */
-                LOG4CXX_LIST_DEF(LoggingEventList, log4cxx::spi::LoggingEventPtr);
                 LoggingEventList buffer;
 
                 /**
diff --git a/src/main/include/log4cxx/helpers/bytearrayinputstream.h b/src/main/include/log4cxx/helpers/bytearrayinputstream.h
index 92bcb595..11d33def 100755
--- a/src/main/include/log4cxx/helpers/bytearrayinputstream.h
+++ b/src/main/include/log4cxx/helpers/bytearrayinputstream.h
@@ -32,6 +32,7 @@ namespace log4cxx
 {
 
         namespace helpers {
+          LOG4CXX_LIST_DEF(ByteList, unsigned char);
 
           /**
            * InputStream implemented on top of a byte array.
@@ -39,7 +40,6 @@ namespace log4cxx
           class LOG4CXX_EXPORT ByteArrayInputStream : public InputStream
           {
           private:
-              LOG4CXX_LIST_DEF(ByteList, unsigned char);
               ByteList buf;
               size_t pos;
 
diff --git a/src/main/include/log4cxx/helpers/bytearrayoutputstream.h b/src/main/include/log4cxx/helpers/bytearrayoutputstream.h
index 34e3d095..1f4233da 100644
--- a/src/main/include/log4cxx/helpers/bytearrayoutputstream.h
+++ b/src/main/include/log4cxx/helpers/bytearrayoutputstream.h
@@ -34,6 +34,7 @@ namespace log4cxx
 
         namespace helpers {
           class Pool;
+          LOG4CXX_LIST_DEF(ByteList, unsigned char);
 
           /**
           *   OutputStream implemented on top of std::vector
@@ -41,7 +42,6 @@ namespace log4cxx
           class LOG4CXX_EXPORT ByteArrayOutputStream : public OutputStream
           {
           private:
-                 LOG4CXX_LIST_DEF(ByteList, unsigned char);
                  ByteList array;
 
           public:
diff --git a/src/main/include/log4cxx/helpers/simpledateformat.h b/src/main/include/log4cxx/helpers/simpledateformat.h
index 9c27f685..0b4dc5fd 100644
--- a/src/main/include/log4cxx/helpers/simpledateformat.h
+++ b/src/main/include/log4cxx/helpers/simpledateformat.h
@@ -39,6 +39,8 @@ namespace log4cxx
             class PatternToken;
         }
 
+          LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);
+
           /**
            * Concrete class for formatting and parsing dates in a
            * locale-sensitive manner.
@@ -75,8 +77,6 @@ namespace log4cxx
                   /**
                    * List of tokens.
                    */
-                  LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);
-
                   PatternTokenList pattern;
                   
                   static void addToken(const logchar spec, const int repeat, const std::locale* locale, PatternTokenList& pattern);
diff --git a/src/main/include/log4cxx/helpers/socketoutputstream.h b/src/main/include/log4cxx/helpers/socketoutputstream.h
index 6bca1733..0c6fbb4f 100644
--- a/src/main/include/log4cxx/helpers/socketoutputstream.h
+++ b/src/main/include/log4cxx/helpers/socketoutputstream.h
@@ -32,6 +32,7 @@ namespace log4cxx
 {
         namespace helpers
         {
+                LOG4CXX_LIST_DEF(ByteList, unsigned char);
 
                 class LOG4CXX_EXPORT SocketOutputStream : public OutputStream
                 {
@@ -50,7 +51,6 @@ namespace log4cxx
                         virtual void write(ByteBuffer& buf, Pool& p);
 
                 private:
-                        LOG4CXX_LIST_DEF(ByteList, unsigned char);
                         ByteList array;
                         SocketPtr socket;
                        //
diff --git a/src/main/include/log4cxx/net/sockethubappender.h b/src/main/include/log4cxx/net/sockethubappender.h
index 89948334..b4269943 100644
--- a/src/main/include/log4cxx/net/sockethubappender.h
+++ b/src/main/include/log4cxx/net/sockethubappender.h
@@ -38,6 +38,8 @@ namespace log4cxx
         }
         namespace net
         {
+                LOG4CXX_LIST_DEF(ObjectOutputStreamList, log4cxx::helpers::ObjectOutputStreamPtr);
+
                 /**
                 Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objects to a set of remote log
                 servers, usually a SocketNode.
@@ -112,7 +114,6 @@ namespace log4cxx
                         static int DEFAULT_PORT;
 
                         int port;
-                        LOG4CXX_LIST_DEF(ObjectOutputStreamList, log4cxx::helpers::ObjectOutputStreamPtr);
                         ObjectOutputStreamList streams;
                         bool locationInfo;
 
diff --git a/src/main/include/log4cxx/net/telnetappender.h b/src/main/include/log4cxx/net/telnetappender.h
index 5cbe2b0b..17678d86 100644
--- a/src/main/include/log4cxx/net/telnetappender.h
+++ b/src/main/include/log4cxx/net/telnetappender.h
@@ -39,6 +39,8 @@ namespace log4cxx
         }
         namespace net
         {
+                typedef log4cxx::helpers::SocketPtr Connection;
+                LOG4CXX_LIST_DEF(ConnectionList, Connection);
 /**
 <p>The TelnetAppender is a log4cxx appender that specializes in
 writing to a read-only socket.  The output is provided in a
@@ -131,9 +133,6 @@ servlet.
                         TelnetAppender(const TelnetAppender&);
                         TelnetAppender& operator=(const TelnetAppender&);
 
-                        typedef log4cxx::helpers::SocketPtr Connection;
-                        LOG4CXX_LIST_DEF(ConnectionList, Connection);
-                        
                         void write(log4cxx::helpers::ByteBuffer&);
                         void writeStatus(const log4cxx::helpers::SocketPtr& socket, const LogString& msg, log4cxx::helpers::Pool& p);
                         ConnectionList connections;
diff --git a/src/main/include/log4cxx/patternlayout.h b/src/main/include/log4cxx/patternlayout.h
index 55d6eb5b..d084b6cb 100644
--- a/src/main/include/log4cxx/patternlayout.h
+++ b/src/main/include/log4cxx/patternlayout.h
@@ -32,6 +32,8 @@
 
 namespace log4cxx
 {
+        LOG4CXX_LIST_DEF(LoggingEventPatternConverterList, log4cxx::pattern::LoggingEventPatternConverterPtr);
+        LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
 
         /**
 
@@ -334,13 +336,11 @@ namespace log4cxx
                 /**
                  * Pattern converters.
                  */
-                LOG4CXX_LIST_DEF(LoggingEventPatternConverterList, log4cxx::pattern::LoggingEventPatternConverterPtr);
                 LoggingEventPatternConverterList patternConverters;
 
                /**
                 * Field widths and alignment corresponding to pattern converters.
                 */
-                LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
                 FormattingInfoList patternFields;
 
 
diff --git a/src/main/include/log4cxx/rolling/rollingpolicybase.h b/src/main/include/log4cxx/rolling/rollingpolicybase.h
index 154b17d9..ab8dad70 100755
--- a/src/main/include/log4cxx/rolling/rollingpolicybase.h
+++ b/src/main/include/log4cxx/rolling/rollingpolicybase.h
@@ -34,6 +34,8 @@
 
 namespace log4cxx {
     namespace rolling {
+        LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);
+        LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
 
         /**
          * Implements methods common to most, it not all, rolling
@@ -57,13 +59,11 @@ namespace log4cxx {
           /**
            * File name pattern converters.
            */
-          LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);
           PatternConverterList patternConverters;
 
           /**
            * File name field specifiers.
            */
-          LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
           FormattingInfoList patternFields;
 
           /**
diff --git a/src/main/include/log4cxx/spi/loggingevent.h b/src/main/include/log4cxx/spi/loggingevent.h
index 25f5c0dd..102bea21 100644
--- a/src/main/include/log4cxx/spi/loggingevent.h
+++ b/src/main/include/log4cxx/spi/loggingevent.h
@@ -43,6 +43,7 @@ namespace log4cxx
 
         namespace spi
         {
+                LOG4CXX_LIST_DEF(KeySet, LogString);
 
                 /**
                 The internal representation of logging events. When an affirmative
@@ -152,7 +153,6 @@ namespace log4cxx
                         */
                         bool getMDC(const LogString& key, LogString& dest) const;
 
-                        LOG4CXX_LIST_DEF(KeySet, LogString);
                         /**
                         * Returns the set of of the key values in the MDC for the event.
                         * The returned set is unmodifiable by the caller.
@@ -160,6 +160,7 @@ namespace log4cxx
                         * @return Set an unmodifiable set of the MDC keys.
                         * 
                         */
+                        typedef spi::KeySet KeySet;
                         KeySet getMDCKeySet() const;
 
                         /**
