Merge branch 'master' into legacy-compilers
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0796d63..df5909e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,8 @@
 # Find Apache Runtime Utilities
 find_package(APR-Util REQUIRED)
 
+find_package( Threads REQUIRED )
+
 # Find expat for XML parsing
 find_package(EXPAT REQUIRED)
 
@@ -137,6 +139,9 @@
 get_directory_property( HAS_LIBESMTP DIRECTORY src/main/include DEFINITION HAS_LIBESMTP )
 get_directory_property( HAS_ODBC DIRECTORY src/main/include DEFINITION HAS_ODBC )
 get_directory_property( HAS_SYSLOG DIRECTORY src/main/include DEFINITION HAS_SYSLOG )
+get_directory_property( THREAD_IMPL DIRECTORY src/main/include DEFINITION THREAD_IMPL )
+get_directory_property( SMART_PTR_IMPL DIRECTORY src/main/include DEFINITION SMART_PTR_IMPL )
+get_directory_property( MUTEX_IMPL DIRECTORY src/main/include DEFINITION MUTEX_IMPL )
 
 foreach(varName HAS_STD_LOCALE  HAS_ODBC  HAS_MBSRTOWCS  HAS_WCSTOMBS  HAS_FWIDE  HAS_LIBESMTP  HAS_SYSLOG)
   if(${varName} EQUAL 0)
@@ -188,10 +193,14 @@
 message(STATUS "  log4cxx cfstring API ............ : ${LOG4CXX_CFSTRING}")
 endif()
 message(STATUS "  logchar type .................... : ${LOG4CXX_CHAR}")
+message(STATUS "  charset ......................... : ${LOG4CXX_CHARSET}")
 message(STATUS "  Using libESMTP .................. : ${HAS_LIBESMTP}")
 message(STATUS "  ODBC library .................... : ${HAS_ODBC}")
 message(STATUS "  syslog .......................... : ${HAS_SYSLOG}")
 message(STATUS "  Qt support ...................... : ${LOG4CXX_QT_SUPPORT}")
+message(STATUS "  thread implementation ........... : ${THREAD_IMPL}")
+message(STATUS "  smart pointer implementation .... : ${SMART_PTR_IMPL}")
+message(STATUS "  mutex implementation ............ : ${MUTEX_IMPL}")
 
 if(BUILD_TESTING)
 message(STATUS "Applications required for tests:")
diff --git a/src/cmake/boost-fallback/LICENSE b/src/cmake/boost-fallback/LICENSE
new file mode 100644
index 0000000..56eb5b8
--- /dev/null
+++ b/src/cmake/boost-fallback/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 Robert Middleton
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/src/cmake/boost-fallback/README.md b/src/cmake/boost-fallback/README.md
new file mode 100644
index 0000000..537fde6
--- /dev/null
+++ b/src/cmake/boost-fallback/README.md
@@ -0,0 +1,14 @@
+To use:
+
+1. Include boost-fallback.cmake in your project
+2. If desired, use the provided header file to switch between the various
+ implementations:
+
+```
+include(boost-fallback/boost-fallback.cmake)
+
+set(NAMESPACE_ALIAS some_namespace)
+configure_file(boost-fallback/boost-std-configuration.h.cmake
+    boost-fallback/boost-std-configuration.h)
+target_include_directories( executable-name PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/boost-fallback )
+```
diff --git a/src/cmake/boost-fallback/boost-fallback.cmake b/src/cmake/boost-fallback/boost-fallback.cmake
new file mode 100644
index 0000000..0f91ac3
--- /dev/null
+++ b/src/cmake/boost-fallback/boost-fallback.cmake
@@ -0,0 +1,82 @@
+#include(${CMAKE_MODULE_PATH}/FindPackageHandleStandardArgs.cmake)
+
+# Checks for classes in std::, falling back to boost if the requested
+# classes are not available
+#
+# Available classes to check for:
+# thread
+# mutex
+# shared_mutex
+#
+# Variables set:
+# ${prefix}_
+
+#function(_boost_fallback_thread)
+#    try_compile(HAS_STD_THREAD "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+#	"${CMAKE_CURRENT_LIST_DIR}/test-stdthread.cpp")
+
+
+#    find_package(boost_thread COMPONENTS thread)
+#endfunction()
+
+## check for boost fallback instead of std:: classes
+## arg1: prefix for variables to set
+## arg2: list of classes to check for
+#function(boost_fallback prefix classes)
+#endfunction()
+
+#
+# This module checks for C++ standard classes and their boost counterparts
+#
+# Thread variables set:
+# STD_THREAD_FOUND - if std::thread is found
+# Boost_THREAD_FOUND - if boost::thread is found
+#
+# Mutex variables set:
+# STD_MUTEX_FOUND - if std::mutex is found
+# STD_SHARED_MUTEX_FOUND - if std::shared_mutex is found
+# Boost_MUTEX_FOUND - if boost::mutex is found
+# Boost_SHARED_MUTEX_FOUND - if boost::shared_mutex is found
+#
+# Smart pointer variables set:
+# STD_SHARED_PTR_FOUND - if std::shared_ptr is found
+# Boost_SHARED_PTR_FOUND - if boost::shared_ptr is found
+
+include(FindThreads)
+
+try_compile(STD_THREAD_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+    "${CMAKE_CURRENT_LIST_DIR}/test-stdthread.cpp")
+try_compile(STD_MUTEX_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+    "${CMAKE_CURRENT_LIST_DIR}/test-stdmutex.cpp")
+try_compile(STD_SHARED_MUTEX_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+    "${CMAKE_CURRENT_LIST_DIR}/test-stdsharedmutex.cpp")
+try_compile(STD_SHARED_PTR_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+    "${CMAKE_CURRENT_LIST_DIR}/test-stdsharedptr.cpp")
+
+find_package(Boost COMPONENTS thread)
+try_compile(Boost_SHARED_PTR_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+    "${CMAKE_CURRENT_LIST_DIR}/test-boostsharedptr.cpp")
+try_compile(Boost_MUTEX_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+    "${CMAKE_CURRENT_LIST_DIR}/test-boostmutex.cpp")
+try_compile(Boost_SHARED_MUTEX_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+    "${CMAKE_CURRENT_LIST_DIR}/test-boostsharedmutex.cpp"
+    LINK_LIBRARIES Threads::Threads
+)
+
+# Link the target with the appropriate boost libraries(if required)
+function(boostfallback_link target)
+    if(NOT ${STD_THREAD_FOUND})
+        if(${Boost_THREAD_FOUND})
+           find_package(Boost COMPONENTS thread)
+           target_link_libraries( ${target} PUBLIC Boost::thread)
+        endif()
+    endif()
+    if(NOT ${STD_SHARED_MUTEX_FOUND})
+        if(${Boost_SHARED_MUTEX_FOUND})
+           find_package(Boost COMPONENTS thread)
+           target_link_libraries( ${target} PUBLIC Boost::thread)
+        endif()
+    endif()
+endfunction()
+
+
diff --git a/src/cmake/boost-fallback/boost-std-configuration.h.cmake b/src/cmake/boost-fallback/boost-std-configuration.h.cmake
new file mode 100644
index 0000000..58e3eca
--- /dev/null
+++ b/src/cmake/boost-fallback/boost-std-configuration.h.cmake
@@ -0,0 +1,78 @@
+#ifndef BOOST_STD_CONFIGURATION_H
+#define BOOST_STD_CONFIGURATION_H
+
+#cmakedefine01 STD_THREAD_FOUND
+#cmakedefine01 Boost_THREAD_FOUND
+#cmakedefine01 STD_MUTEX_FOUND
+#cmakedefine01 Boost_MUTEX_FOUND
+#cmakedefine01 STD_SHARED_MUTEX_FOUND
+#cmakedefine01 Boost_SHARED_MUTEX_FOUND
+#cmakedefine01 STD_SHARED_PTR_FOUND
+#cmakedefine01 Boost_SHARED_PTR_FOUND
+
+#if STD_THREAD_FOUND
+#include <thread>
+namespace ${NAMESPACE_ALIAS} {
+    typedef std::thread thread;
+}
+#elif Boost_THREAD_FOUND
+#include <boost/thread.hpp>
+namespace ${NAMESPACE_ALIAS} {
+    typedef boost::thread thread;
+}
+#endif
+
+#if STD_MUTEX_FOUND
+#include <mutex>
+#include <condition_variable>
+namespace ${NAMESPACE_ALIAS} {
+    typedef std::mutex mutex;
+    template <typename T>
+    using unique_lock = std::unique_lock<T>;
+    typedef std::condition_variable condition_variable;
+}
+#elif Boost_MUTEX_FOUND
+#include <boost/thread.hpp>
+namespace ${NAMESPACE_ALIAS} {
+    typedef boost::mutex mutex;
+    template <typename T>
+    using unique_lock = boost::unique_lock<T>;
+    typedef boost::condition_variable condition_variable;
+}
+#endif
+
+#if STD_SHARED_MUTEX_FOUND
+#include <shared_mutex>
+namespace ${NAMESPACE_ALIAS} {
+    typedef std::shared_mutex shared_mutex;
+    template <typename T>
+    using shared_lock = std::shared_lock<T>;
+}
+#elif Boost_SHARED_MUTEX_FOUND
+#include <boost/thread/shared_mutex.hpp>
+namespace ${NAMESPACE_ALIAS} {
+    typedef boost::shared_mutex shared_mutex;
+    template <typename T>
+    using shared_lock = boost::shared_lock<T>;
+}
+#endif
+
+#if STD_SHARED_PTR_FOUND
+#include <memory>
+namespace ${NAMESPACE_ALIAS} {
+    template <typename T>
+    using shared_ptr = std::shared_ptr<T>;
+    template <typename T>
+    using weak_ptr = std::weak_ptr<T>;
+}
+#elif Boost_SHARED_PTR_FOUND
+#include <boost/smart_ptr.hpp>
+namespace ${NAMESPACE_ALIAS} {
+    template <typename T>
+    using shared_ptr = boost::shared_ptr<T>;
+    template <typename T>
+    using weak_ptr = boost::weak_ptr<T>;
+}
+#endif
+
+#endif /* BOOST_STD_CONFIGURATION_H */
diff --git a/src/cmake/boost-fallback/test-boostmutex.cpp b/src/cmake/boost-fallback/test-boostmutex.cpp
new file mode 100644
index 0000000..f10d0fc
--- /dev/null
+++ b/src/cmake/boost-fallback/test-boostmutex.cpp
@@ -0,0 +1,6 @@
+#include <boost/thread.hpp>
+
+int main(int argc, char** argv){
+	boost::mutex mutex;
+	return 0;
+}
diff --git a/src/cmake/boost-fallback/test-boostsharedmutex.cpp b/src/cmake/boost-fallback/test-boostsharedmutex.cpp
new file mode 100644
index 0000000..3f88de6
--- /dev/null
+++ b/src/cmake/boost-fallback/test-boostsharedmutex.cpp
@@ -0,0 +1,6 @@
+#include <boost/thread/shared_mutex.hpp>
+
+int main(int argc, char** argv){
+	boost::shared_mutex mtx;
+	return 0;
+}
diff --git a/src/cmake/boost-fallback/test-boostsharedptr.cpp b/src/cmake/boost-fallback/test-boostsharedptr.cpp
new file mode 100644
index 0000000..3371640
--- /dev/null
+++ b/src/cmake/boost-fallback/test-boostsharedptr.cpp
@@ -0,0 +1,10 @@
+#include <boost/smart_ptr.hpp>
+
+struct foo{
+	int x;
+};
+
+int main(int argc, char** argv){
+	boost::shared_ptr<foo> fooptr;
+	return 0;
+}
diff --git a/src/cmake/boost-fallback/test-boostthread.cpp b/src/cmake/boost-fallback/test-boostthread.cpp
new file mode 100644
index 0000000..2c9cdf7
--- /dev/null
+++ b/src/cmake/boost-fallback/test-boostthread.cpp
@@ -0,0 +1,6 @@
+#include <boost/thread.hpp>
+
+int main(int argc, char** argv){
+	boost::thread th;
+	return 0;
+}
diff --git a/src/cmake/boost-fallback/test-stdmutex.cpp b/src/cmake/boost-fallback/test-stdmutex.cpp
new file mode 100644
index 0000000..3805ed6
--- /dev/null
+++ b/src/cmake/boost-fallback/test-stdmutex.cpp
@@ -0,0 +1,6 @@
+#include <mutex>
+
+int main(int argc, char** argv){
+	std::mutex mutex;
+	return 0;
+}
diff --git a/src/cmake/boost-fallback/test-stdsharedmutex.cpp b/src/cmake/boost-fallback/test-stdsharedmutex.cpp
new file mode 100644
index 0000000..a99a272
--- /dev/null
+++ b/src/cmake/boost-fallback/test-stdsharedmutex.cpp
@@ -0,0 +1,6 @@
+#include <shared_mutex>
+
+int main(int argc, char** argv){
+	std::shared_mutex shared;
+	return 0;
+}
diff --git a/src/cmake/boost-fallback/test-stdsharedptr.cpp b/src/cmake/boost-fallback/test-stdsharedptr.cpp
new file mode 100644
index 0000000..b5af4d5
--- /dev/null
+++ b/src/cmake/boost-fallback/test-stdsharedptr.cpp
@@ -0,0 +1,10 @@
+#include <memory>
+
+struct foo{
+	int x;
+};
+
+int main(int argc, char** argv){
+	std::shared_ptr<foo> fooptr;
+	return 0;
+}
diff --git a/src/cmake/boost-fallback/test-stdthread.cpp b/src/cmake/boost-fallback/test-stdthread.cpp
new file mode 100644
index 0000000..9d8b4f6
--- /dev/null
+++ b/src/cmake/boost-fallback/test-stdthread.cpp
@@ -0,0 +1,6 @@
+#include <thread>
+
+int main(int argc, char** argv){
+	std::thread th;
+	return 0;
+}
diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt
index ffe2429..7c518e3 100644
--- a/src/main/cpp/CMakeLists.txt
+++ b/src/main/cpp/CMakeLists.txt
@@ -29,7 +29,6 @@
   class.cpp
   classnamepatternconverter.cpp
   classregistration.cpp
-  condition.cpp
   configurator.cpp
   consoleappender.cpp
   cyclicbuffer.cpp
@@ -93,15 +92,12 @@
   messagebuffer.cpp
   messagepatternconverter.cpp
   methodlocationpatternconverter.cpp
-  mutex.cpp
   nameabbreviator.cpp
   namepatternconverter.cpp
   ndc.cpp
   ndcpatternconverter.cpp
   nteventlogappender.cpp
-  objectimpl.cpp
   objectoutputstream.cpp
-  objectptr.cpp
   obsoleterollingfileappender.cpp
   odbcappender.cpp
   onlyonceerrorhandler.cpp
@@ -141,14 +137,12 @@
   stringhelper.cpp
   stringmatchfilter.cpp
   stringtokenizer.cpp
-  synchronized.cpp
   syslogappender.cpp
   syslogwriter.cpp
   system.cpp
   systemerrwriter.cpp
   systemoutwriter.cpp
   telnetappender.cpp
-  threadcxx.cpp
   threadlocal.cpp
   threadpatternconverter.cpp
   threadspecificdata.cpp
@@ -169,3 +163,4 @@
   VERSION ${LIBLOG4CXX_LIB_VERSION}
   SOVERSION ${LIBLOG4CXX_LIB_SOVERSION}
 )
+boostfallback_link(log4cxx)
diff --git a/src/main/cpp/action.cpp b/src/main/cpp/action.cpp
index ee347e4..d652cf5 100644
--- a/src/main/cpp/action.cpp
+++ b/src/main/cpp/action.cpp
@@ -16,7 +16,6 @@
  */
 #include <log4cxx/logstring.h>
 #include <log4cxx/rolling/action.h>
-#include <log4cxx/helpers/synchronized.h>
 
 using namespace log4cxx;
 using namespace log4cxx::rolling;
@@ -27,8 +26,7 @@
 Action::Action() :
 	complete(false),
 	interrupted(false),
-	pool(),
-	mutex(pool)
+    pool()
 {
 }
 
@@ -41,7 +39,7 @@
  */
 void Action::run(log4cxx::helpers::Pool& pool1)
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 	if (!interrupted)
 	{
@@ -64,7 +62,7 @@
  */
 void Action::close()
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 	interrupted = true;
 }
 
diff --git a/src/main/cpp/appenderattachableimpl.cpp b/src/main/cpp/appenderattachableimpl.cpp
index ad85216..eb00bd9 100644
--- a/src/main/cpp/appenderattachableimpl.cpp
+++ b/src/main/cpp/appenderattachableimpl.cpp
@@ -29,23 +29,12 @@
 
 
 AppenderAttachableImpl::AppenderAttachableImpl(Pool& pool)
-	: appenderList(),
-	  mutex(pool)
+    : appenderList()
 {
 }
 
-void AppenderAttachableImpl::addRef() const
-{
-	ObjectImpl::addRef();
-}
 
-void AppenderAttachableImpl::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
-
-void AppenderAttachableImpl::addAppender(const AppenderPtr& newAppender)
+void AppenderAttachableImpl::addAppender(const AppenderPtr newAppender)
 {
 	// Null values for newAppender parameter are strictly forbidden.
 	if (newAppender == 0)
@@ -104,7 +93,7 @@
 	return 0;
 }
 
-bool AppenderAttachableImpl::isAttached(const AppenderPtr& appender) const
+bool AppenderAttachableImpl::isAttached(const AppenderPtr appender) const
 {
 	if (appender == 0)
 	{
@@ -131,7 +120,7 @@
 	appenderList.clear();
 }
 
-void AppenderAttachableImpl::removeAppender(const AppenderPtr& appender)
+void AppenderAttachableImpl::removeAppender(const AppenderPtr appender)
 {
 	if (appender == 0)
 	{
diff --git a/src/main/cpp/appenderskeleton.cpp b/src/main/cpp/appenderskeleton.cpp
index 42c1999..42a30ca 100644
--- a/src/main/cpp/appenderskeleton.cpp
+++ b/src/main/cpp/appenderskeleton.cpp
@@ -21,9 +21,6 @@
 #include <log4cxx/helpers/onlyonceerrorhandler.h>
 #include <log4cxx/level.h>
 #include <log4cxx/helpers/stringhelper.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <apr_atomic.h>
-
 
 using namespace log4cxx;
 using namespace log4cxx::spi;
@@ -39,10 +36,9 @@
 		errorHandler(new OnlyOnceErrorHandler()),
 		headFilter(),
 		tailFilter(),
-		pool(),
-		SHARED_MUTEX_INIT(mutex, pool)
+        pool()
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 	closed = false;
 }
 
@@ -53,23 +49,12 @@
 	  errorHandler(new OnlyOnceErrorHandler()),
 	  headFilter(),
 	  tailFilter(),
-	  pool(),
-	  SHARED_MUTEX_INIT(mutex, pool)
+      pool()
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 	closed = false;
 }
 
-void AppenderSkeleton::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void AppenderSkeleton::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
 void AppenderSkeleton::finalize()
 {
 	// An appender might be closed then garbage collected. There is no
@@ -84,7 +69,7 @@
 
 void AppenderSkeleton::addFilter(const spi::FilterPtr& newFilter)
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
 	if (headFilter == 0)
 	{
@@ -99,7 +84,7 @@
 
 void AppenderSkeleton::clearFilters()
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 	headFilter = tailFilter = 0;
 }
 
@@ -110,7 +95,7 @@
 
 void AppenderSkeleton::doAppend(const spi::LoggingEventPtr& event, Pool& pool1)
 {
-	LOCK_W sync(mutex);
+	log4cxx::shared_lock<log4cxx::shared_mutex> lock(mutex);
 
 	doAppendImpl(event, pool1);
 }
@@ -151,9 +136,9 @@
 	append(event, pool1);
 }
 
-void AppenderSkeleton::setErrorHandler(const spi::ErrorHandlerPtr& errorHandler1)
+void AppenderSkeleton::setErrorHandler(const spi::ErrorHandlerPtr errorHandler1)
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
 	if (errorHandler1 == 0)
 	{
@@ -169,7 +154,7 @@
 
 void AppenderSkeleton::setThreshold(const LevelPtr& threshold1)
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 	this->threshold = threshold1;
 }
 
diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp
index ccb7241..13dfd17 100644
--- a/src/main/cpp/aprinitializer.cpp
+++ b/src/main/cpp/aprinitializer.cpp
@@ -25,7 +25,6 @@
 #include <log4cxx/helpers/threadspecificdata.h>
 #include <apr_thread_mutex.h>
 #include <apr_thread_proc.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/filewatchdog.h>
 
 using namespace log4cxx::helpers;
@@ -42,7 +41,7 @@
 }
 }
 
-APRInitializer::APRInitializer() : p(0), mutex(0), startTime(0), tlsKey(0)
+APRInitializer::APRInitializer() : p(0), startTime(0), tlsKey(0)
 {
 	apr_initialize();
 	apr_pool_create(&p, NULL);
@@ -50,8 +49,7 @@
 	startTime = apr_time_now();
 #if APR_HAS_THREADS
 	apr_status_t stat = apr_threadkey_private_create(&tlsKey, tlsDestruct, p);
-	assert(stat == APR_SUCCESS);
-	stat = apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_NESTED, p);
+    assert(stat == APR_SUCCESS);
 	assert(stat == APR_SUCCESS);
 #endif
 }
@@ -60,7 +58,7 @@
 {
 	{
 #if APR_HAS_THREADS
-		synchronized sync(mutex);
+		log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 		apr_threadkey_private_delete(tlsKey);
 #endif
 
@@ -105,7 +103,7 @@
 {
 	APRInitializer& instance(getInstance());
 #if APR_HAS_THREADS
-	synchronized sync(instance.mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(instance.mutex);
 #endif
 	instance.watchdogs.push_back(watchdog);
 }
@@ -114,7 +112,7 @@
 {
 	APRInitializer& instance(getInstance());
 #if APR_HAS_THREADS
-	synchronized sync(instance.mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(instance.mutex);
 #endif
 
 	for (std::list<FileWatchdog*>::iterator iter = instance.watchdogs.begin();
diff --git a/src/main/cpp/asyncappender.cpp b/src/main/cpp/asyncappender.cpp
index 20b80b7..6a83860 100644
--- a/src/main/cpp/asyncappender.cpp
+++ b/src/main/cpp/asyncappender.cpp
@@ -27,8 +27,6 @@
 #include <apr_thread_proc.h>
 #include <apr_thread_mutex.h>
 #include <apr_thread_cond.h>
-#include <log4cxx/helpers/condition.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/stringhelper.h>
 #include <apr_atomic.h>
 #include <log4cxx/helpers/optionconverter.h>
@@ -44,10 +42,7 @@
 
 AsyncAppender::AsyncAppender()
 	: AppenderSkeleton(),
-	  buffer(),
-	  bufferMutex(pool),
-	  bufferNotFull(pool),
-	  bufferNotEmpty(pool),
+      buffer(),
 	  discardMap(new DiscardMap()),
 	  bufferSize(DEFAULT_BUFFER_SIZE),
 	  appenders(new AppenderAttachableImpl(pool)),
@@ -55,9 +50,7 @@
 	  locationInfo(false),
 	  blocking(true)
 {
-#if APR_HAS_THREADS
-	dispatcher.run(dispatch, this);
-#endif
+	dispatcher = log4cxx::thread( &AsyncAppender::dispatch, this );
 }
 
 AsyncAppender::~AsyncAppender()
@@ -66,19 +59,9 @@
 	delete discardMap;
 }
 
-void AsyncAppender::addRef() const
+void AsyncAppender::addAppender(const AppenderPtr newAppender)
 {
-	ObjectImpl::addRef();
-}
-
-void AsyncAppender::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
-void AsyncAppender::addAppender(const AppenderPtr& newAppender)
-{
-	synchronized sync(appenders->getMutex());
+	log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
 	appenders->addAppender(newAppender);
 }
 
@@ -109,25 +92,23 @@
 
 void AsyncAppender::doAppend(const spi::LoggingEventPtr& event, Pool& pool1)
 {
-	LOCK_R sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
 	doAppendImpl(event, pool1);
 }
 
 void AsyncAppender::append(const spi::LoggingEventPtr& event, Pool& p)
 {
-#if APR_HAS_THREADS
-
 	//
 	//   if dispatcher has died then
 	//      append subsequent events synchronously
 	//
-	if (!dispatcher.isAlive() || bufferSize <= 0)
+    if (!dispatcher.joinable() || bufferSize <= 0)
 	{
-		synchronized sync(appenders->getMutex());
+		log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
 		appenders->appendLoopOnAppenders(event, p);
 		return;
-	}
+    }
 
 	// Set the NDC and thread name for the calling thread as these
 	// LoggingEvent fields were not set at event creation time.
@@ -138,8 +119,8 @@
 	event->getMDCCopy();
 
 
-	{
-		synchronized sync(bufferMutex);
+    {
+		log4cxx::unique_lock<log4cxx::mutex> lock(bufferMutex);
 
 		while (true)
 		{
@@ -151,7 +132,7 @@
 
 				if (previousSize == 0)
 				{
-					bufferNotEmpty.signalAll();
+                    bufferNotEmpty.notify_all();
 				}
 
 				break;
@@ -167,12 +148,12 @@
 			bool discard = true;
 
 			if (blocking
-				&& !Thread::interrupted()
-				&& !dispatcher.isCurrentThread())
+                //&& !Thread::interrupted()
+                && (dispatcher.get_id() != std::this_thread::get_id()) )
 			{
 				try
 				{
-					bufferNotFull.await(bufferMutex);
+                    bufferNotFull.wait(lock);
 					discard = false;
 				}
 				catch (InterruptedException&)
@@ -181,7 +162,7 @@
 					//  reset interrupt status so
 					//    calling code can see interrupt on
 					//    their next wait or sleep.
-					Thread::currentThreadInterrupt();
+                    //Thread::currentThreadInterrupt();
 				}
 			}
 
@@ -208,38 +189,24 @@
 			}
 		}
 	}
-#else
-	synchronized sync(appenders->getMutex());
-	appenders->appendLoopOnAppenders(event, p);
-#endif
 }
 
 
 void AsyncAppender::close()
 {
 	{
-		synchronized sync(bufferMutex);
+		log4cxx::unique_lock<log4cxx::mutex> lock(bufferMutex);
 		closed = true;
-		bufferNotEmpty.signalAll();
-		bufferNotFull.signalAll();
+        bufferNotEmpty.notify_all();
+        bufferNotFull.notify_all();
 	}
 
-#if APR_HAS_THREADS
-
-	try
-	{
-		dispatcher.join();
-	}
-	catch (InterruptedException& e)
-	{
-		Thread::currentThreadInterrupt();
-		LogLog::error(LOG4CXX_STR("Got an InterruptedException while waiting for the dispatcher to finish,"), e);
-	}
-
-#endif
+    if( dispatcher.joinable() ){
+        dispatcher.join();
+    }
 
 	{
-		synchronized sync(appenders->getMutex());
+		log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
 		AppenderList appenderList = appenders->getAllAppenders();
 
 		for (AppenderList::iterator iter = appenderList.begin();
@@ -253,19 +220,19 @@
 
 AppenderList AsyncAppender::getAllAppenders() const
 {
-	synchronized sync(appenders->getMutex());
+	log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
 	return appenders->getAllAppenders();
 }
 
 AppenderPtr AsyncAppender::getAppender(const LogString& n) const
 {
-	synchronized sync(appenders->getMutex());
+	log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
 	return appenders->getAppender(n);
 }
 
-bool AsyncAppender::isAttached(const AppenderPtr& appender) const
+bool AsyncAppender::isAttached(const AppenderPtr appender) const
 {
-	synchronized sync(appenders->getMutex());
+	log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
 	return appenders->isAttached(appender);
 }
 
@@ -276,19 +243,19 @@
 
 void AsyncAppender::removeAllAppenders()
 {
-	synchronized sync(appenders->getMutex());
+	log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
 	appenders->removeAllAppenders();
 }
 
-void AsyncAppender::removeAppender(const AppenderPtr& appender)
+void AsyncAppender::removeAppender(const AppenderPtr appender)
 {
-	synchronized sync(appenders->getMutex());
+	log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
 	appenders->removeAppender(appender);
 }
 
 void AsyncAppender::removeAppender(const LogString& n)
 {
-	synchronized sync(appenders->getMutex());
+	log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
 	appenders->removeAppender(n);
 }
 
@@ -310,9 +277,9 @@
 		throw IllegalArgumentException(LOG4CXX_STR("size argument must be non-negative"));
 	}
 
-	synchronized sync(bufferMutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(bufferMutex);
 	bufferSize = (size < 1) ? 1 : size;
-	bufferNotFull.signalAll();
+    bufferNotFull.notify_all();
 }
 
 int AsyncAppender::getBufferSize() const
@@ -322,9 +289,9 @@
 
 void AsyncAppender::setBlocking(bool value)
 {
-	synchronized sync(bufferMutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(bufferMutex);
 	blocking = value;
-	bufferNotFull.signalAll();
+    bufferNotFull.notify_all();
 }
 
 bool AsyncAppender::getBlocking() const
@@ -365,11 +332,11 @@
 	StringHelper::toString(count, p, msg);
 	msg.append(LOG4CXX_STR(" messages due to a full event buffer including: "));
 	msg.append(maxEvent->getMessage());
-	return new LoggingEvent(
+    return LoggingEventPtr( new LoggingEvent(
 			maxEvent->getLoggerName(),
 			maxEvent->getLevel(),
 			msg,
-			LocationInfo::getLocationUnavailable());
+            LocationInfo::getLocationUnavailable()) );
 }
 
 ::log4cxx::spi::LoggingEventPtr
@@ -380,17 +347,15 @@
 	StringHelper::toString(discardedCount, p, msg);
 	msg.append(LOG4CXX_STR(" messages due to a full event buffer"));
 
-	return new LoggingEvent(
+    return LoggingEventPtr( new LoggingEvent(
 			LOG4CXX_STR(""),
 			log4cxx::Level::getError(),
 			msg,
-			LocationInfo::getLocationUnavailable());
+            LocationInfo::getLocationUnavailable()) );
 }
 
-#if APR_HAS_THREADS
-void* LOG4CXX_THREAD_FUNC AsyncAppender::dispatch(apr_thread_t* /*thread*/, void* data)
+void AsyncAppender::dispatch()
 {
-	AsyncAppender* pThis = (AsyncAppender*) data;
 	bool isActive = true;
 
 	try
@@ -402,54 +367,52 @@
 			//
 			Pool p;
 			LoggingEventList events;
-			{
-				synchronized sync(pThis->bufferMutex);
-				size_t bufferSize = pThis->buffer.size();
-				isActive = !pThis->closed;
+            {
+				log4cxx::unique_lock<log4cxx::mutex> lock(bufferMutex);
+                size_t bufferSize = buffer.size();
+                isActive = !closed;
 
 				while ((bufferSize == 0) && isActive)
 				{
-					pThis->bufferNotEmpty.await(pThis->bufferMutex);
-					bufferSize = pThis->buffer.size();
-					isActive = !pThis->closed;
+                    bufferNotEmpty.wait(lock);
+                    bufferSize = buffer.size();
+                    isActive = !closed;
 				}
 
-				for (LoggingEventList::iterator eventIter = pThis->buffer.begin();
-					eventIter != pThis->buffer.end();
+                for (LoggingEventList::iterator eventIter = buffer.begin();
+                    eventIter != buffer.end();
 					eventIter++)
 				{
 					events.push_back(*eventIter);
 				}
 
-				for (DiscardMap::iterator discardIter = pThis->discardMap->begin();
-					discardIter != pThis->discardMap->end();
+                for (DiscardMap::iterator discardIter = discardMap->begin();
+                    discardIter != discardMap->end();
 					discardIter++)
 				{
 					events.push_back(discardIter->second.createEvent(p));
 				}
 
-				pThis->buffer.clear();
-				pThis->discardMap->clear();
-				pThis->bufferNotFull.signalAll();
+                buffer.clear();
+                discardMap->clear();
+                bufferNotFull.notify_all();
 			}
 
 			for (LoggingEventList::iterator iter = events.begin();
 				iter != events.end();
 				iter++)
 			{
-				synchronized sync(pThis->appenders->getMutex());
-				pThis->appenders->appendLoopOnAppenders(*iter, p);
+				log4cxx::unique_lock<log4cxx::mutex> lock(appenders->getMutex());
+                appenders->appendLoopOnAppenders(*iter, p);
 			}
 		}
 	}
 	catch (InterruptedException&)
 	{
-		Thread::currentThreadInterrupt();
+        //Thread::currentThreadInterrupt();
 	}
 	catch (...)
 	{
-	}
+    }
 
-	return 0;
 }
-#endif
diff --git a/src/main/cpp/bytearrayinputstream.cpp b/src/main/cpp/bytearrayinputstream.cpp
index 566cffa..f710a2a 100644
--- a/src/main/cpp/bytearrayinputstream.cpp
+++ b/src/main/cpp/bytearrayinputstream.cpp
@@ -18,9 +18,9 @@
 #include <log4cxx/helpers/bytearrayinputstream.h>
 #include <log4cxx/helpers/exception.h>
 #include <log4cxx/helpers/bytebuffer.h>
-#include <apr_file_io.h>
 #include <log4cxx/helpers/transcoder.h>
 #include <algorithm>
+#include <cstring>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -54,7 +54,7 @@
 	else
 	{
 		size_t bytesCopied = min(dst.remaining(), buf.size() - pos);
-		memcpy(dst.current(), &buf[pos], bytesCopied);
+        std::memcpy(dst.current(), &buf[pos], bytesCopied);
 		pos += bytesCopied;
 		dst.position(dst.position() + bytesCopied);
 		return (int)bytesCopied;
diff --git a/src/main/cpp/bytebuffer.cpp b/src/main/cpp/bytebuffer.cpp
index fce185f..c82e3fc 100644
--- a/src/main/cpp/bytebuffer.cpp
+++ b/src/main/cpp/bytebuffer.cpp
@@ -17,7 +17,6 @@
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/bytebuffer.h>
 #include <log4cxx/helpers/exception.h>
-#include <apr_pools.h>
 #include <log4cxx/helpers/pool.h>
 
 using namespace log4cxx;
diff --git a/src/main/cpp/charsetdecoder.cpp b/src/main/cpp/charsetdecoder.cpp
index 395ee75..ffd3759 100644
--- a/src/main/cpp/charsetdecoder.cpp
+++ b/src/main/cpp/charsetdecoder.cpp
@@ -18,8 +18,6 @@
 #include <log4cxx/helpers/charsetdecoder.h>
 #include <log4cxx/helpers/bytebuffer.h>
 #include <log4cxx/helpers/exception.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/pool.h>
 #include <apr_xlate.h>
 #if !defined(LOG4CXX)
@@ -55,7 +53,7 @@
 		 *  Creates a new instance.
 		 *  @param frompage name of source encoding.
 		 */
-		APRCharsetDecoder(const LogString& frompage) : pool(), mutex(pool)
+        APRCharsetDecoder(const LogString& frompage) : pool()
 		{
 #if LOG4CXX_LOGCHAR_IS_WCHAR
 			const char* topage = "WCHAR_T";
@@ -97,7 +95,7 @@
 			{
 				size_t outbytes_left = initial_outbytes_left;
 				{
-					synchronized sync(mutex);
+					log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 					stat = apr_xlate_conv_buffer((apr_xlate_t*) convset,
 							NULL, NULL, (char*) buf, &outbytes_left);
 				}
@@ -112,7 +110,7 @@
 					size_t pos = in.position();
 					apr_size_t outbytes_left = initial_outbytes_left;
 					{
-						synchronized sync(mutex);
+						log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 						stat = apr_xlate_conv_buffer((apr_xlate_t*) convset,
 								in.data() + pos,
 								&inbytes_left,
@@ -131,7 +129,7 @@
 		APRCharsetDecoder(const APRCharsetDecoder&);
 		APRCharsetDecoder& operator=(const APRCharsetDecoder&);
 		log4cxx::helpers::Pool pool;
-		Mutex mutex;
+		log4cxx::mutex mutex;
 		apr_xlate_t* convset;
 };
 
@@ -425,7 +423,7 @@
 class LocaleCharsetDecoder : public CharsetDecoder
 {
 	public:
-		LocaleCharsetDecoder() : pool(), mutex(pool), decoder(), encoding()
+        LocaleCharsetDecoder() : pool(), decoder(), encoding()
 		{
 		}
 		virtual ~LocaleCharsetDecoder()
@@ -450,15 +448,15 @@
 			{
 				Pool subpool;
 				const char* enc = apr_os_locale_encoding(subpool.getAPRPool());
-				{
-					synchronized sync(mutex);
+                {
+					log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 					if (enc == 0)
 					{
 						if (decoder == 0)
 						{
 							encoding = "C";
-							decoder = new USASCIICharsetDecoder();
+                            decoder.reset( new USASCIICharsetDecoder() );
 						}
 					}
 					else if (encoding != enc)
@@ -473,7 +471,7 @@
 						}
 						catch (IllegalArgumentException&)
 						{
-							decoder = new USASCIICharsetDecoder();
+                            decoder.reset( new USASCIICharsetDecoder() );
 						}
 					}
 				}
@@ -484,7 +482,7 @@
 		}
 	private:
 		Pool pool;
-		Mutex mutex;
+		log4cxx::mutex mutex;
 		CharsetDecoderPtr decoder;
 		std::string encoding;
 };
@@ -531,7 +529,7 @@
 	//
 	if (decoder == 0)
 	{
-		return createDefaultDecoder();
+        return CharsetDecoderPtr( createDefaultDecoder() );
 	}
 
 	return decoder;
@@ -548,7 +546,7 @@
 	//
 	if (decoder == 0)
 	{
-		return new UTF8CharsetDecoder();
+        return CharsetDecoderPtr( new UTF8CharsetDecoder() );
 	}
 
 	return decoder;
@@ -556,7 +554,7 @@
 
 CharsetDecoderPtr CharsetDecoder::getISOLatinDecoder()
 {
-	return new ISOLatinCharsetDecoder();
+    return CharsetDecoderPtr( new ISOLatinCharsetDecoder() );
 }
 
 
@@ -565,7 +563,7 @@
 	if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-8"), LOG4CXX_STR("utf-8")) ||
 		StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF8"), LOG4CXX_STR("utf8")))
 	{
-		return new UTF8CharsetDecoder();
+        return CharsetDecoderPtr( new UTF8CharsetDecoder() );
 	}
 	else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("C"), LOG4CXX_STR("c")) ||
 		charset == LOG4CXX_STR("646") ||
@@ -573,16 +571,16 @@
 		StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO646-US"), LOG4CXX_STR("iso646-US")) ||
 		StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ANSI_X3.4-1968"), LOG4CXX_STR("ansi_x3.4-1968")))
 	{
-		return new USASCIICharsetDecoder();
+        return CharsetDecoderPtr( new USASCIICharsetDecoder() );
 	}
 	else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-8859-1"), LOG4CXX_STR("iso-8859-1")) ||
 		StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-LATIN-1"), LOG4CXX_STR("iso-latin-1")))
 	{
-		return new ISOLatinCharsetDecoder();
+        return CharsetDecoderPtr( new ISOLatinCharsetDecoder() );
 	}
 
 #if APR_HAS_XLATE
-	return new APRCharsetDecoder(charset);
+    return CharsetDecoderPtr( new APRCharsetDecoder(charset) );
 #else
 	throw IllegalArgumentException(charset);
 #endif
diff --git a/src/main/cpp/charsetencoder.cpp b/src/main/cpp/charsetencoder.cpp
index 1d4fd75..12768ce 100644
--- a/src/main/cpp/charsetencoder.cpp
+++ b/src/main/cpp/charsetencoder.cpp
@@ -28,8 +28,6 @@
 
 #include <log4cxx/private/log4cxx_private.h>
 #include <apr_portable.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/synchronized.h>
 
 #ifdef LOG4CXX_HAS_WCSTOMBS
 	#include <stdlib.h>
@@ -53,7 +51,7 @@
 class APRCharsetEncoder : public CharsetEncoder
 {
 	public:
-		APRCharsetEncoder(const LogString& topage) : pool(), mutex(pool)
+        APRCharsetEncoder(const LogString& topage) : pool()
 		{
 #if LOG4CXX_LOGCHAR_IS_WCHAR
 			const char* frompage = "WCHAR_T";
@@ -91,7 +89,7 @@
 
 			if (iter == in.end())
 			{
-				synchronized sync(mutex);
+				log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 				stat = apr_xlate_conv_buffer(convset, NULL, NULL,
 						out.data() + position, &outbytes_left);
 			}
@@ -102,7 +100,7 @@
 					(in.size() - inOffset) * sizeof(LogString::value_type);
 				apr_size_t initial_inbytes_left = inbytes_left;
 				{
-					synchronized sync(mutex);
+					log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 					stat = apr_xlate_conv_buffer(convset,
 							(const char*) (in.data() + inOffset),
 							&inbytes_left,
@@ -120,7 +118,7 @@
 		APRCharsetEncoder(const APRCharsetEncoder&);
 		APRCharsetEncoder& operator=(const APRCharsetEncoder&);
 		Pool pool;
-		Mutex mutex;
+		log4cxx::mutex mutex;
 		apr_xlate_t* convset;
 };
 #endif
@@ -452,7 +450,7 @@
 class LocaleCharsetEncoder : public CharsetEncoder
 {
 	public:
-		LocaleCharsetEncoder() : pool(), mutex(pool), encoder(), encoding()
+        LocaleCharsetEncoder() : pool(), encoder(), encoding()
 		{
 		}
 		virtual ~LocaleCharsetEncoder()
@@ -481,14 +479,14 @@
 				Pool subpool;
 				const char* enc = apr_os_locale_encoding(subpool.getAPRPool());
 				{
-					synchronized sync(mutex);
+					log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 					if (enc == 0)
 					{
 						if (encoder == 0)
 						{
 							encoding = "C";
-							encoder = new USASCIICharsetEncoder();
+                            encoder.reset( new USASCIICharsetEncoder() );
 						}
 					}
 					else if (encoding != enc)
@@ -503,7 +501,7 @@
 						}
 						catch (IllegalArgumentException&)
 						{
-							encoder = new USASCIICharsetEncoder();
+                            encoder.reset( new USASCIICharsetEncoder() );
 						}
 					}
 				}
@@ -517,7 +515,7 @@
 		LocaleCharsetEncoder(const LocaleCharsetEncoder&);
 		LocaleCharsetEncoder& operator=(const LocaleCharsetEncoder&);
 		Pool pool;
-		Mutex mutex;
+		log4cxx::mutex mutex;
 		CharsetEncoderPtr encoder;
 		std::string encoding;
 };
@@ -548,7 +546,7 @@
 	//
 	if (encoder == 0)
 	{
-		return createDefaultEncoder();
+        return CharsetEncoderPtr( createDefaultEncoder() );
 	}
 
 	return encoder;
@@ -572,7 +570,7 @@
 
 CharsetEncoderPtr CharsetEncoder::getUTF8Encoder()
 {
-	return new UTF8CharsetEncoder();
+    return CharsetEncoderPtr( new UTF8CharsetEncoder() );
 }
 
 
@@ -581,7 +579,7 @@
 {
 	if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-8"), LOG4CXX_STR("utf-8")))
 	{
-		return new UTF8CharsetEncoder();
+        return CharsetEncoderPtr( new UTF8CharsetEncoder() );
 	}
 	else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("C"), LOG4CXX_STR("c")) ||
 		charset == LOG4CXX_STR("646") ||
@@ -589,25 +587,25 @@
 		StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO646-US"), LOG4CXX_STR("iso646-US")) ||
 		StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ANSI_X3.4-1968"), LOG4CXX_STR("ansi_x3.4-1968")))
 	{
-		return new USASCIICharsetEncoder();
+        return CharsetEncoderPtr( new USASCIICharsetEncoder() );
 	}
 	else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-8859-1"), LOG4CXX_STR("iso-8859-1")) ||
 		StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-LATIN-1"), LOG4CXX_STR("iso-latin-1")))
 	{
-		return new ISOLatinCharsetEncoder();
+        return CharsetEncoderPtr( new ISOLatinCharsetEncoder() );
 	}
 	else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-16BE"), LOG4CXX_STR("utf-16be"))
 		|| StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-16"), LOG4CXX_STR("utf-16")))
 	{
-		return new UTF16BECharsetEncoder();
+        return CharsetEncoderPtr( new UTF16BECharsetEncoder() );
 	}
 	else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-16LE"), LOG4CXX_STR("utf-16le")))
 	{
-		return new UTF16LECharsetEncoder();
+        return CharsetEncoderPtr( new UTF16LECharsetEncoder() );
 	}
 
 #if APR_HAS_XLATE
-	return new APRCharsetEncoder(charset);
+    return CharsetEncoderPtr( new APRCharsetEncoder(charset) );
 #else
 	throw IllegalArgumentException(charset);
 #endif
diff --git a/src/main/cpp/class.cpp b/src/main/cpp/class.cpp
index 860ae50..307a7cb 100644
--- a/src/main/cpp/class.cpp
+++ b/src/main/cpp/class.cpp
@@ -94,7 +94,7 @@
 	return getName();
 }
 
-ObjectPtr Class::newInstance() const
+Object* Class::newInstance() const
 {
 	throw InstantiationException(LOG4CXX_STR("Cannot create new instances of Class."));
 #if LOG4CXX_RETURN_AFTER_THROW
diff --git a/src/main/cpp/classnamepatternconverter.cpp b/src/main/cpp/classnamepatternconverter.cpp
index e39027a..fbffe9d 100644
--- a/src/main/cpp/classnamepatternconverter.cpp
+++ b/src/main/cpp/classnamepatternconverter.cpp
@@ -47,7 +47,7 @@
 		return def;
 	}
 
-	return new ClassNamePatternConverter(options);
+    return PatternConverterPtr( new ClassNamePatternConverter(options) );
 }
 
 void ClassNamePatternConverter::format(
diff --git a/src/main/cpp/condition.cpp b/src/main/cpp/condition.cpp
deleted file mode 100644
index 9970f27..0000000
--- a/src/main/cpp/condition.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/condition.h>
-#include <log4cxx/helpers/exception.h>
-
-#include <apr_thread_cond.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <log4cxx/helpers/pool.h>
-#include <log4cxx/helpers/thread.h>
-
-using namespace log4cxx::helpers;
-using namespace log4cxx;
-
-
-Condition::Condition(Pool& p)
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_cond_create(&condition, p.getAPRPool());
-
-	if (stat != APR_SUCCESS)
-	{
-		throw RuntimeException(stat);
-	}
-
-#endif
-}
-
-Condition::~Condition()
-{
-#if APR_HAS_THREADS
-	apr_thread_cond_destroy(condition);
-#endif
-}
-
-log4cxx_status_t Condition::signalAll()
-{
-#if APR_HAS_THREADS
-	return apr_thread_cond_broadcast(condition);
-#else
-	return APR_SUCCESS;
-#endif
-}
-
-void Condition::await(Mutex& mutex)
-{
-#if APR_HAS_THREADS
-
-	if (Thread::interrupted())
-	{
-		throw InterruptedException();
-	}
-
-	apr_status_t stat = apr_thread_cond_wait(
-			condition,
-			mutex.getAPRMutex());
-
-	if (stat != APR_SUCCESS)
-	{
-		throw InterruptedException(stat);
-	}
-
-#endif
-}
-
diff --git a/src/main/cpp/dailyrollingfileappender.cpp b/src/main/cpp/dailyrollingfileappender.cpp
index 9d58fcb..5b424aa 100644
--- a/src/main/cpp/dailyrollingfileappender.cpp
+++ b/src/main/cpp/dailyrollingfileappender.cpp
@@ -60,7 +60,7 @@
 
 void DailyRollingFileAppender::activateOptions(log4cxx::helpers::Pool& p)
 {
-	TimeBasedRollingPolicyPtr policy = new TimeBasedRollingPolicy();
+    TimeBasedRollingPolicyPtr policy = TimeBasedRollingPolicyPtr( new TimeBasedRollingPolicy() );
 	LogString pattern(getFile());
 	bool inLiteral = false;
 	bool inPattern = false;
diff --git a/src/main/cpp/datelayout.cpp b/src/main/cpp/datelayout.cpp
index e8366bb..290374b 100644
--- a/src/main/cpp/datelayout.cpp
+++ b/src/main/cpp/datelayout.cpp
@@ -72,30 +72,30 @@
 		else if (StringHelper::equalsIgnoreCase(dateFormatOption,
 				LOG4CXX_STR("RELATIVE"), LOG4CXX_STR("relative")))
 		{
-			dateFormat =  new RelativeTimeDateFormat();
+            dateFormat =  DateFormatPtr(new RelativeTimeDateFormat());
 			dateFormatOption = LOG4CXX_STR("RELATIVE");
 		}
 		else if (StringHelper::equalsIgnoreCase(dateFormatOption,
 				LOG4CXX_STR("ABSOLUTE"),  LOG4CXX_STR("absolute")))
 		{
-			dateFormat =  new AbsoluteTimeDateFormat();
+            dateFormat =  DateFormatPtr(new AbsoluteTimeDateFormat());
 			dateFormatOption = LOG4CXX_STR("ABSOLUTE");
 		}
 		else if (StringHelper::equalsIgnoreCase(dateFormatOption,
 				LOG4CXX_STR("DATE"), LOG4CXX_STR("date")))
 		{
-			dateFormat =  new DateTimeDateFormat();
+            dateFormat =  DateFormatPtr(new DateTimeDateFormat());
 			dateFormatOption = LOG4CXX_STR("DATE");
 		}
 		else if (StringHelper::equalsIgnoreCase(dateFormatOption,
 				LOG4CXX_STR("ISO8601"), LOG4CXX_STR("iso8601")))
 		{
-			dateFormat =  new ISO8601DateFormat();
+            dateFormat =  DateFormatPtr(new ISO8601DateFormat());
 			dateFormatOption = LOG4CXX_STR("iso8601");
 		}
 		else
 		{
-			dateFormat = new SimpleDateFormat(dateFormatOption);
+            dateFormat = DateFormatPtr(new SimpleDateFormat(dateFormatOption));
 		}
 	}
 
diff --git a/src/main/cpp/datepatternconverter.cpp b/src/main/cpp/datepatternconverter.cpp
index 25b51ea..122a5d6 100644
--- a/src/main/cpp/datepatternconverter.cpp
+++ b/src/main/cpp/datepatternconverter.cpp
@@ -53,7 +53,7 @@
 
 	if (options.size() == 0)
 	{
-		df = new ISO8601DateFormat();
+        df = DateFormatPtr(new ISO8601DateFormat());
 	}
 	else
 	{
@@ -63,17 +63,17 @@
 			StringHelper::equalsIgnoreCase(dateFormatStr,
 				LOG4CXX_STR("ISO8601"), LOG4CXX_STR("iso8601")))
 		{
-			df = new ISO8601DateFormat();
+            df = DateFormatPtr(new ISO8601DateFormat());
 		}
 		else if (StringHelper::equalsIgnoreCase(dateFormatStr,
 				LOG4CXX_STR("ABSOLUTE"), LOG4CXX_STR("absolute")))
 		{
-			df = new AbsoluteTimeDateFormat();
+            df = DateFormatPtr(new AbsoluteTimeDateFormat());
 		}
 		else if (StringHelper::equalsIgnoreCase(dateFormatStr,
 				LOG4CXX_STR("DATE"), LOG4CXX_STR("date")))
 		{
-			df = new DateTimeDateFormat();
+            df = DateFormatPtr(new DateTimeDateFormat());
 		}
 		else
 		{
@@ -81,13 +81,13 @@
 			{
 				try
 				{
-					df = new SimpleDateFormat(dateFormatStr);
+                    df = DateFormatPtr(new SimpleDateFormat(dateFormatStr));
 					maximumCacheValidity =
 						CachedDateFormat::getMaximumCacheValidity(dateFormatStr);
 				}
 				catch (IllegalArgumentException& e)
 				{
-					df = new ISO8601DateFormat();
+                    df = DateFormatPtr(new ISO8601DateFormat());
 					LogLog::warn(((LogString)
 							LOG4CXX_STR("Could not instantiate SimpleDateFormat with pattern "))
 						+ dateFormatStr, e);
@@ -95,7 +95,7 @@
 			}
 			else
 			{
-				df = new StrftimeDateFormat(dateFormatStr);
+                df = DateFormatPtr(new StrftimeDateFormat(dateFormatStr));
 			}
 		}
 
@@ -112,7 +112,7 @@
 
 	if (maximumCacheValidity > 0)
 	{
-		df = new CachedDateFormat(df, maximumCacheValidity);
+        df = DateFormatPtr(new CachedDateFormat(df, maximumCacheValidity));
 	}
 
 	return df;
@@ -121,7 +121,7 @@
 PatternConverterPtr DatePatternConverter::newInstance(
 	const std::vector<LogString>& options)
 {
-	return new DatePatternConverter(options);
+    return PatternConverterPtr(new DatePatternConverter(options));
 }
 
 void DatePatternConverter::format(
@@ -140,7 +140,7 @@
 	LogString& toAppendTo,
 	Pool& p) const
 {
-	DatePtr date(obj);
+    DatePtr date = log4cxx::cast<Date>(obj);
 
 	if (date != NULL)
 	{
@@ -148,7 +148,7 @@
 	}
 	else
 	{
-		LoggingEventPtr event(obj);
+        LoggingEventPtr event = log4cxx::cast<LoggingEvent>(obj);
 
 		if (event != NULL)
 		{
diff --git a/src/main/cpp/defaultconfigurator.cpp b/src/main/cpp/defaultconfigurator.cpp
index b304084..4b64298 100644
--- a/src/main/cpp/defaultconfigurator.cpp
+++ b/src/main/cpp/defaultconfigurator.cpp
@@ -27,7 +27,7 @@
 using namespace log4cxx::spi;
 using namespace log4cxx::helpers;
 
-void DefaultConfigurator::configure(LoggerRepository* repository)
+void DefaultConfigurator::configure(LoggerRepositoryPtr repository)
 {
 	repository->setConfigured(true);
 	const LogString configuratorClassName(getConfiguratorClass());
diff --git a/src/main/cpp/defaultloggerfactory.cpp b/src/main/cpp/defaultloggerfactory.cpp
index 8f81a77..e400d26 100644
--- a/src/main/cpp/defaultloggerfactory.cpp
+++ b/src/main/cpp/defaultloggerfactory.cpp
@@ -26,5 +26,5 @@
 	log4cxx::helpers::Pool& pool,
 	const LogString& name) const
 {
-	return new Logger(pool, name);
+    return LoggerPtr(new Logger(pool, name));
 }
diff --git a/src/main/cpp/defaultrepositoryselector.cpp b/src/main/cpp/defaultrepositoryselector.cpp
index 6313f29..238e0ac 100644
--- a/src/main/cpp/defaultrepositoryselector.cpp
+++ b/src/main/cpp/defaultrepositoryselector.cpp
@@ -22,23 +22,12 @@
 using namespace log4cxx::helpers;
 
 
-DefaultRepositorySelector::DefaultRepositorySelector(const LoggerRepositoryPtr& repository1)
+DefaultRepositorySelector::DefaultRepositorySelector(const LoggerRepositoryPtr repository1)
 	: repository(repository1)
 {
 }
 
-void DefaultRepositorySelector::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-
-void DefaultRepositorySelector::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
-LoggerRepositoryPtr& DefaultRepositorySelector::getLoggerRepository()
+LoggerRepositoryPtr DefaultRepositorySelector::getLoggerRepository()
 {
 	return repository;
 }
diff --git a/src/main/cpp/domconfigurator.cpp b/src/main/cpp/domconfigurator.cpp
index c5770bf..85d23ee 100644
--- a/src/main/cpp/domconfigurator.cpp
+++ b/src/main/cpp/domconfigurator.cpp
@@ -32,7 +32,6 @@
 #include <log4cxx/spi/loggerfactory.h>
 #include <log4cxx/defaultloggerfactory.h>
 #include <log4cxx/helpers/filewatchdog.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/spi/loggerrepository.h>
 #include <log4cxx/spi/loggingevent.h>
 #include <log4cxx/helpers/pool.h>
@@ -64,20 +63,20 @@
 {
 class XMLWatchdog  : public FileWatchdog
 {
-	public:
-		XMLWatchdog(const File& filename) : FileWatchdog(filename)
-		{
-		}
+public:
+    XMLWatchdog(const File& filename) : FileWatchdog(filename)
+    {
+    }
 
-		/**
-		Call DOMConfigurator#doConfigure with the
-		<code>filename</code> to reconfigure log4cxx.
-		*/
-		void doOnChange()
-		{
-			DOMConfigurator().doConfigure(file,
-				LogManager::getLoggerRepository());
-		}
+    /**
+    Call DOMConfigurator#doConfigure with the
+    <code>filename</code> to reconfigure log4cxx.
+    */
+    void doOnChange()
+    {
+        DOMConfigurator().doConfigure(file,
+                                      LogManager::getLoggerRepository());
+    }
 };
 }
 }
@@ -116,328 +115,322 @@
 #define INTERNAL_DEBUG_ATTR "debug"
 
 DOMConfigurator::DOMConfigurator()
-	: props(), repository()
+    : props(), repository()
 {
 }
 
-void DOMConfigurator::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void DOMConfigurator::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
 /**
 Used internally to parse appenders by IDREF name.
 */
 AppenderPtr DOMConfigurator::findAppenderByName(log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* element,
-	apr_xml_doc* doc,
-	const LogString& appenderName,
-	AppenderMap& appenders)
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* element,
+        apr_xml_doc* doc,
+        const LogString& appenderName,
+        AppenderMap& appenders)
 {
-	AppenderPtr appender;
-	std::string tagName(element->name);
+    AppenderPtr appender;
+    std::string tagName(element->name);
 
-	if (tagName == APPENDER_TAG)
-	{
-		if (appenderName == getAttribute(utf8Decoder, element, NAME_ATTR))
-		{
-			appender = parseAppender(p, utf8Decoder, element, doc, appenders);
-		}
-	}
+    if (tagName == APPENDER_TAG)
+    {
+        if (appenderName == getAttribute(utf8Decoder, element, NAME_ATTR))
+        {
+            appender = parseAppender(p, utf8Decoder, element, doc, appenders);
+        }
+    }
 
-	if (element->first_child && !appender)
-	{
-		appender = findAppenderByName(p, utf8Decoder, element->first_child, doc, appenderName, appenders);
-	}
+    if (element->first_child && !appender)
+    {
+        appender = findAppenderByName(p, utf8Decoder, element->first_child, doc, appenderName, appenders);
+    }
 
-	if (element->next && !appender)
-	{
-		appender = findAppenderByName(p, utf8Decoder, element->next, doc, appenderName, appenders);
-	}
+    if (element->next && !appender)
+    {
+        appender = findAppenderByName(p, utf8Decoder, element->next, doc, appenderName, appenders);
+    }
 
-	return appender;
+    return appender;
 }
 
 /**
  Used internally to parse appenders by IDREF element.
 */
 AppenderPtr DOMConfigurator::findAppenderByReference(
-	log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* appenderRef,
-	apr_xml_doc* doc,
-	AppenderMap& appenders)
+    log4cxx::helpers::Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* appenderRef,
+    apr_xml_doc* doc,
+    AppenderMap& appenders)
 {
-	LogString appenderName(subst(getAttribute(utf8Decoder, appenderRef, REF_ATTR)));
-	AppenderMap::const_iterator match = appenders.find(appenderName);
-	AppenderPtr appender;
+    LogString appenderName(subst(getAttribute(utf8Decoder, appenderRef, REF_ATTR)));
+    AppenderMap::const_iterator match = appenders.find(appenderName);
+    AppenderPtr appender;
 
-	if (match != appenders.end())
-	{
-		appender = match->second;
-	}
-	else if (doc)
-	{
-		appender = findAppenderByName(p, utf8Decoder, doc->root, doc, appenderName, appenders);
+    if (match != appenders.end())
+    {
+        appender = match->second;
+    }
+    else if (doc)
+    {
+        appender = findAppenderByName(p, utf8Decoder, doc->root, doc, appenderName, appenders);
 
-		if (appender)
-		{
-			appenders.insert(AppenderMap::value_type(appenderName, appender));
-		}
-	}
+        if (appender)
+        {
+            appenders.insert(AppenderMap::value_type(appenderName, appender));
+        }
+    }
 
-	if (!appender)
-	{
-		LogLog::error(LOG4CXX_STR("No appender named [") +
-			appenderName + LOG4CXX_STR("] could be found."));
-	}
+    if (!appender)
+    {
+        LogLog::error(LOG4CXX_STR("No appender named [") +
+                      appenderName + LOG4CXX_STR("] could be found."));
+    }
 
-	return appender;
+    return appender;
 }
 
 /**
 Used internally to parse an appender element.
 */
 AppenderPtr DOMConfigurator::parseAppender(Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* appenderElement,
-	apr_xml_doc* doc,
-	AppenderMap& appenders)
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* appenderElement,
+        apr_xml_doc* doc,
+        AppenderMap& appenders)
 {
 
-	LogString className(subst(getAttribute(utf8Decoder, appenderElement, CLASS_ATTR)));
-	LogLog::debug(LOG4CXX_STR("Class name: [") + className + LOG4CXX_STR("]"));
+    LogString className(subst(getAttribute(utf8Decoder, appenderElement, CLASS_ATTR)));
+    LogLog::debug(LOG4CXX_STR("Class name: [") + className + LOG4CXX_STR("]"));
 
-	try
-	{
-		ObjectPtr instance = Loader::loadClass(className).newInstance();
-		AppenderPtr appender = instance;
-		PropertySetter propSetter(appender);
+    try
+    {
+        ObjectPtr instance = ObjectPtr(Loader::loadClass(className).newInstance());
+        AppenderPtr appender = log4cxx::cast<Appender>(instance);
+        PropertySetter propSetter(appender);
 
-		appender->setName(subst(getAttribute(utf8Decoder, appenderElement, NAME_ATTR)));
+        appender->setName(subst(getAttribute(utf8Decoder, appenderElement, NAME_ATTR)));
 
-		for (apr_xml_elem* currentElement = appenderElement->first_child;
-			currentElement;
-			currentElement = currentElement->next)
-		{
+        for (apr_xml_elem* currentElement = appenderElement->first_child;
+                currentElement;
+                currentElement = currentElement->next)
+        {
 
-			std::string tagName(currentElement->name);
+            std::string tagName(currentElement->name);
 
-			// Parse appender parameters
-			if (tagName == PARAM_TAG)
-			{
-				setParameter(p, utf8Decoder, currentElement, propSetter);
-			}
-			// Set appender layout
-			else if (tagName == LAYOUT_TAG)
-			{
-				appender->setLayout(parseLayout(p, utf8Decoder, currentElement));
-			}
-			// Add filters
-			else if (tagName == FILTER_TAG)
-			{
-				std::vector<log4cxx::spi::FilterPtr> filters;
-				parseFilters(p, utf8Decoder, currentElement, filters);
+            // Parse appender parameters
+            if (tagName == PARAM_TAG)
+            {
+                setParameter(p, utf8Decoder, currentElement, propSetter);
+            }
+            // Set appender layout
+            else if (tagName == LAYOUT_TAG)
+            {
+                appender->setLayout(parseLayout(p, utf8Decoder, currentElement));
+            }
+            // Add filters
+            else if (tagName == FILTER_TAG)
+            {
+                std::vector<log4cxx::spi::FilterPtr> filters;
+                parseFilters(p, utf8Decoder, currentElement, filters);
 
-				for (std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
-					iter != filters.end();
-					iter++)
-				{
-					appender->addFilter(*iter);
-				}
-			}
-			else if (tagName == ERROR_HANDLER_TAG)
-			{
-				parseErrorHandler(p, utf8Decoder, currentElement, appender, doc, appenders);
-			}
-			else if (tagName == ROLLING_POLICY_TAG)
-			{
-				RollingPolicyPtr rollPolicy(parseRollingPolicy(p, utf8Decoder, currentElement));
-				RollingFileAppenderPtr rfa(appender);
+                for (std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
+                        iter != filters.end();
+                        iter++)
+                {
+                    appender->addFilter(*iter);
+                }
+            }
+            else if (tagName == ERROR_HANDLER_TAG)
+            {
+                parseErrorHandler(p, utf8Decoder, currentElement, appender, doc, appenders);
+            }
+            else if (tagName == ROLLING_POLICY_TAG)
+            {
+                RollingPolicyPtr rollPolicy(parseRollingPolicy(p, utf8Decoder, currentElement));
+                RollingFileAppenderPtr rfa = log4cxx::cast<RollingFileAppender>(appender);
 
-				if (rfa != NULL)
-				{
-					rfa->setRollingPolicy(rollPolicy);
-				}
-			}
-			else if (tagName == TRIGGERING_POLICY_TAG)
-			{
-				ObjectPtr policy(parseTriggeringPolicy(p, utf8Decoder, currentElement));
-				RollingFileAppenderPtr rfa(appender);
+                if (rfa != NULL)
+                {
+                    rfa->setRollingPolicy(rollPolicy);
+                }
+            }
+            else if (tagName == TRIGGERING_POLICY_TAG)
+            {
+                ObjectPtr policy(parseTriggeringPolicy(p, utf8Decoder, currentElement));
+                RollingFileAppenderPtr rfa = log4cxx::cast<RollingFileAppender>(appender);
+                TriggeringPolicyPtr policyPtr = log4cxx::cast<TriggeringPolicy>(policy);
 
-				if (rfa != NULL)
-				{
-					rfa->setTriggeringPolicy(policy);
-				}
-				else
-				{
-					log4cxx::net::SMTPAppenderPtr smtpa(appender);
+                if (rfa != NULL)
+                {
+                    rfa->setTriggeringPolicy(policyPtr);
+                }
+                else
+                {
+                    log4cxx::net::SMTPAppenderPtr smtpa = log4cxx::cast<log4cxx::net::SMTPAppender>(appender);
 
-					if (smtpa != NULL)
-					{
-						log4cxx::spi::TriggeringEventEvaluatorPtr evaluator(policy);
-						smtpa->setEvaluator(evaluator);
-					}
-				}
-			}
-			else if (tagName == APPENDER_REF_TAG)
-			{
-				LogString refName = subst(getAttribute(utf8Decoder, currentElement, REF_ATTR));
+                    if (smtpa != NULL)
+                    {
+                        log4cxx::spi::TriggeringEventEvaluatorPtr evaluator = log4cxx::cast<TriggeringEventEvaluator>(policyPtr);
+                        smtpa->setEvaluator(evaluator);
+                    }
+                }
+            }
+            else if (tagName == APPENDER_REF_TAG)
+            {
+                LogString refName = subst(getAttribute(utf8Decoder, currentElement, REF_ATTR));
 
-				if (appender->instanceof(AppenderAttachable::getStaticClass()))
-				{
-					AppenderAttachablePtr aa(appender);
-					LogLog::debug(LOG4CXX_STR("Attaching appender named [") +
-						refName + LOG4CXX_STR("] to appender named [") +
-						appender->getName() + LOG4CXX_STR("]."));
-					aa->addAppender(findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders));
-				}
-				else
-				{
-					LogLog::error(LOG4CXX_STR("Requesting attachment of appender named [") +
-						refName + LOG4CXX_STR("] to appender named [") + appender->getName() +
-						LOG4CXX_STR("] which does not implement AppenderAttachable."));
-				}
-			}
-		}
+                if (appender->instanceof(AppenderAttachable::getStaticClass()))
+                {
+                    AppenderAttachablePtr aa = log4cxx::cast<AppenderAttachable>(appender);
+                    LogLog::debug(LOG4CXX_STR("Attaching appender named [") +
+                                  refName + LOG4CXX_STR("] to appender named [") +
+                                  appender->getName() + LOG4CXX_STR("]."));
+                    aa->addAppender(findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders));
+                }
+                else
+                {
+                    LogLog::error(LOG4CXX_STR("Requesting attachment of appender named [") +
+                                  refName + LOG4CXX_STR("] to appender named [") + appender->getName() +
+                                  LOG4CXX_STR("] which does not implement AppenderAttachable."));
+                }
+            }
+        }
 
-		propSetter.activate(p);
-		return appender;
-	}
-	/* Yes, it's ugly.  But all of these exceptions point to the same
-	    problem: we can't create an Appender */
-	catch (Exception& oops)
-	{
-		LogLog::error(LOG4CXX_STR("Could not create an Appender. Reported error follows."),
-			oops);
-		return 0;
-	}
+        propSetter.activate(p);
+        return appender;
+    }
+    /* Yes, it's ugly.  But all of these exceptions point to the same
+        problem: we can't create an Appender */
+    catch (Exception& oops)
+    {
+        LogLog::error(LOG4CXX_STR("Could not create an Appender. Reported error follows."),
+                      oops);
+        return 0;
+    }
 }
 
 /**
 Used internally to parse an {@link ErrorHandler} element.
 */
 void DOMConfigurator::parseErrorHandler(Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* element,
-	AppenderPtr& appender,
-	apr_xml_doc* doc,
-	AppenderMap& appenders)
+                                        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+                                        apr_xml_elem* element,
+                                        AppenderPtr& appender,
+                                        apr_xml_doc* doc,
+                                        AppenderMap& appenders)
 {
 
-	ErrorHandlerPtr eh = OptionConverter::instantiateByClassName(
-			subst(getAttribute(utf8Decoder, element, CLASS_ATTR)),
-			ErrorHandler::getStaticClass(),
-			0);
+    ErrorHandlerPtr eh;
+    std::shared_ptr<Object> obj = OptionConverter::instantiateByClassName(
+                             subst(getAttribute(utf8Decoder, element, CLASS_ATTR)),
+                             ErrorHandler::getStaticClass(),
+                             0);
+    eh = log4cxx::cast<ErrorHandler>(obj);
 
-	if (eh != 0)
-	{
-		eh->setAppender(appender);
+    if (eh != 0)
+    {
+        eh->setAppender(appender);
 
-		PropertySetter propSetter(eh);
+        PropertySetter propSetter(eh);
 
-		for (apr_xml_elem* currentElement = element->first_child;
-			currentElement;
-			currentElement = currentElement->next)
-		{
-			std::string tagName(currentElement->name);
+        for (apr_xml_elem* currentElement = element->first_child;
+                currentElement;
+                currentElement = currentElement->next)
+        {
+            std::string tagName(currentElement->name);
 
-			if (tagName == PARAM_TAG)
-			{
-				setParameter(p, utf8Decoder, currentElement, propSetter);
-			}
-			else if (tagName == APPENDER_REF_TAG)
-			{
-				eh->setBackupAppender(findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders));
-			}
-			else if (tagName == LOGGER_REF)
-			{
-				LogString loggerName(getAttribute(utf8Decoder, currentElement, REF_ATTR));
-				LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
-				eh->setLogger(logger);
-			}
-			else if (tagName == ROOT_REF)
-			{
-				LoggerPtr root = repository->getRootLogger();
-				eh->setLogger(root);
-			}
-		}
+            if (tagName == PARAM_TAG)
+            {
+                setParameter(p, utf8Decoder, currentElement, propSetter);
+            }
+            else if (tagName == APPENDER_REF_TAG)
+            {
+                eh->setBackupAppender(findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders));
+            }
+            else if (tagName == LOGGER_REF)
+            {
+                LogString loggerName(getAttribute(utf8Decoder, currentElement, REF_ATTR));
+                LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
+                eh->setLogger(logger);
+            }
+            else if (tagName == ROOT_REF)
+            {
+                LoggerPtr root = repository->getRootLogger();
+                eh->setLogger(root);
+            }
+        }
 
-		propSetter.activate(p);
-		ObjectPtrT<AppenderSkeleton> appSkeleton(appender);
+        propSetter.activate(p);
+        std::shared_ptr<AppenderSkeleton> appSkeleton = log4cxx::cast<AppenderSkeleton>(appender);
 
-		if (appSkeleton != 0)
-		{
-			appSkeleton->setErrorHandler(eh);
-		}
-	}
+        if (appSkeleton != 0)
+        {
+            appSkeleton->setErrorHandler(eh);
+        }
+    }
 }
 
 /**
  Used internally to parse a filter element.
 */
 void DOMConfigurator::parseFilters(Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* element,
-	std::vector<log4cxx::spi::FilterPtr>& filters)
+                                   log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+                                   apr_xml_elem* element,
+                                   std::vector<log4cxx::spi::FilterPtr>& filters)
 {
-	LogString clazz = subst(getAttribute(utf8Decoder, element, CLASS_ATTR));
-	FilterPtr filter = OptionConverter::instantiateByClassName(clazz,
-			Filter::getStaticClass(), 0);
+    LogString clazz = subst(getAttribute(utf8Decoder, element, CLASS_ATTR));
+    FilterPtr filter;
+    std::shared_ptr<Object> obj = OptionConverter::instantiateByClassName(clazz,
+                       Filter::getStaticClass(), 0);
+    filter = log4cxx::cast<Filter>(obj);
 
-	if (filter != 0)
-	{
-		PropertySetter propSetter(filter);
+    if (filter != 0)
+    {
+        PropertySetter propSetter(filter);
 
-		for (apr_xml_elem* currentElement = element->first_child;
-			currentElement;
-			currentElement = currentElement->next)
-		{
-			std::string tagName(currentElement->name);
+        for (apr_xml_elem* currentElement = element->first_child;
+                currentElement;
+                currentElement = currentElement->next)
+        {
+            std::string tagName(currentElement->name);
 
-			if (tagName == PARAM_TAG)
-			{
-				setParameter(p, utf8Decoder, currentElement, propSetter);
-			}
-		}
+            if (tagName == PARAM_TAG)
+            {
+                setParameter(p, utf8Decoder, currentElement, propSetter);
+            }
+        }
 
-		propSetter.activate(p);
-		filters.push_back(filter);
-	}
+        propSetter.activate(p);
+        filters.push_back(filter);
+    }
 }
 
 /**
 Used internally to parse an category or logger element.
 */
 void DOMConfigurator::parseLogger(
-	log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* loggerElement,
-	apr_xml_doc* doc,
-	AppenderMap& appenders)
+    log4cxx::helpers::Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* loggerElement,
+    apr_xml_doc* doc,
+    AppenderMap& appenders)
 {
-	// Create a new Logger object from the <category> element.
-	LogString loggerName = subst(getAttribute(utf8Decoder, loggerElement, NAME_ATTR));
+    // Create a new Logger object from the <category> element.
+    LogString loggerName = subst(getAttribute(utf8Decoder, loggerElement, NAME_ATTR));
 
-	LogLog::debug(LOG4CXX_STR("Retreiving an instance of Logger."));
-	LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
+    LogLog::debug(LOG4CXX_STR("Retreiving an instance of Logger."));
+    LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
 
-	// Setting up a logger needs to be an atomic operation, in order
-	// to protect potential log operations while logger
-	// configuration is in progress.
-	LOCK_W sync(logger->getMutex());
-	bool additivity = OptionConverter::toBoolean(
-			subst(getAttribute(utf8Decoder, loggerElement, ADDITIVITY_ATTR)),
-			true);
+    // Setting up a logger needs to be an atomic operation, in order
+    // to protect potential log operations while logger
+    // configuration is in progress.
+    bool additivity = OptionConverter::toBoolean(
+                          subst(getAttribute(utf8Decoder, loggerElement, ADDITIVITY_ATTR)),
+                          true);
 
-	LogLog::debug(LOG4CXX_STR("Setting [") + logger->getName() + LOG4CXX_STR("] additivity to [") +
-		(additivity ? LogString(LOG4CXX_STR("true")) : LogString(LOG4CXX_STR("false"))) + LOG4CXX_STR("]."));
+    LogLog::debug(LOG4CXX_STR("Setting [") + logger->getName() + LOG4CXX_STR("] additivity to [") +
+                  (additivity ? LogString(LOG4CXX_STR("true")) : LogString(LOG4CXX_STR("false"))) + LOG4CXX_STR("]."));
 	logger->setAdditivity(additivity);
 	parseChildrenOfLoggerElement(p, utf8Decoder, loggerElement, logger, false, doc, appenders);
 }
@@ -446,53 +439,52 @@
  Used internally to parse the logger factory element.
 */
 void DOMConfigurator::parseLoggerFactory(
-	log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* factoryElement)
+    log4cxx::helpers::Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* factoryElement)
 {
-	LogString className(subst(getAttribute(utf8Decoder, factoryElement, CLASS_ATTR)));
+    LogString className(subst(getAttribute(utf8Decoder, factoryElement, CLASS_ATTR)));
 
-	if (className.empty())
-	{
-		LogLog::error(LOG4CXX_STR("Logger Factory tag class attribute not found."));
-		LogLog::debug(LOG4CXX_STR("No Logger Factory configured."));
-	}
-	else
-	{
-		LogLog::debug(LOG4CXX_STR("Desired logger factory: [") + className + LOG4CXX_STR("]"));
-		loggerFactory = OptionConverter::instantiateByClassName(
-				className,
-				LoggerFactory::getStaticClass(),
-				0);
-		PropertySetter propSetter(loggerFactory);
+    if (className.empty())
+    {
+        LogLog::error(LOG4CXX_STR("Logger Factory tag class attribute not found."));
+        LogLog::debug(LOG4CXX_STR("No Logger Factory configured."));
+    }
+    else
+    {
+        LogLog::debug(LOG4CXX_STR("Desired logger factory: [") + className + LOG4CXX_STR("]"));
+        std::shared_ptr<Object> obj = OptionConverter::instantiateByClassName(
+                            className,
+                            LoggerFactory::getStaticClass(),
+                            0);
+        loggerFactory = log4cxx::cast<LoggerFactory>(obj);
+        PropertySetter propSetter(loggerFactory);
 
-		for (apr_xml_elem* currentElement = factoryElement->first_child;
-			currentElement;
-			currentElement = currentElement->next)
-		{
-			std::string tagName(currentElement->name);
+        for (apr_xml_elem* currentElement = factoryElement->first_child;
+                currentElement;
+                currentElement = currentElement->next)
+        {
+            std::string tagName(currentElement->name);
 
-			if (tagName == PARAM_TAG)
-			{
-				setParameter(p, utf8Decoder, currentElement, propSetter);
-			}
-		}
-	}
+            if (tagName == PARAM_TAG)
+            {
+                setParameter(p, utf8Decoder, currentElement, propSetter);
+            }
+        }
+    }
 }
 
 /**
  Used internally to parse the root logger element.
 */
 void DOMConfigurator::parseRoot(
-	log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* rootElement,
-	apr_xml_doc* doc,
-	AppenderMap& appenders)
+    log4cxx::helpers::Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* rootElement,
+    apr_xml_doc* doc,
+    AppenderMap& appenders)
 {
-	LoggerPtr root = repository->getRootLogger();
-	// logger configuration needs to be atomic
-	LOCK_W sync(root->getMutex());
+    LoggerPtr root = repository->getRootLogger();
 	parseChildrenOfLoggerElement(p, utf8Decoder, rootElement, root, true, doc, appenders);
 }
 
@@ -500,195 +492,194 @@
  Used internally to parse the children of a logger element.
 */
 void DOMConfigurator::parseChildrenOfLoggerElement(
-	log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* loggerElement, LoggerPtr logger, bool isRoot,
-	apr_xml_doc* doc,
+    log4cxx::helpers::Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* loggerElement, LoggerPtr logger, bool isRoot,
+    apr_xml_doc* doc,
 	AppenderMap& appenders)
 {
-
-	PropertySetter propSetter(logger);
+    PropertySetter propSetter(logger);
+    std::vector<AppenderPtr> newappenders;
 
 	// Remove all existing appenders from logger. They will be
 	// reconstructed if need be.
 	logger->removeAllAppenders();
 
+    for (apr_xml_elem* currentElement = loggerElement->first_child;
+            currentElement;
+            currentElement = currentElement->next)
+    {
+        std::string tagName(currentElement->name);
 
-	for (apr_xml_elem* currentElement = loggerElement->first_child;
-		currentElement;
-		currentElement = currentElement->next)
-	{
-		std::string tagName(currentElement->name);
+        if (tagName == APPENDER_REF_TAG)
+        {
+            AppenderPtr appender = findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders);
+            LogString refName =  subst(getAttribute(utf8Decoder, currentElement, REF_ATTR));
 
-		if (tagName == APPENDER_REF_TAG)
-		{
-			AppenderPtr appender = findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders);
-			LogString refName =  subst(getAttribute(utf8Decoder, currentElement, REF_ATTR));
-
-			if (appender != 0)
-			{
-				LogLog::debug(LOG4CXX_STR("Adding appender named [") + refName +
-					LOG4CXX_STR("] to logger [") + logger->getName() + LOG4CXX_STR("]."));
-			}
-			else
-			{
-				LogLog::debug(LOG4CXX_STR("Appender named [") + refName +
-					LOG4CXX_STR("] not found."));
-			}
+            if (appender != 0)
+            {
+                LogLog::debug(LOG4CXX_STR("Adding appender named [") + refName +
+                              LOG4CXX_STR("] to logger [") + logger->getName() + LOG4CXX_STR("]."));
+            }
+            else
+            {
+                LogLog::debug(LOG4CXX_STR("Appender named [") + refName +
+                              LOG4CXX_STR("] not found."));
+            }
 
 			logger->addAppender(appender);
 
-		}
-		else if (tagName == LEVEL_TAG)
-		{
-			parseLevel(p, utf8Decoder, currentElement, logger, isRoot);
-		}
-		else if (tagName == PRIORITY_TAG)
-		{
-			parseLevel(p, utf8Decoder, currentElement, logger, isRoot);
-		}
-		else if (tagName == PARAM_TAG)
-		{
-			setParameter(p, utf8Decoder, currentElement, propSetter);
-		}
+        }
+        else if (tagName == LEVEL_TAG)
+        {
+            parseLevel(p, utf8Decoder, currentElement, logger, isRoot);
+        }
+        else if (tagName == PRIORITY_TAG)
+        {
+            parseLevel(p, utf8Decoder, currentElement, logger, isRoot);
+        }
+        else if (tagName == PARAM_TAG)
+        {
+            setParameter(p, utf8Decoder, currentElement, propSetter);
+        }
 	}
 
-	propSetter.activate(p);
+    propSetter.activate(p);
 }
 
 /**
  Used internally to parse a layout element.
 */
 LayoutPtr DOMConfigurator::parseLayout (
-	log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* layout_element)
+    log4cxx::helpers::Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* layout_element)
 {
-	LogString className(subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR)));
-	LogLog::debug(LOG4CXX_STR("Parsing layout of class: \"") + className + LOG4CXX_STR("\""));
+    LogString className(subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR)));
+    LogLog::debug(LOG4CXX_STR("Parsing layout of class: \"") + className + LOG4CXX_STR("\""));
 
-	try
-	{
-		ObjectPtr instance = Loader::loadClass(className).newInstance();
-		LayoutPtr layout = instance;
-		PropertySetter propSetter(layout);
+    try
+    {
+        ObjectPtr instance = ObjectPtr(Loader::loadClass(className).newInstance());
+        LayoutPtr layout = log4cxx::cast<Layout>(instance);
+        PropertySetter propSetter(layout);
 
-		for (apr_xml_elem* currentElement = layout_element->first_child;
-			currentElement;
-			currentElement = currentElement->next)
-		{
-			std::string tagName(currentElement->name);
+        for (apr_xml_elem* currentElement = layout_element->first_child;
+                currentElement;
+                currentElement = currentElement->next)
+        {
+            std::string tagName(currentElement->name);
 
-			if (tagName == PARAM_TAG)
-			{
-				setParameter(p, utf8Decoder, currentElement, propSetter);
-			}
-		}
+            if (tagName == PARAM_TAG)
+            {
+                setParameter(p, utf8Decoder, currentElement, propSetter);
+            }
+        }
 
-		propSetter.activate(p);
-		return layout;
-	}
-	catch (Exception& oops)
-	{
-		LogLog::error(LOG4CXX_STR("Could not create the Layout. Reported error follows."),
-			oops);
-		return 0;
-	}
+        propSetter.activate(p);
+        return layout;
+    }
+    catch (Exception& oops)
+    {
+        LogLog::error(LOG4CXX_STR("Could not create the Layout. Reported error follows."),
+                      oops);
+        return 0;
+    }
 }
 
 /**
  Used internally to parse a triggering policy
 */
 ObjectPtr DOMConfigurator::parseTriggeringPolicy (
-	log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* layout_element)
+    log4cxx::helpers::Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* layout_element)
 {
-	LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
-	LogLog::debug(LOG4CXX_STR("Parsing triggering policy of class: \"") + className + LOG4CXX_STR("\""));
+    LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
+    LogLog::debug(LOG4CXX_STR("Parsing triggering policy of class: \"") + className + LOG4CXX_STR("\""));
 
-	try
-	{
-		ObjectPtr instance = Loader::loadClass(className).newInstance();
-		PropertySetter propSetter(instance);
+    try
+    {
+        ObjectPtr instance = ObjectPtr(Loader::loadClass(className).newInstance());
+        PropertySetter propSetter(instance);
 
-		for (apr_xml_elem* currentElement = layout_element->first_child;
-			currentElement;
-			currentElement = currentElement->next)
-		{
-			std::string tagName(currentElement->name);
+        for (apr_xml_elem* currentElement = layout_element->first_child;
+                currentElement;
+                currentElement = currentElement->next)
+        {
+            std::string tagName(currentElement->name);
 
-			if (tagName == PARAM_TAG)
-			{
-				setParameter(p, utf8Decoder, currentElement, propSetter);
-			}
-			else if (tagName == FILTER_TAG)
-			{
-				std::vector<log4cxx::spi::FilterPtr> filters;
-				parseFilters(p, utf8Decoder, currentElement, filters);
-				FilterBasedTriggeringPolicyPtr fbtp(instance);
+            if (tagName == PARAM_TAG)
+            {
+                setParameter(p, utf8Decoder, currentElement, propSetter);
+            }
+            else if (tagName == FILTER_TAG)
+            {
+                std::vector<log4cxx::spi::FilterPtr> filters;
+                parseFilters(p, utf8Decoder, currentElement, filters);
+                FilterBasedTriggeringPolicyPtr fbtp = log4cxx::cast<FilterBasedTriggeringPolicy>(instance);
 
-				if (fbtp != NULL)
-				{
-					for (std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
-						iter != filters.end();
-						iter++)
-					{
-						fbtp->addFilter(*iter);
-					}
-				}
-			}
-		}
+                if (fbtp != NULL)
+                {
+                    for (std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
+                            iter != filters.end();
+                            iter++)
+                    {
+                        fbtp->addFilter(*iter);
+                    }
+                }
+            }
+        }
 
-		propSetter.activate(p);
-		return instance;
-	}
-	catch (Exception& oops)
-	{
-		LogLog::error(LOG4CXX_STR("Could not create the TriggeringPolicy. Reported error follows."),
-			oops);
-		return 0;
-	}
+        propSetter.activate(p);
+        return instance;
+    }
+    catch (Exception& oops)
+    {
+        LogLog::error(LOG4CXX_STR("Could not create the TriggeringPolicy. Reported error follows."),
+                      oops);
+        return 0;
+    }
 }
 
 /**
  Used internally to parse a triggering policy
 */
 RollingPolicyPtr DOMConfigurator::parseRollingPolicy (
-	log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* layout_element)
+    log4cxx::helpers::Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* layout_element)
 {
-	LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
-	LogLog::debug(LOG4CXX_STR("Parsing rolling policy of class: \"") + className + LOG4CXX_STR("\""));
+    LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
+    LogLog::debug(LOG4CXX_STR("Parsing rolling policy of class: \"") + className + LOG4CXX_STR("\""));
 
-	try
-	{
-		ObjectPtr instance = Loader::loadClass(className).newInstance();
-		RollingPolicyPtr layout = instance;
-		PropertySetter propSetter(layout);
+    try
+    {
+        ObjectPtr instance = ObjectPtr(Loader::loadClass(className).newInstance());
+        RollingPolicyPtr layout = log4cxx::cast<RollingPolicy>(instance);
+        PropertySetter propSetter(layout);
 
-		for (apr_xml_elem* currentElement = layout_element->first_child;
-			currentElement;
-			currentElement = currentElement->next)
-		{
-			std::string tagName(currentElement->name);
+        for (apr_xml_elem* currentElement = layout_element->first_child;
+                currentElement;
+                currentElement = currentElement->next)
+        {
+            std::string tagName(currentElement->name);
 
-			if (tagName == PARAM_TAG)
-			{
-				setParameter(p, utf8Decoder, currentElement, propSetter);
-			}
-		}
+            if (tagName == PARAM_TAG)
+            {
+                setParameter(p, utf8Decoder, currentElement, propSetter);
+            }
+        }
 
-		propSetter.activate(p);
-		return layout;
-	}
-	catch (Exception& oops)
-	{
-		LogLog::error(LOG4CXX_STR("Could not create the RollingPolicy. Reported error follows."),
-			oops);
-		return 0;
-	}
+        propSetter.activate(p);
+        return layout;
+    }
+    catch (Exception& oops)
+    {
+        LogLog::error(LOG4CXX_STR("Could not create the RollingPolicy. Reported error follows."),
+                      oops);
+        return 0;
+    }
 }
 
 
@@ -697,238 +688,238 @@
  Used internally to parse a level  element.
 */
 void DOMConfigurator::parseLevel(
-	log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* element, LoggerPtr logger, bool isRoot)
+    log4cxx::helpers::Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* element, LoggerPtr logger, bool isRoot)
 {
-	LogString loggerName = logger->getName();
+    LogString loggerName = logger->getName();
 
-	if (isRoot)
-	{
-		loggerName = LOG4CXX_STR("root");
-	}
+    if (isRoot)
+    {
+        loggerName = LOG4CXX_STR("root");
+    }
 
-	LogString levelStr(subst(getAttribute(utf8Decoder, element, VALUE_ATTR)));
-	LogLog::debug(LOG4CXX_STR("Level value for ") + loggerName + LOG4CXX_STR(" is [") + levelStr + LOG4CXX_STR("]."));
+    LogString levelStr(subst(getAttribute(utf8Decoder, element, VALUE_ATTR)));
+    LogLog::debug(LOG4CXX_STR("Level value for ") + loggerName + LOG4CXX_STR(" is [") + levelStr + LOG4CXX_STR("]."));
 
-	if (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited"))
-		|| StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
-	{
-		if (isRoot)
-		{
-			LogLog::error(LOG4CXX_STR("Root level cannot be inherited. Ignoring directive."));
-		}
-		else
-		{
-			logger->setLevel(0);
-		}
-	}
-	else
-	{
-		LogString className(subst(getAttribute(utf8Decoder, element, CLASS_ATTR)));
+    if (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited"))
+            || StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
+    {
+        if (isRoot)
+        {
+            LogLog::error(LOG4CXX_STR("Root level cannot be inherited. Ignoring directive."));
+        }
+        else
+        {
+            logger->setLevel(0);
+        }
+    }
+    else
+    {
+        LogString className(subst(getAttribute(utf8Decoder, element, CLASS_ATTR)));
 
-		if (className.empty())
-		{
-			logger->setLevel(OptionConverter::toLevel(levelStr, Level::getDebug()));
-		}
-		else
-		{
-			LogLog::debug(LOG4CXX_STR("Desired Level sub-class: [") + className + LOG4CXX_STR("]"));
+        if (className.empty())
+        {
+            logger->setLevel(OptionConverter::toLevel(levelStr, Level::getDebug()));
+        }
+        else
+        {
+            LogLog::debug(LOG4CXX_STR("Desired Level sub-class: [") + className + LOG4CXX_STR("]"));
 
-			try
-			{
-				Level::LevelClass& levelClass =
-					(Level::LevelClass&)Loader::loadClass(className);
-				LevelPtr level = levelClass.toLevel(levelStr);
-				logger->setLevel(level);
-			}
-			catch (Exception& oops)
-			{
-				LogLog::error(
-					LOG4CXX_STR("Could not create level [") + levelStr +
-					LOG4CXX_STR("]. Reported error follows."),
-					oops);
+            try
+            {
+                Level::LevelClass& levelClass =
+                    (Level::LevelClass&)Loader::loadClass(className);
+                LevelPtr level = levelClass.toLevel(levelStr);
+                logger->setLevel(level);
+            }
+            catch (Exception& oops)
+            {
+                LogLog::error(
+                    LOG4CXX_STR("Could not create level [") + levelStr +
+                    LOG4CXX_STR("]. Reported error follows."),
+                    oops);
 
-				return;
-			}
-			catch (...)
-			{
-				LogLog::error(
-					LOG4CXX_STR("Could not create level [") + levelStr);
+                return;
+            }
+            catch (...)
+            {
+                LogLog::error(
+                    LOG4CXX_STR("Could not create level [") + levelStr);
 
-				return;
-			}
-		}
-	}
+                return;
+            }
+        }
+    }
 
-	LogLog::debug(loggerName + LOG4CXX_STR(" level set to ") +
-		logger->getEffectiveLevel()->toString());
+    LogLog::debug(loggerName + LOG4CXX_STR(" level set to ") +
+                  logger->getEffectiveLevel()->toString());
 }
 
 void DOMConfigurator::setParameter(log4cxx::helpers::Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* elem,
-	PropertySetter& propSetter)
+                                   log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+                                   apr_xml_elem* elem,
+                                   PropertySetter& propSetter)
 {
-	LogString name(subst(getAttribute(utf8Decoder, elem, NAME_ATTR)));
-	LogString value(subst(getAttribute(utf8Decoder, elem, VALUE_ATTR)));
-	value = subst(value);
-	propSetter.setProperty(name, value, p);
+    LogString name(subst(getAttribute(utf8Decoder, elem, NAME_ATTR)));
+    LogString value(subst(getAttribute(utf8Decoder, elem, VALUE_ATTR)));
+    value = subst(value);
+    propSetter.setProperty(name, value, p);
 }
 
-void DOMConfigurator::doConfigure(const File& filename, spi::LoggerRepositoryPtr& repository1)
+void DOMConfigurator::doConfigure(const File& filename, spi::LoggerRepositoryPtr repository1)
 {
-	repository1->setConfigured(true);
-	this->repository = repository1;
-	LogString msg(LOG4CXX_STR("DOMConfigurator configuring file "));
-	msg.append(filename.getPath());
-	msg.append(LOG4CXX_STR("..."));
-	LogLog::debug(msg);
+    repository1->setConfigured(true);
+    this->repository = repository1;
+    LogString msg(LOG4CXX_STR("DOMConfigurator configuring file "));
+    msg.append(filename.getPath());
+    msg.append(LOG4CXX_STR("..."));
+    LogLog::debug(msg);
 
-	loggerFactory = new DefaultLoggerFactory();
+    loggerFactory = LoggerFactoryPtr(new DefaultLoggerFactory());
 
-	Pool p;
-	apr_file_t* fd;
+    Pool p;
+    apr_file_t* fd;
 
-	log4cxx_status_t rv = filename.open(&fd, APR_READ, APR_OS_DEFAULT, p);
+    log4cxx_status_t rv = filename.open(&fd, APR_READ, APR_OS_DEFAULT, p);
 
-	if (rv != APR_SUCCESS)
-	{
-		LogString msg2(LOG4CXX_STR("Could not open file ["));
-		msg2.append(filename.getPath());
-		msg2.append(LOG4CXX_STR("]."));
-		LogLog::error(msg2);
-	}
-	else
-	{
-		apr_xml_parser* parser = NULL;
-		apr_xml_doc* doc = NULL;
-		rv = apr_xml_parse_file(p.getAPRPool(), &parser, &doc, fd, 2000);
+    if (rv != APR_SUCCESS)
+    {
+        LogString msg2(LOG4CXX_STR("Could not open file ["));
+        msg2.append(filename.getPath());
+        msg2.append(LOG4CXX_STR("]."));
+        LogLog::error(msg2);
+    }
+    else
+    {
+        apr_xml_parser* parser = NULL;
+        apr_xml_doc* doc = NULL;
+        rv = apr_xml_parse_file(p.getAPRPool(), &parser, &doc, fd, 2000);
 
-		if (rv != APR_SUCCESS)
-		{
-			char errbuf[2000];
-			char errbufXML[2000];
-			LogString msg2(LOG4CXX_STR("Error parsing file ["));
-			msg2.append(filename.getPath());
-			msg2.append(LOG4CXX_STR("], "));
-			apr_strerror(rv, errbuf, sizeof(errbuf));
-			LOG4CXX_DECODE_CHAR(lerrbuf, std::string(errbuf));
-			msg2.append(lerrbuf);
+        if (rv != APR_SUCCESS)
+        {
+            char errbuf[2000];
+            char errbufXML[2000];
+            LogString msg2(LOG4CXX_STR("Error parsing file ["));
+            msg2.append(filename.getPath());
+            msg2.append(LOG4CXX_STR("], "));
+            apr_strerror(rv, errbuf, sizeof(errbuf));
+            LOG4CXX_DECODE_CHAR(lerrbuf, std::string(errbuf));
+            msg2.append(lerrbuf);
 
-			if (parser)
-			{
-				apr_xml_parser_geterror(parser, errbufXML, sizeof(errbufXML));
-				LOG4CXX_DECODE_CHAR(lerrbufXML, std::string(errbufXML));
-				msg2.append(lerrbufXML);
-			}
+            if (parser)
+            {
+                apr_xml_parser_geterror(parser, errbufXML, sizeof(errbufXML));
+                LOG4CXX_DECODE_CHAR(lerrbufXML, std::string(errbufXML));
+                msg2.append(lerrbufXML);
+            }
 
-			LogLog::error(msg2);
-		}
-		else
-		{
-			AppenderMap appenders;
-			CharsetDecoderPtr utf8Decoder(CharsetDecoder::getUTF8Decoder());
-			parse(p, utf8Decoder, doc->root, doc, appenders);
-		}
-	}
+            LogLog::error(msg2);
+        }
+        else
+        {
+            AppenderMap appenders;
+            CharsetDecoderPtr utf8Decoder(CharsetDecoder::getUTF8Decoder());
+            parse(p, utf8Decoder, doc->root, doc, appenders);
+        }
+    }
 }
 
 void DOMConfigurator::configure(const std::string& filename)
 {
-	File file(filename);
-	DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+    File file(filename);
+    DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
 }
 
 #if LOG4CXX_WCHAR_T_API
 void DOMConfigurator::configure(const std::wstring& filename)
 {
-	File file(filename);
-	DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+    File file(filename);
+    DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
 }
 #endif
 
 #if LOG4CXX_UNICHAR_API
 void DOMConfigurator::configure(const std::basic_string<UniChar>& filename)
 {
-	File file(filename);
-	DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+    File file(filename);
+    DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
 }
 #endif
 
 #if LOG4CXX_CFSTRING_API
 void DOMConfigurator::configure(const CFStringRef& filename)
 {
-	File file(filename);
-	DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+    File file(filename);
+    DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
 }
 #endif
 
 
 void DOMConfigurator::configureAndWatch(const std::string& filename)
 {
-	configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
+    configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
 }
 
 #if LOG4CXX_WCHAR_T_API
 void DOMConfigurator::configureAndWatch(const std::wstring& filename)
 {
-	configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
+    configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
 }
 #endif
 
 #if LOG4CXX_UNICHAR_API
 void DOMConfigurator::configureAndWatch(const std::basic_string<UniChar>& filename)
 {
-	configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
+    configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
 }
 #endif
 
 #if LOG4CXX_CFSTRING_API
 void DOMConfigurator::configureAndWatch(const CFStringRef& filename)
 {
-	configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
+    configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
 }
 #endif
 
 void DOMConfigurator::configureAndWatch(const std::string& filename, long delay)
 {
-	File file(filename);
+    File file(filename);
 #if APR_HAS_THREADS
 
-	if ( xdog )
-	{
-		APRInitializer::unregisterCleanup(xdog);
-		delete xdog;
-	}
+    if ( xdog )
+    {
+        APRInitializer::unregisterCleanup(xdog);
+        delete xdog;
+    }
 
-	xdog = new XMLWatchdog(file);
-	APRInitializer::registerCleanup(xdog);
-	xdog->setDelay(delay);
-	xdog->start();
+    xdog = new XMLWatchdog(file);
+    APRInitializer::registerCleanup(xdog);
+    xdog->setDelay(delay);
+    xdog->start();
 #else
-	DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+    DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
 #endif
 }
 
 #if LOG4CXX_WCHAR_T_API
 void DOMConfigurator::configureAndWatch(const std::wstring& filename, long delay)
 {
-	File file(filename);
+    File file(filename);
 #if APR_HAS_THREADS
 
-	if ( xdog )
-	{
-		APRInitializer::unregisterCleanup(xdog);
-		delete xdog;
-	}
+    if ( xdog )
+    {
+        APRInitializer::unregisterCleanup(xdog);
+        delete xdog;
+    }
 
-	xdog = new XMLWatchdog(file);
-	APRInitializer::registerCleanup(xdog);
-	xdog->setDelay(delay);
-	xdog->start();
+    xdog = new XMLWatchdog(file);
+    APRInitializer::registerCleanup(xdog);
+    xdog->setDelay(delay);
+    xdog->start();
 #else
-	DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+    DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
 #endif
 }
 #endif
@@ -936,21 +927,21 @@
 #if LOG4CXX_UNICHAR_API
 void DOMConfigurator::configureAndWatch(const std::basic_string<UniChar>& filename, long delay)
 {
-	File file(filename);
+    File file(filename);
 #if APR_HAS_THREADS
 
-	if ( xdog )
-	{
-		APRInitializer::unregisterCleanup(xdog);
-		delete xdog;
-	}
+    if ( xdog )
+    {
+        APRInitializer::unregisterCleanup(xdog);
+        delete xdog;
+    }
 
-	xdog = new XMLWatchdog(file);
-	APRInitializer::registerCleanup(xdog);
-	xdog->setDelay(delay);
-	xdog->start();
+    xdog = new XMLWatchdog(file);
+    APRInitializer::registerCleanup(xdog);
+    xdog->setDelay(delay);
+    xdog->start();
 #else
-	DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+    DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
 #endif
 }
 #endif
@@ -958,154 +949,154 @@
 #if LOG4CXX_CFSTRING_API
 void DOMConfigurator::configureAndWatch(const CFStringRef& filename, long delay)
 {
-	File file(filename);
+    File file(filename);
 #if APR_HAS_THREADS
 
-	if ( xdog )
-	{
-		APRInitializer::unregisterCleanup(xdog);
-		delete xdog;
-	}
+    if ( xdog )
+    {
+        APRInitializer::unregisterCleanup(xdog);
+        delete xdog;
+    }
 
-	xdog = new XMLWatchdog(file);
-	APRInitializer::registerCleanup(xdog);
-	xdog->setDelay(delay);
-	xdog->start();
+    xdog = new XMLWatchdog(file);
+    APRInitializer::registerCleanup(xdog);
+    xdog->setDelay(delay);
+    xdog->start();
 #else
-	DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+    DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
 #endif
 }
 #endif
 
 void DOMConfigurator::parse(
-	Pool& p,
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* element,
-	apr_xml_doc* doc,
-	AppenderMap& appenders)
+    Pool& p,
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* element,
+    apr_xml_doc* doc,
+    AppenderMap& appenders)
 {
-	std::string rootElementName(element->name);
+    std::string rootElementName(element->name);
 
-	if (rootElementName != CONFIGURATION_TAG)
-	{
-		if (rootElementName == OLD_CONFIGURATION_TAG)
-		{
-			//LogLog::warn(LOG4CXX_STR("The <")+String(OLD_CONFIGURATION_TAG)+
-			// LOG4CXX_STR("> element has been deprecated."));
-			//LogLog::warn(LOG4CXX_STR("Use the <")+String(CONFIGURATION_TAG)+
-			// LOG4CXX_STR("> element instead."));
-		}
-		else
-		{
-			LogLog::error(LOG4CXX_STR("DOM element is - not a <configuration> element."));
-			return;
-		}
-	}
+    if (rootElementName != CONFIGURATION_TAG)
+    {
+        if (rootElementName == OLD_CONFIGURATION_TAG)
+        {
+            //LogLog::warn(LOG4CXX_STR("The <")+String(OLD_CONFIGURATION_TAG)+
+            // LOG4CXX_STR("> element has been deprecated."));
+            //LogLog::warn(LOG4CXX_STR("Use the <")+String(CONFIGURATION_TAG)+
+            // LOG4CXX_STR("> element instead."));
+        }
+        else
+        {
+            LogLog::error(LOG4CXX_STR("DOM element is - not a <configuration> element."));
+            return;
+        }
+    }
 
-	LogString debugAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_DEBUG_ATTR));
+    LogString debugAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_DEBUG_ATTR));
 
-	static const LogString NuLL(LOG4CXX_STR("NULL"));
-	LogLog::debug(LOG4CXX_STR("debug attribute= \"") + debugAttrib + LOG4CXX_STR("\"."));
+    static const LogString NuLL(LOG4CXX_STR("NULL"));
+    LogLog::debug(LOG4CXX_STR("debug attribute= \"") + debugAttrib + LOG4CXX_STR("\"."));
 
-	// if the log4j.dtd is not specified in the XML file, then the
-	// "debug" attribute is returned as the empty string.
-	if (!debugAttrib.empty() && debugAttrib != NuLL)
-	{
-		LogLog::setInternalDebugging(OptionConverter::toBoolean(debugAttrib, true));
-	}
-	else
-	{
-		LogLog::debug(LOG4CXX_STR("Ignoring internalDebug attribute."));
-	}
+    // if the log4j.dtd is not specified in the XML file, then the
+    // "debug" attribute is returned as the empty string.
+    if (!debugAttrib.empty() && debugAttrib != NuLL)
+    {
+        LogLog::setInternalDebugging(OptionConverter::toBoolean(debugAttrib, true));
+    }
+    else
+    {
+        LogLog::debug(LOG4CXX_STR("Ignoring internalDebug attribute."));
+    }
 
 
-	LogString confDebug = subst(getAttribute(utf8Decoder, element, CONFIG_DEBUG_ATTR));
+    LogString confDebug = subst(getAttribute(utf8Decoder, element, CONFIG_DEBUG_ATTR));
 
-	if (!confDebug.empty() && confDebug != NuLL)
-	{
-		LogLog::warn(LOG4CXX_STR("The \"configDebug\" attribute is deprecated."));
-		LogLog::warn(LOG4CXX_STR("Use the \"internalDebug\" attribute instead."));
-		LogLog::setInternalDebugging(OptionConverter::toBoolean(confDebug, true));
-	}
+    if (!confDebug.empty() && confDebug != NuLL)
+    {
+        LogLog::warn(LOG4CXX_STR("The \"configDebug\" attribute is deprecated."));
+        LogLog::warn(LOG4CXX_STR("Use the \"internalDebug\" attribute instead."));
+        LogLog::setInternalDebugging(OptionConverter::toBoolean(confDebug, true));
+    }
 
-	LogString thresholdStr = subst(getAttribute(utf8Decoder, element, THRESHOLD_ATTR));
-	LogLog::debug(LOG4CXX_STR("Threshold =\"") + thresholdStr + LOG4CXX_STR("\"."));
+    LogString thresholdStr = subst(getAttribute(utf8Decoder, element, THRESHOLD_ATTR));
+    LogLog::debug(LOG4CXX_STR("Threshold =\"") + thresholdStr + LOG4CXX_STR("\"."));
 
-	if (!thresholdStr.empty() && thresholdStr != NuLL)
-	{
-		repository->setThreshold(thresholdStr);
-	}
+    if (!thresholdStr.empty() && thresholdStr != NuLL)
+    {
+        repository->setThreshold(thresholdStr);
+    }
 
-	LogString strstrValue = subst(getAttribute(utf8Decoder, element, STRINGSTREAM_ATTR));
-	LogLog::debug(LOG4CXX_STR("Stringstream =\"") + strstrValue + LOG4CXX_STR("\"."));
+    LogString strstrValue = subst(getAttribute(utf8Decoder, element, STRINGSTREAM_ATTR));
+    LogLog::debug(LOG4CXX_STR("Stringstream =\"") + strstrValue + LOG4CXX_STR("\"."));
 
-	if (!strstrValue.empty() && strstrValue != NuLL)
-	{
-		MessageBufferUseStaticStream();
-	}
+    if (!strstrValue.empty() && strstrValue != NuLL)
+    {
+        MessageBufferUseStaticStream();
+    }
 
-	apr_xml_elem* currentElement;
+    apr_xml_elem* currentElement;
 
-	for (currentElement = element->first_child;
-		currentElement;
-		currentElement = currentElement->next)
-	{
-		std::string tagName(currentElement->name);
+    for (currentElement = element->first_child;
+            currentElement;
+            currentElement = currentElement->next)
+    {
+        std::string tagName(currentElement->name);
 
-		if (tagName == CATEGORY_FACTORY_TAG)
-		{
-			parseLoggerFactory(p, utf8Decoder, currentElement);
-		}
-	}
+        if (tagName == CATEGORY_FACTORY_TAG)
+        {
+            parseLoggerFactory(p, utf8Decoder, currentElement);
+        }
+    }
 
-	for (currentElement = element->first_child;
-		currentElement;
-		currentElement = currentElement->next)
-	{
-		std::string tagName(currentElement->name);
+    for (currentElement = element->first_child;
+            currentElement;
+            currentElement = currentElement->next)
+    {
+        std::string tagName(currentElement->name);
 
-		if (tagName == CATEGORY || tagName == LOGGER)
-		{
-			parseLogger(p, utf8Decoder, currentElement, doc, appenders);
-		}
-		else if (tagName == ROOT_TAG)
-		{
-			parseRoot(p, utf8Decoder, currentElement, doc, appenders);
-		}
-	}
+        if (tagName == CATEGORY || tagName == LOGGER)
+        {
+            parseLogger(p, utf8Decoder, currentElement, doc, appenders);
+        }
+        else if (tagName == ROOT_TAG)
+        {
+            parseRoot(p, utf8Decoder, currentElement, doc, appenders);
+        }
+    }
 }
 
 LogString DOMConfigurator::subst(const LogString& value)
 {
-	try
-	{
-		return OptionConverter::substVars(value, props);
-	}
-	catch (IllegalArgumentException& e)
-	{
-		LogLog::warn(LOG4CXX_STR("Could not perform variable substitution."), e);
-		return value;
-	}
+    try
+    {
+        return OptionConverter::substVars(value, props);
+    }
+    catch (IllegalArgumentException& e)
+    {
+        LogLog::warn(LOG4CXX_STR("Could not perform variable substitution."), e);
+        return value;
+    }
 }
 
 
 LogString DOMConfigurator::getAttribute(
-	log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-	apr_xml_elem* element,
-	const std::string& attrName)
+    log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+    apr_xml_elem* element,
+    const std::string& attrName)
 {
-	LogString attrValue;
+    LogString attrValue;
 
-	for (apr_xml_attr* attr = element->attr;
-		attr;
-		attr = attr->next)
-	{
-		if (attrName == attr->name)
-		{
-			ByteBuffer buf((char*) attr->value, strlen(attr->value));
-			utf8Decoder->decode(buf, attrValue);
-		}
-	}
+    for (apr_xml_attr* attr = element->attr;
+            attr;
+            attr = attr->next)
+    {
+        if (attrName == attr->name)
+        {
+            ByteBuffer buf((char*) attr->value, strlen(attr->value));
+            utf8Decoder->decode(buf, attrValue);
+        }
+    }
 
-	return attrValue;
+    return attrValue;
 }
diff --git a/src/main/cpp/exception.cpp b/src/main/cpp/exception.cpp
index 0023a9a..759d074 100644
--- a/src/main/cpp/exception.cpp
+++ b/src/main/cpp/exception.cpp
@@ -246,30 +246,6 @@
 }
 
 
-MutexException::MutexException(log4cxx_status_t stat)
-	: Exception(formatMessage(stat))
-{
-}
-
-MutexException::MutexException(const MutexException& src)
-	: Exception(src)
-{
-}
-
-MutexException& MutexException::operator=(const MutexException& src)
-{
-	Exception::operator=(src);
-	return *this;
-}
-
-LogString MutexException::formatMessage(log4cxx_status_t stat)
-{
-	LogString s(LOG4CXX_STR("Mutex exception: stat = "));
-	Pool p;
-	StringHelper::toString(stat, p, s);
-	return s;
-}
-
 InterruptedException::InterruptedException() : Exception(LOG4CXX_STR("Thread was interrupted"))
 {
 }
diff --git a/src/main/cpp/fallbackerrorhandler.cpp b/src/main/cpp/fallbackerrorhandler.cpp
index 7e59270..76fa48b 100644
--- a/src/main/cpp/fallbackerrorhandler.cpp
+++ b/src/main/cpp/fallbackerrorhandler.cpp
@@ -35,16 +35,6 @@
 {
 }
 
-void FallbackErrorHandler::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void FallbackErrorHandler::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
 void FallbackErrorHandler::setLogger(const LoggerPtr& logger)
 {
 	LogLog::debug(((LogString) LOG4CXX_STR("FB: Adding logger ["))
@@ -67,9 +57,8 @@
 		+  message, e);
 	LogLog::debug(LOG4CXX_STR("FB: INITIATING FALLBACK PROCEDURE."));
 
-	for (size_t i = 0; i < loggers.size(); i++)
+	for (LoggerPtr l : loggers)
 	{
-		LoggerPtr& l = (LoggerPtr&)loggers.at(i);
 		LogLog::debug(((LogString) LOG4CXX_STR("FB: Searching for ["))
 			+ primary->getName() + LOG4CXX_STR("] in logger [")
 			+ l->getName() + LOG4CXX_STR("]."));
diff --git a/src/main/cpp/fileappender.cpp b/src/main/cpp/fileappender.cpp
index 8d678d4..a9fb11d 100644
--- a/src/main/cpp/fileappender.cpp
+++ b/src/main/cpp/fileappender.cpp
@@ -20,13 +20,11 @@
 #include <log4cxx/helpers/stringhelper.h>
 #include <log4cxx/helpers/loglog.h>
 #include <log4cxx/helpers/optionconverter.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/pool.h>
 #include <log4cxx/helpers/fileoutputstream.h>
 #include <log4cxx/helpers/outputstreamwriter.h>
 #include <log4cxx/helpers/bufferedwriter.h>
 #include <log4cxx/helpers/bytebuffer.h>
-#include <log4cxx/helpers/synchronized.h>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -37,155 +35,162 @@
 
 FileAppender::FileAppender()
 {
-	LOCK_W sync(mutex);
-	fileAppend = true;
-	bufferedIO = false;
-	bufferSize = 8 * 1024;
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+    fileAppend = true;
+    bufferedIO = false;
+    bufferSize = 8 * 1024;
 }
 
 FileAppender::FileAppender(const LayoutPtr& layout1, const LogString& fileName1,
-	bool append1, bool bufferedIO1, int bufferSize1)
-	: WriterAppender(layout1)
+                           bool append1, bool bufferedIO1, int bufferSize1)
+    : WriterAppender(layout1)
 {
-	{
-		LOCK_W sync(mutex);
-		fileAppend = append1;
-		fileName = fileName1;
-		bufferedIO = bufferedIO1;
-		bufferSize = bufferSize1;
-	}
-	Pool p;
-	activateOptions(p);
+    {
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+        fileAppend = append1;
+        fileName = fileName1;
+        bufferedIO = bufferedIO1;
+        bufferSize = bufferSize1;
+    }
+    Pool p;
+    activateOptions(p);
 }
 
 FileAppender::FileAppender(const LayoutPtr& layout1, const LogString& fileName1,
-	bool append1)
-	: WriterAppender(layout1)
+                           bool append1)
+    : WriterAppender(layout1)
 {
-	{
-		LOCK_W sync(mutex);
-		fileAppend = append1;
-		fileName = fileName1;
-		bufferedIO = false;
-		bufferSize = 8 * 1024;
-	}
-	Pool p;
-	activateOptions(p);
+    {
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+        fileAppend = append1;
+        fileName = fileName1;
+        bufferedIO = false;
+        bufferSize = 8 * 1024;
+    }
+    Pool p;
+    activateOptions(p);
 }
 
 FileAppender::FileAppender(const LayoutPtr& layout1, const LogString& fileName1)
-	: WriterAppender(layout1)
+    : WriterAppender(layout1)
 {
-	{
-		LOCK_W sync(mutex);
-		fileAppend = true;
-		fileName = fileName1;
-		bufferedIO = false;
-		bufferSize = 8 * 1024;
-	}
-	Pool p;
-	activateOptions(p);
+    {
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+        fileAppend = true;
+        fileName = fileName1;
+        bufferedIO = false;
+        bufferSize = 8 * 1024;
+    }
+    Pool p;
+    activateOptions(p);
 }
 
 FileAppender::~FileAppender()
 {
-	finalize();
+    finalize();
 }
 
 void FileAppender::setAppend(bool fileAppend1)
 {
-	LOCK_W sync(mutex);
-	this->fileAppend = fileAppend1;
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+    this->fileAppend = fileAppend1;
 }
 
 void FileAppender::setFile(const LogString& file)
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+	setFileInternal(file);
+}
+
+void FileAppender::setFileInternal(const LogString& file)
+{
 	fileName = file;
 }
 
-
-
 void FileAppender::setBufferedIO(bool bufferedIO1)
 {
-	LOCK_W sync(mutex);
-	this->bufferedIO = bufferedIO1;
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+    this->bufferedIO = bufferedIO1;
 
-	if (bufferedIO1)
-	{
-		setImmediateFlush(false);
-	}
+    if (bufferedIO1)
+    {
+        setImmediateFlush(false);
+    }
 }
 
 void FileAppender::setOption(const LogString& option,
-	const LogString& value)
+                             const LogString& value)
 {
-	if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FILE"), LOG4CXX_STR("file"))
-		|| StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FILENAME"), LOG4CXX_STR("filename")))
-	{
-		LOCK_W sync(mutex);
-		fileName = stripDuplicateBackslashes(value);
-	}
-	else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("APPEND"), LOG4CXX_STR("append")))
-	{
-		LOCK_W sync(mutex);
-		fileAppend = OptionConverter::toBoolean(value, true);
-	}
-	else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFEREDIO"), LOG4CXX_STR("bufferedio")))
-	{
-		LOCK_W sync(mutex);
-		bufferedIO = OptionConverter::toBoolean(value, true);
-	}
-	else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("IMMEDIATEFLUSH"), LOG4CXX_STR("immediateflush")))
-	{
-		LOCK_W sync(mutex);
-		bufferedIO = !OptionConverter::toBoolean(value, false);
-	}
-	else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
-	{
-		LOCK_W sync(mutex);
-		bufferSize = OptionConverter::toFileSize(value, 8 * 1024);
-	}
-	else
-	{
-		WriterAppender::setOption(option, value);
-	}
+    if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FILE"), LOG4CXX_STR("file"))
+            || StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FILENAME"), LOG4CXX_STR("filename")))
+    {
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+        fileName = stripDuplicateBackslashes(value);
+    }
+    else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("APPEND"), LOG4CXX_STR("append")))
+    {
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+        fileAppend = OptionConverter::toBoolean(value, true);
+    }
+    else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFEREDIO"), LOG4CXX_STR("bufferedio")))
+    {
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+        bufferedIO = OptionConverter::toBoolean(value, true);
+    }
+    else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("IMMEDIATEFLUSH"), LOG4CXX_STR("immediateflush")))
+    {
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+        bufferedIO = !OptionConverter::toBoolean(value, false);
+    }
+    else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
+    {
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+        bufferSize = OptionConverter::toFileSize(value, 8 * 1024);
+    }
+    else
+    {
+        WriterAppender::setOption(option, value);
+    }
 }
 
 void FileAppender::activateOptions(Pool& p)
 {
-	LOCK_W sync(mutex);
-	int errors = 0;
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+	activateOptionsInternal(p);
+}
 
-	if (!fileName.empty())
-	{
-		try
-		{
-			setFile(fileName, fileAppend, bufferedIO, bufferSize, p);
-		}
-		catch (IOException& e)
-		{
-			errors++;
-			LogString msg(LOG4CXX_STR("setFile("));
-			msg.append(fileName);
-			msg.append(1, (logchar) 0x2C /* ',' */);
-			StringHelper::toString(fileAppend, msg);
-			msg.append(LOG4CXX_STR(") call failed."));
-			errorHandler->error(msg, e, ErrorCode::FILE_OPEN_FAILURE);
-		}
-	}
-	else
-	{
-		errors++;
-		LogLog::error(LogString(LOG4CXX_STR("File option not set for appender ["))
-			+  name + LOG4CXX_STR("]."));
-		LogLog::warn(LOG4CXX_STR("Are you using FileAppender instead of ConsoleAppender?"));
-	}
+void FileAppender::activateOptionsInternal(Pool& p){
+    int errors = 0;
 
-	if (errors == 0)
-	{
-		WriterAppender::activateOptions(p);
-	}
+    if (!fileName.empty())
+    {
+        try
+        {
+			setFileInternal(fileName, fileAppend, bufferedIO, bufferSize, p);
+        }
+        catch (IOException& e)
+        {
+            errors++;
+            LogString msg(LOG4CXX_STR("setFile("));
+            msg.append(fileName);
+            msg.append(1, (logchar) 0x2C /* ',' */);
+            StringHelper::toString(fileAppend, msg);
+            msg.append(LOG4CXX_STR(") call failed."));
+            errorHandler->error(msg, e, ErrorCode::FILE_OPEN_FAILURE);
+        }
+    }
+    else
+    {
+        errors++;
+        LogLog::error(LogString(LOG4CXX_STR("File option not set for appender ["))
+                      +  name + LOG4CXX_STR("]."));
+        LogLog::warn(LOG4CXX_STR("Are you using FileAppender instead of ConsoleAppender?"));
+    }
+
+    if (errors == 0)
+    {
+        WriterAppender::activateOptions(p);
+    }
 }
 
 
@@ -202,45 +207,45 @@
  */
 LogString FileAppender::stripDuplicateBackslashes(const LogString& src)
 {
-	logchar backslash = 0x5C; // '\\'
-	LogString::size_type i = src.find_last_of(backslash);
+    logchar backslash = 0x5C; // '\\'
+    LogString::size_type i = src.find_last_of(backslash);
 
-	if (i != LogString::npos)
-	{
-		LogString tmp(src);
+    if (i != LogString::npos)
+    {
+        LogString tmp(src);
 
-		for (;
-			i != LogString::npos && i > 0;
-			i = tmp.find_last_of(backslash, i - 1))
-		{
-			//
-			//   if the preceding character is a slash then
-			//      remove the preceding character
-			//      and continue processing
-			if (tmp[i - 1] == backslash)
-			{
-				tmp.erase(i, 1);
-				i--;
+        for (;
+                i != LogString::npos && i > 0;
+                i = tmp.find_last_of(backslash, i - 1))
+        {
+            //
+            //   if the preceding character is a slash then
+            //      remove the preceding character
+            //      and continue processing
+            if (tmp[i - 1] == backslash)
+            {
+                tmp.erase(i, 1);
+                i--;
 
-				if (i == 0)
-				{
-					break;
-				}
-			}
-			else
-			{
-				//
-				//  if there an odd number of slashes
-				//     the string wasn't trying to work around
-				//     OptionConverter::convertSpecialChars
-				return src;
-			}
-		}
+                if (i == 0)
+                {
+                    break;
+                }
+            }
+            else
+            {
+                //
+                //  if there an odd number of slashes
+                //     the string wasn't trying to work around
+                //     OptionConverter::convertSpecialChars
+                return src;
+            }
+        }
 
-		return tmp;
-	}
+        return tmp;
+    }
 
-	return src;
+    return src;
 }
 
 /**
@@ -263,98 +268,96 @@
   @throws IOException
 
  */
-void FileAppender::setFile(
-	const LogString& filename,
-	bool append1,
-	bool bufferedIO1,
-	size_t bufferSize1,
-	Pool& p)
+void FileAppender::setFileInternal(
+    const LogString& filename,
+    bool append1,
+    bool bufferedIO1,
+    size_t bufferSize1,
+    Pool& p)
 {
-	LOCK_W sync(mutex);
+    // It does not make sense to have immediate flush and bufferedIO.
+    if (bufferedIO1)
+    {
+        setImmediateFlush(false);
+    }
 
-	// It does not make sense to have immediate flush and bufferedIO.
-	if (bufferedIO1)
-	{
-		setImmediateFlush(false);
+    closeWriter();
+
+    bool writeBOM = false;
+
+    if (StringHelper::equalsIgnoreCase(getEncoding(),
+                                       LOG4CXX_STR("utf-16"), LOG4CXX_STR("UTF-16")))
+    {
+        //
+        //    don't want to write a byte order mark if the file exists
+        //
+        if (append1)
+        {
+            File outFile;
+            outFile.setPath(filename);
+            writeBOM = !outFile.exists(p);
+        }
+        else
+        {
+            writeBOM = true;
+        }
+    }
+
+    OutputStreamPtr outStream;
+
+    try
+    {
+        outStream = FileOutputStreamPtr(new FileOutputStream(filename, append1));
+    }
+    catch (IOException&)
+    {
+        LogString parentName = File().setPath(filename).getParent(p);
+
+        if (!parentName.empty())
+        {
+            File parentDir;
+            parentDir.setPath(parentName);
+
+            if (!parentDir.exists(p) && parentDir.mkdirs(p))
+            {
+                outStream = OutputStreamPtr(new FileOutputStream(filename, append1));
+            }
+            else
+            {
+                throw;
+            }
+        }
+        else
+        {
+            throw;
+        }
+    }
+
+
+    //
+    //   if a new file and UTF-16, then write a BOM
+    //
+    if (writeBOM)
+    {
+        char bom[] = { (char) 0xFE, (char) 0xFF };
+        ByteBuffer buf(bom, 2);
+        outStream->write(buf, p);
+    }
+
+    WriterPtr newWriter(createWriter(outStream));
+
+    if (bufferedIO1)
+    {
+        newWriter = WriterPtr(new BufferedWriter(newWriter, bufferSize1));
 	}
 
-	closeWriter();
+    setWriterInternal(newWriter);
 
-	bool writeBOM = false;
-
-	if (StringHelper::equalsIgnoreCase(getEncoding(),
-			LOG4CXX_STR("utf-16"), LOG4CXX_STR("UTF-16")))
-	{
-		//
-		//    don't want to write a byte order mark if the file exists
-		//
-		if (append1)
-		{
-			File outFile;
-			outFile.setPath(filename);
-			writeBOM = !outFile.exists(p);
-		}
-		else
-		{
-			writeBOM = true;
-		}
-	}
-
-	OutputStreamPtr outStream;
-
-	try
-	{
-		outStream = new FileOutputStream(filename, append1);
-	}
-	catch (IOException&)
-	{
-		LogString parentName = File().setPath(filename).getParent(p);
-
-		if (!parentName.empty())
-		{
-			File parentDir;
-			parentDir.setPath(parentName);
-
-			if (!parentDir.exists(p) && parentDir.mkdirs(p))
-			{
-				outStream = new FileOutputStream(filename, append1);
-			}
-			else
-			{
-				throw;
-			}
-		}
-		else
-		{
-			throw;
-		}
-	}
-
-
-	//
-	//   if a new file and UTF-16, then write a BOM
-	//
-	if (writeBOM)
-	{
-		char bom[] = { (char) 0xFE, (char) 0xFF };
-		ByteBuffer buf(bom, 2);
-		outStream->write(buf, p);
-	}
-
-	WriterPtr newWriter(createWriter(outStream));
-
-	if (bufferedIO1)
-	{
-		newWriter = new BufferedWriter(newWriter, bufferSize1);
-	}
-
-	setWriter(newWriter);
-
-	this->fileAppend = append1;
-	this->bufferedIO = bufferedIO1;
-	this->fileName = filename;
-	this->bufferSize = (int)bufferSize1;
-	writeHeader(p);
+    this->fileAppend = append1;
+    this->bufferedIO = bufferedIO1;
+    this->fileName = filename;
+    this->bufferSize = (int)bufferSize1;
+    writeHeader(p);
 
 }
 
diff --git a/src/main/cpp/filewatchdog.cpp b/src/main/cpp/filewatchdog.cpp
index b2771ff..9d5afea 100644
--- a/src/main/cpp/filewatchdog.cpp
+++ b/src/main/cpp/filewatchdog.cpp
@@ -23,14 +23,13 @@
 #include <apr_atomic.h>
 #include <log4cxx/helpers/transcoder.h>
 #include <log4cxx/helpers/exception.h>
+#include <functional>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
 
 long FileWatchdog::DEFAULT_DELAY = 60000;
 
-#if APR_HAS_THREADS
-
 FileWatchdog::FileWatchdog(const File& file1)
 	: file(file1), delay(DEFAULT_DELAY), lastModif(0),
 	  warnedAlready(false), interrupted(0), thread()
@@ -39,16 +38,13 @@
 
 FileWatchdog::~FileWatchdog()
 {
-	apr_atomic_set32(&interrupted, 0xFFFF);
+    interrupted = 0xFFFF;
 
-	try
-	{
-		thread.interrupt();
-		thread.join();
-	}
-	catch (Exception&)
-	{
-	}
+    {
+		log4cxx::unique_lock<log4cxx::mutex> lock(interrupt_mutex);
+        interrupt.notify_all();
+    }
+    thread.join();
 }
 
 void FileWatchdog::checkAndConfigure()
@@ -78,33 +74,27 @@
 	}
 }
 
-void* APR_THREAD_FUNC FileWatchdog::run(apr_thread_t* /* thread */, void* data)
+void FileWatchdog::run()
 {
-	FileWatchdog* pThis = (FileWatchdog*) data;
 
-	unsigned int interrupted = apr_atomic_read32(&pThis->interrupted);
+    while (interrupted != 0xFFFF)
+    {
+		log4cxx::unique_lock<log4cxx::mutex> lock( interrupt_mutex );
+        interrupt.wait_for( lock, std::chrono::milliseconds( delay ),
+                            std::bind(&FileWatchdog::is_interrupted, this) );
 
-	while (!interrupted)
-	{
-		try
-		{
-			Thread::sleep(pThis->delay);
-			pThis->checkAndConfigure();
-		}
-		catch (InterruptedException&)
-		{
-			interrupted = apr_atomic_read32(&pThis->interrupted);
-		}
-	}
+        checkAndConfigure();
+    }
 
-	return NULL;
 }
 
 void FileWatchdog::start()
 {
 	checkAndConfigure();
 
-	thread.run(run, this);
+	thread = log4cxx::thread( &FileWatchdog::run, this );
 }
 
-#endif
+bool FileWatchdog::is_interrupted(){
+    return interrupted == 0xFFFF;
+}
diff --git a/src/main/cpp/filter.cpp b/src/main/cpp/filter.cpp
index 87e9d9e..d838286 100644
--- a/src/main/cpp/filter.cpp
+++ b/src/main/cpp/filter.cpp
@@ -26,16 +26,6 @@
 {
 }
 
-void Filter::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void Filter::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
 FilterPtr Filter::getNext() const
 {
 	return next;
diff --git a/src/main/cpp/fixedwindowrollingpolicy.cpp b/src/main/cpp/fixedwindowrollingpolicy.cpp
index 0cd9cea..bcc7d23 100644
--- a/src/main/cpp/fixedwindowrollingpolicy.cpp
+++ b/src/main/cpp/fixedwindowrollingpolicy.cpp
@@ -133,7 +133,8 @@
 
 	ActionPtr noAction;
 
-	return new RolloverDescription(newActiveFile, append, noAction, noAction);
+    return RolloverDescriptionPtr(
+                new RolloverDescription(newActiveFile, append, noAction, noAction));
 }
 
 /**
@@ -174,31 +175,31 @@
 	if (StringHelper::endsWith(renameTo, LOG4CXX_STR(".gz")))
 	{
 		renameTo.resize(renameTo.size() - 3);
-		compressAction =
+        compressAction = ActionPtr(
 			new GZCompressAction(
 			File().setPath(renameTo),
 			File().setPath(compressedName),
-			true);
+            true));
 	}
 	else if (StringHelper::endsWith(renameTo, LOG4CXX_STR(".zip")))
 	{
 		renameTo.resize(renameTo.size() - 4);
-		compressAction =
+        compressAction = ActionPtr(
 			new ZipCompressAction(
 			File().setPath(renameTo),
 			File().setPath(compressedName),
-			true);
+            true));
 	}
 
-	FileRenameActionPtr renameAction =
+    FileRenameActionPtr renameAction = FileRenameActionPtr(
 		new FileRenameAction(
 		File().setPath(currentActiveFile),
 		File().setPath(renameTo),
-		false);
+        false));
 
-	desc = new RolloverDescription(
+    desc = RolloverDescriptionPtr(new RolloverDescription(
 		currentActiveFile,  append,
-		renameAction,       compressAction);
+        renameAction,       compressAction));
 
 	return desc;
 }
@@ -235,7 +236,7 @@
 
 	std::vector<FileRenameActionPtr> renames;
 	LogString buf;
-	ObjectPtr obj = new Integer(lowIndex);
+    ObjectPtr obj = ObjectPtr(new Integer(lowIndex));
 	formatFileName(obj, buf, p);
 
 	LogString lowFilename(buf);
@@ -296,7 +297,7 @@
 			//   if intermediate index
 			//     add a rename action to the list
 			buf.erase(buf.begin(), buf.end());
-			obj = new Integer(i + 1);
+            obj = ObjectPtr(new Integer(i + 1));
 			formatFileName(obj, buf, p);
 
 			LogString highFilename(buf);
@@ -308,7 +309,7 @@
 					highFilename.substr(0, highFilename.length() - suffixLength);
 			}
 
-			renames.push_back(new FileRenameAction(*toRename, File().setPath(renameTo), true));
+            renames.push_back(FileRenameActionPtr(new FileRenameAction(*toRename, File().setPath(renameTo), true)));
 			lowFilename = highFilename;
 		}
 		else
diff --git a/src/main/cpp/hierarchy.cpp b/src/main/cpp/hierarchy.cpp
index ee6d417..b0a7ded 100644
--- a/src/main/cpp/hierarchy.cpp
+++ b/src/main/cpp/hierarchy.cpp
@@ -29,7 +29,6 @@
 #include <algorithm>
 #include <log4cxx/helpers/loglog.h>
 #include <log4cxx/appender.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/stringhelper.h>
 #if !defined(LOG4CXX)
@@ -38,7 +37,6 @@
 #include <log4cxx/helpers/aprinitializer.h>
 #include <log4cxx/defaultconfigurator.h>
 #include <log4cxx/spi/rootlogger.h>
-#include <apr_atomic.h>
 #include "assert.h"
 
 
@@ -49,15 +47,14 @@
 IMPLEMENT_LOG4CXX_OBJECT(Hierarchy)
 
 Hierarchy::Hierarchy() :
-	pool(),
-	mutex(pool),
+    pool(),
 	loggers(new LoggerMap()),
 	provisionNodes(new ProvisionNodeMap())
 {
-	synchronized sync(mutex);
-	root = new RootLogger(pool, Level::getDebug());
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
+    root = LoggerPtr(new RootLogger(pool, Level::getDebug()));
 	root->setHierarchy(this);
-	defaultFactory = new DefaultLoggerFactory();
+    defaultFactory = LoggerFactoryPtr(new DefaultLoggerFactory());
 	emittedNoAppenderWarning = false;
 	configured = false;
 	thresholdInt = Level::ALL_INT;
@@ -75,19 +72,9 @@
 #endif
 }
 
-void Hierarchy::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void Hierarchy::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
 void Hierarchy::addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener)
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 	if (std::find(listeners.begin(), listeners.end(), listener) != listeners.end())
 	{
@@ -101,15 +88,15 @@
 
 void Hierarchy::clear()
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 	loggers->clear();
 }
 
-void Hierarchy::emitNoAppenderWarning(const LoggerPtr& logger)
+void Hierarchy::emitNoAppenderWarning(const Logger* logger)
 {
 	bool emitWarning = false;
 	{
-		synchronized sync(mutex);
+		log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 		emitWarning = !emittedNoAppenderWarning;
 		emittedNoAppenderWarning = true;
 	}
@@ -126,7 +113,7 @@
 
 LoggerPtr Hierarchy::exists(const LogString& name)
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 	LoggerPtr logger;
 	LoggerMap::iterator it = loggers->find(name);
@@ -144,14 +131,8 @@
 {
 	if (l != 0)
 	{
-		synchronized sync(mutex);
-		thresholdInt = l->toInt();
-		threshold = l;
-
-		if (thresholdInt != Level::ALL_INT)
-		{
-			setConfigured(true);
-		}
+		log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
+        setThresholdInternal(l);
 	}
 }
 
@@ -170,12 +151,22 @@
 	}
 }
 
-void Hierarchy::fireAddAppenderEvent(const LoggerPtr& logger, const AppenderPtr& appender)
+void Hierarchy::setThresholdInternal(const LevelPtr &l){
+    thresholdInt = l->toInt();
+    threshold = l;
+
+    if (thresholdInt != Level::ALL_INT)
+    {
+        configured = true;
+    }
+}
+
+void Hierarchy::fireAddAppenderEvent(const Logger* logger, const Appender* appender)
 {
 	setConfigured(true);
 	HierarchyEventListenerList clonedList;
 	{
-		synchronized sync(mutex);
+		log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 		clonedList = listeners;
 	}
 
@@ -185,16 +176,16 @@
 	for (it = clonedList.begin(); it != itEnd; it++)
 	{
 		listener = *it;
-		listener->addAppenderEvent(logger, appender);
+        listener->addAppenderEvent(logger, appender);
 	}
 }
 
-void Hierarchy::fireRemoveAppenderEvent(const LoggerPtr& logger, const AppenderPtr& appender)
+void Hierarchy::fireRemoveAppenderEvent(const Logger* logger, const Appender* appender)
 
 {
 	HierarchyEventListenerList clonedList;
 	{
-		synchronized sync(mutex);
+		log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 		clonedList = listeners;
 	}
 	HierarchyEventListenerList::iterator it, itEnd = clonedList.end();
@@ -220,7 +211,7 @@
 LoggerPtr Hierarchy::getLogger(const LogString& name,
 	const spi::LoggerFactoryPtr& factory)
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 	LoggerMap::iterator it = loggers->find(name);
 
@@ -250,7 +241,7 @@
 
 LoggerList Hierarchy::getCurrentLoggers() const
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 	LoggerList v;
 	LoggerMap::const_iterator it, itEnd = loggers->end();
@@ -271,15 +262,16 @@
 
 bool Hierarchy::isDisabled(int level) const
 {
-	if (!configured)
-	{
-		synchronized sync(mutex);
-
-		if (!configured)
-		{
-			DefaultConfigurator::configure(
-				const_cast<Hierarchy*>(this));
-		}
+    bool currentlyConfigured;
+    {
+		log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
+        currentlyConfigured = configured;
+    }
+    if (!currentlyConfigured)
+    {
+        std::shared_ptr<Hierarchy> nonconstThis = std::const_pointer_cast<Hierarchy>(shared_from_this());
+        DefaultConfigurator::configure(
+            nonconstThis);
 	}
 
 	return thresholdInt > level;
@@ -288,62 +280,61 @@
 
 void Hierarchy::resetConfiguration()
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 	getRootLogger()->setLevel(Level::getDebug());
 	root->setResourceBundle(0);
-	setThreshold(Level::getAll());
+    setThresholdInternal(Level::getAll());
 
-	shutdown(); // nested locks are OK
+    shutdownInternal();
 
-	LoggerList loggers1 = getCurrentLoggers();
-	LoggerList::iterator it, itEnd = loggers1.end();
+    LoggerMap::const_iterator it, itEnd = loggers->end();
 
-	for (it = loggers1.begin(); it != itEnd; it++)
-	{
-		LoggerPtr& logger = *it;
-		logger->setLevel(0);
-		logger->setAdditivity(true);
-		logger->setResourceBundle(0);
-	}
+    for (it = loggers->begin(); it != itEnd; it++)
+    {
+        it->second->setLevel(0);
+        it->second->setAdditivity(true);
+        it->second->setResourceBundle(0);
+    }
 
 	//rendererMap.clear();
 }
 
 void Hierarchy::shutdown()
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
-	setConfigured(false);
-
-	LoggerPtr root1 = getRootLogger();
-
-	// begin by closing nested appenders
-	root1->closeNestedAppenders();
-
-	LoggerList loggers1 = getCurrentLoggers();
-	LoggerList::iterator it, itEnd = loggers1.end();
-
-	for (it = loggers1.begin(); it != itEnd; it++)
-	{
-		LoggerPtr& logger = *it;
-		logger->closeNestedAppenders();
-	}
-
-	// then, remove all appenders
-	root1->removeAllAppenders();
-
-	for (it = loggers1.begin(); it != itEnd; it++)
-	{
-		LoggerPtr& logger = *it;
-		logger->removeAllAppenders();
-	}
+    shutdownInternal();
 }
 
+void Hierarchy::shutdownInternal(){
+    configured = false;
+
+    LoggerPtr root1 = getRootLogger();
+
+    // begin by closing nested appenders
+    root1->closeNestedAppenders();
+
+    LoggerMap::iterator it, itEnd = loggers->end();
+
+    for (it = loggers->begin(); it != itEnd; it++)
+    {
+        LoggerPtr logger = it->second;
+        logger->closeNestedAppenders();
+    }
+
+    // then, remove all appenders
+    root1->removeAllAppenders();
+
+    for (it = loggers->begin(); it != itEnd; it++)
+    {
+        LoggerPtr logger = it->second;
+        logger->removeAllAppenders();
+    }
+}
 
 void Hierarchy::updateParents(LoggerPtr logger)
 {
-	synchronized sync(mutex);
 	const LogString name(logger->getName());
 	size_t length = name.size();
 	bool parentFound = false;
@@ -409,7 +400,7 @@
 
 void Hierarchy::setConfigured(bool newValue)
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 	configured = newValue;
 }
 
diff --git a/src/main/cpp/inetaddress.cpp b/src/main/cpp/inetaddress.cpp
index 5158648..0f20584 100644
--- a/src/main/cpp/inetaddress.cpp
+++ b/src/main/cpp/inetaddress.cpp
@@ -103,7 +103,7 @@
 			Transcoder::decode(host, hostNameString);
 		}
 
-		result.push_back(new InetAddress(hostNameString, ipAddrString));
+        result.push_back(InetAddressPtr(new InetAddress(hostNameString, ipAddrString)));
 		currentAddr = currentAddr->next;
 	}
 
diff --git a/src/main/cpp/integerpatternconverter.cpp b/src/main/cpp/integerpatternconverter.cpp
index 27be938..36a11d5 100644
--- a/src/main/cpp/integerpatternconverter.cpp
+++ b/src/main/cpp/integerpatternconverter.cpp
@@ -48,7 +48,7 @@
 	LogString& toAppendTo,
 	Pool& p) const
 {
-	IntegerPtr i(obj);
+    IntegerPtr i = log4cxx::cast<Integer>(obj);
 
 	if (i != NULL)
 	{
diff --git a/src/main/cpp/jsonlayout.cpp b/src/main/cpp/jsonlayout.cpp
index a2e72c3..d475777 100644
--- a/src/main/cpp/jsonlayout.cpp
+++ b/src/main/cpp/jsonlayout.cpp
@@ -24,8 +24,6 @@
 #include <log4cxx/helpers/stringhelper.h>
 #include <log4cxx/helpers/transcoder.h>
 
-#include <apr_time.h>
-#include <apr_strings.h>
 #include <string.h>
 
 using namespace log4cxx;
diff --git a/src/main/cpp/layout.cpp b/src/main/cpp/layout.cpp
index a54215c..522044d 100644
--- a/src/main/cpp/layout.cpp
+++ b/src/main/cpp/layout.cpp
@@ -25,16 +25,6 @@
 
 Layout::~Layout() {}
 
-void Layout::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void Layout::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
 LogString Layout::getContentType() const
 {
 	return LOG4CXX_STR("text/plain");
diff --git a/src/main/cpp/level.cpp b/src/main/cpp/level.cpp
index ef388a9..c8f2921 100644
--- a/src/main/cpp/level.cpp
+++ b/src/main/cpp/level.cpp
@@ -29,45 +29,86 @@
 
 IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(Level, LevelClass)
 
+volatile bool Level::initialized = false;
+log4cxx::mutex Level::initMutex;
+LevelPtr Level::allLevel;
+LevelPtr Level::fatalLevel;
+LevelPtr Level::errorLevel;
+LevelPtr Level::warnLevel;
+LevelPtr Level::infoLevel;
+LevelPtr Level::debugLevel;
+LevelPtr Level::traceLevel;
+LevelPtr Level::offLevel;
+
+void Level::initializeLevels(){
+    if( initialized ){
+        return;
+    }
+
+	log4cxx::unique_lock<log4cxx::mutex> lock(initMutex);
+    if( initialized ){
+        return;
+    }
+
+    allLevel   = LevelPtr(new Level(Level::ALL_INT, LOG4CXX_STR("ALL"), 7));
+    fatalLevel = LevelPtr(new Level(Level::FATAL_INT, LOG4CXX_STR("FATAL"), 0));
+    errorLevel = LevelPtr(new Level(Level::ERROR_INT, LOG4CXX_STR("ERROR"), 3));
+    warnLevel  = LevelPtr(new Level(Level::WARN_INT, LOG4CXX_STR("WARN"), 4));
+    infoLevel  = LevelPtr(new Level(Level::INFO_INT, LOG4CXX_STR("INFO"), 6));
+    debugLevel = LevelPtr(new Level(Level::DEBUG_INT, LOG4CXX_STR("DEBUG"), 7));
+    traceLevel = LevelPtr(new Level(Level::TRACE_INT, LOG4CXX_STR("TRACE"), 7));
+    offLevel   = LevelPtr(new Level(Level::OFF_INT, LOG4CXX_STR("OFF"), 0));
+
+    initialized = true;
+}
+
 LevelPtr Level::getOff()
 {
-	return LevelPtr(new Level(Level::OFF_INT, LOG4CXX_STR("OFF"), 0));
+    initializeLevels();
+    return offLevel;
 }
 
 LevelPtr Level::getFatal()
 {
-	return LevelPtr(new Level(Level::FATAL_INT, LOG4CXX_STR("FATAL"), 0));
+    initializeLevels();
+    return fatalLevel;
 }
 
 LevelPtr Level::getError()
 {
-	return LevelPtr(new Level(Level::ERROR_INT, LOG4CXX_STR("ERROR"), 3));
+    initializeLevels();
+    return errorLevel;
 }
 
 LevelPtr Level::getWarn()
 {
-	return LevelPtr(new Level(Level::WARN_INT, LOG4CXX_STR("WARN"), 4));
+    initializeLevels();
+    return warnLevel;
 }
 
 LevelPtr Level::getInfo()
 {
-	return LevelPtr(new Level(Level::INFO_INT, LOG4CXX_STR("INFO"), 6));
+    initializeLevels();
+    return infoLevel;
 }
 
 LevelPtr Level::getDebug()
 {
-	return LevelPtr(new Level(Level::DEBUG_INT, LOG4CXX_STR("DEBUG"), 7));
+    initializeLevels();
+    return debugLevel;
 }
 
 LevelPtr Level::getTrace()
 {
-	return LevelPtr(new Level(Level::TRACE_INT, LOG4CXX_STR("TRACE"), 7));
+    initializeLevels();
+    return traceLevel;
 }
 
 
 LevelPtr Level::getAll()
 {
-	return LevelPtr(new Level(Level::ALL_INT, LOG4CXX_STR("ALL"), 7));
+    initializeLevels();
+    return allLevel;
 }
 
 
@@ -76,7 +117,7 @@
 	const LogString& name1, int syslogEquivalent1)
 	: level(level1), name(name1), syslogEquivalent(syslogEquivalent1)
 {
-	APRInitializer::initialize();
+    APRInitializer::initialize();
 }
 
 
diff --git a/src/main/cpp/levelpatternconverter.cpp b/src/main/cpp/levelpatternconverter.cpp
index 03ffad2..13ae6d7 100644
--- a/src/main/cpp/levelpatternconverter.cpp
+++ b/src/main/cpp/levelpatternconverter.cpp
@@ -59,7 +59,7 @@
  */
 LogString LevelPatternConverter::getStyleClass(const ObjectPtr& obj) const
 {
-	LoggingEventPtr e(obj);
+    LoggingEventPtr e = log4cxx::cast<LoggingEvent>(obj);
 
 	if (e != NULL)
 	{
diff --git a/src/main/cpp/loader.cpp b/src/main/cpp/loader.cpp
index cc1bec9..e7a2f63 100644
--- a/src/main/cpp/loader.cpp
+++ b/src/main/cpp/loader.cpp
@@ -65,7 +65,7 @@
 
 	try
 	{
-		return new FileInputStream(name);
+        return InputStreamPtr( new FileInputStream(name) );
 	}
 	catch (const IOException&)
 	{
diff --git a/src/main/cpp/locationinfo.cpp b/src/main/cpp/locationinfo.cpp
index 0ff6246..6106687 100644
--- a/src/main/cpp/locationinfo.cpp
+++ b/src/main/cpp/locationinfo.cpp
@@ -18,8 +18,6 @@
 #include <log4cxx/spi/location/locationinfo.h>
 #include <log4cxx/helpers/objectoutputstream.h>
 #include <log4cxx/helpers/pool.h>
-#include "apr_pools.h"
-#include "apr_strings.h"
 
 using namespace ::log4cxx::spi;
 using namespace log4cxx::helpers;
diff --git a/src/main/cpp/logger.cpp b/src/main/cpp/logger.cpp
index 5738740..24e02ff 100644
--- a/src/main/cpp/logger.cpp
+++ b/src/main/cpp/logger.cpp
@@ -25,12 +25,11 @@
 #include <log4cxx/helpers/loglog.h>
 #include <log4cxx/spi/loggerrepository.h>
 #include <log4cxx/helpers/stringhelper.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/transcoder.h>
 #include <log4cxx/helpers/appenderattachableimpl.h>
 #include <log4cxx/helpers/exception.h>
 #if !defined(LOG4CXX)
-	#define LOG4CXX 1
+#define LOG4CXX 1
 #endif
 #include <log4cxx/private/log4cxx_private.h>
 #include <log4cxx/helpers/aprinitializer.h>
@@ -42,304 +41,318 @@
 IMPLEMENT_LOG4CXX_OBJECT(Logger)
 
 Logger::Logger(Pool& p, const LogString& name1)
-	: pool(&p), name(), level(), parent(), resourceBundle(),
-	  repository(), aai(), SHARED_MUTEX_INIT(mutex, p)
+    : pool(&p), name(), level(), parent(), resourceBundle(),
+      repository(), aai()
 {
-	name = name1;
-	additive = true;
+    name = name1;
+    additive = true;
 }
 
 Logger::~Logger()
 {
 }
 
-void Logger::addRef() const
+void Logger::addAppender(const AppenderPtr newAppender)
 {
-	ObjectImpl::addRef();
+    log4cxx::spi::LoggerRepository* rep = 0;
+    {
+		log4cxx::shared_lock<log4cxx::shared_mutex> lock(mutex);
+
+        if (aai == 0)
+        {
+            aai = AppenderAttachableImplPtr(new AppenderAttachableImpl(*pool));
+        }
+
+        aai->addAppender(newAppender);
+        rep = repository;
+    }
+
+    if (rep != 0)
+    {
+        rep->fireAddAppenderEvent(this, newAppender.get());
+    }
 }
 
-void Logger::releaseRef() const
-{
-	ObjectImpl::releaseRef();
+void Logger::reconfigure( const std::vector<AppenderPtr>& appenders, bool additive1 ) {
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+
+    additive = additive1;
+
+    if (aai != 0)
+    {
+        aai->removeAllAppenders();
+        aai = 0;
+    }
+
+    aai = AppenderAttachableImplPtr(new AppenderAttachableImpl(*pool));
+
+    for( std::vector<AppenderPtr>::const_iterator it = appenders.cbegin();
+            it != appenders.cend();
+            it++ ) {
+        aai->addAppender( *it );
+
+        if (repository != 0)
+        {
+            repository->fireAddAppenderEvent(this, it->get());
+        }
+    }
 }
 
-void Logger::addAppender(const AppenderPtr& newAppender)
-{
-	log4cxx::spi::LoggerRepository* rep = 0;
-	{
-		LOCK_W sync(mutex);
-
-		if (aai == 0)
-		{
-			aai = new AppenderAttachableImpl(*pool);
-		}
-
-		aai->addAppender(newAppender);
-		rep = repository;
-	}
-
-	if (rep != 0)
-	{
-		rep->fireAddAppenderEvent(this, newAppender);
-	}
-}
-
-
 void Logger::callAppenders(const spi::LoggingEventPtr& event, Pool& p) const
 {
-	int writes = 0;
+    int writes = 0;
 
-	for (LoggerPtr logger(const_cast<Logger*>(this));
-		logger != 0;
-		logger = logger->parent)
-	{
-		// Protected against simultaneous call to addAppender, removeAppender,...
-		LOCK_R sync(logger->mutex);
+    for (const Logger* logger = this;
+            logger != 0;
+            logger = logger->parent.get())
+    {
+        // Protected against simultaneous call to addAppender, removeAppender,...
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(logger->mutex);
 
-		if (logger->aai != 0)
-		{
-			writes += logger->aai->appendLoopOnAppenders(event, p);
-		}
+        if (logger->aai != 0)
+        {
+            writes += logger->aai->appendLoopOnAppenders(event, p);
+        }
 
-		if (!logger->additive)
-		{
-			break;
-		}
-	}
+        if (!logger->additive)
+        {
+            break;
+        }
+    }
 
-	if (writes == 0 && repository != 0)
-	{
-		repository->emitNoAppenderWarning(const_cast<Logger*>(this));
-	}
+    if (writes == 0 && repository != 0)
+    {
+        repository->emitNoAppenderWarning(const_cast<Logger*>(this));
+    }
 }
 
 void Logger::closeNestedAppenders()
 {
-	AppenderList appenders = getAllAppenders();
+    AppenderList appenders = getAllAppenders();
 
-	for (AppenderList::iterator it = appenders.begin(); it != appenders.end(); ++it)
-	{
-		(*it)->close();
-	}
+    for (AppenderList::iterator it = appenders.begin(); it != appenders.end(); ++it)
+    {
+        (*it)->close();
+    }
 }
 
 
 void Logger::forcedLog(const LevelPtr& level1, const std::string& message,
-	const LocationInfo& location) const
+                       const LocationInfo& location) const
 {
-	Pool p;
-	LOG4CXX_DECODE_CHAR(msg, message);
-	LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
-	callAppenders(event, p);
+    Pool p;
+    LOG4CXX_DECODE_CHAR(msg, message);
+    LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
+    callAppenders(event, p);
 }
 
 
 void Logger::forcedLog(const LevelPtr& level1, const std::string& message) const
 {
-	Pool p;
-	LOG4CXX_DECODE_CHAR(msg, message);
-	LoggingEventPtr event(new LoggingEvent(name, level1, msg,
-			LocationInfo::getLocationUnavailable()));
-	callAppenders(event, p);
+    Pool p;
+    LOG4CXX_DECODE_CHAR(msg, message);
+    LoggingEventPtr event(new LoggingEvent(name, level1, msg,
+                                           LocationInfo::getLocationUnavailable()));
+    callAppenders(event, p);
 }
 
 void Logger::forcedLogLS(const LevelPtr& level1, const LogString& message,
-	const LocationInfo& location) const
+                         const LocationInfo& location) const
 {
-	Pool p;
-	LoggingEventPtr event(new LoggingEvent(name, level1, message, location));
-	callAppenders(event, p);
+    Pool p;
+    LoggingEventPtr event(new LoggingEvent(name, level1, message, location));
+    callAppenders(event, p);
 }
 
 
 bool Logger::getAdditivity() const
 {
-	return additive;
+    return additive;
 }
 
 AppenderList Logger::getAllAppenders() const
 {
-	LOCK_W sync(mutex);
+	log4cxx::shared_lock<log4cxx::shared_mutex> lock(mutex);
 
-	if (aai == 0)
-	{
-		return AppenderList();
-	}
-	else
-	{
-		return aai->getAllAppenders();
-	}
+    if (aai == 0)
+    {
+        return AppenderList();
+    }
+    else
+    {
+        return aai->getAllAppenders();
+    }
 }
 
 AppenderPtr Logger::getAppender(const LogString& name1) const
 {
-	LOCK_W sync(mutex);
+	log4cxx::shared_lock<log4cxx::shared_mutex> lock(mutex);
 
-	if (aai == 0 || name1.empty())
-	{
-		return 0;
-	}
+    if (aai == 0 || name1.empty())
+    {
+        return 0;
+    }
 
-	return aai->getAppender(name1);
+    return aai->getAppender(name1);
 }
 
-const LevelPtr& Logger::getEffectiveLevel() const
+const LevelPtr Logger::getEffectiveLevel() const
 {
-	for (const Logger* l = this; l != 0; l = l->parent)
-	{
-		if (l->level != 0)
-		{
-			return l->level;
-		}
-	}
+    for (const Logger* l = this; l != 0; l = l->parent.get())
+    {
+        if (l->level != 0)
+        {
+            return l->level;
+        }
+    }
 
-	throw NullPointerException(LOG4CXX_STR("No level specified for logger or ancestors."));
+    throw NullPointerException(LOG4CXX_STR("No level specified for logger or ancestors."));
 #if LOG4CXX_RETURN_AFTER_THROW
-	return this->level;
+    return this->level;
 #endif
 }
 
-LoggerRepositoryPtr Logger::getLoggerRepository() const
+LoggerRepository* Logger::getLoggerRepository() const
 {
-	return repository;
+    return repository;
 }
 
 ResourceBundlePtr Logger::getResourceBundle() const
 {
-	for (LoggerPtr l(const_cast<Logger*>(this)); l != 0; l = l->parent)
-	{
-		if (l->resourceBundle != 0)
-		{
-			return l->resourceBundle;
-		}
-	}
+    for (const Logger* l = this; l != 0; l = l->parent.get())
+    {
+        if (l->resourceBundle != 0)
+        {
+            return l->resourceBundle;
+        }
+    }
 
-	// It might be the case that there is no resource bundle
-	return 0;
+    // It might be the case that there is no resource bundle
+    return 0;
 }
 
 
 LogString Logger::getResourceBundleString(const LogString& key) const
 {
-	ResourceBundlePtr rb = getResourceBundle();
+    ResourceBundlePtr rb = getResourceBundle();
 
-	// This is one of the rare cases where we can use logging in order
-	// to report errors from within log4j.
-	if (rb == 0)
-	{
-		return LogString();
-	}
-	else
-	{
-		try
-		{
-			return rb->getString(key);
-		}
-		catch (MissingResourceException&)
-		{
-			logLS(Level::getError(), LOG4CXX_STR("No resource is associated with key \"") +
-				key + LOG4CXX_STR("\"."), LocationInfo::getLocationUnavailable());
+    // This is one of the rare cases where we can use logging in order
+    // to report errors from within log4j.
+    if (rb == 0)
+    {
+        return LogString();
+    }
+    else
+    {
+        try
+        {
+            return rb->getString(key);
+        }
+        catch (MissingResourceException&)
+        {
+            logLS(Level::getError(), LOG4CXX_STR("No resource is associated with key \"") +
+                  key + LOG4CXX_STR("\"."), LocationInfo::getLocationUnavailable());
 
-			return LogString();
-		}
-	}
+            return LogString();
+        }
+    }
 }
 
 
 LoggerPtr Logger::getParent() const
 {
-	return parent;
+    return parent;
 }
 
 LevelPtr Logger::getLevel() const
 {
-	return level;
+    return level;
 }
 
 
-bool Logger::isAttached(const AppenderPtr& appender) const
+bool Logger::isAttached(const AppenderPtr appender) const
 {
-	LOCK_R sync(mutex);
+	log4cxx::shared_lock<log4cxx::shared_mutex> lock(mutex);
 
-	if (appender == 0 || aai == 0)
-	{
-		return false;
-	}
-	else
-	{
-		return aai->isAttached(appender);
-	}
+    if (appender == 0 || aai == 0)
+    {
+        return false;
+    }
+    else
+    {
+        return aai->isAttached(appender);
+    }
 }
 
 bool Logger::isTraceEnabled() const
 {
-	if (repository == 0 || repository->isDisabled(Level::TRACE_INT))
-	{
-		return false;
-	}
+    if (repository == 0 || repository->isDisabled(Level::TRACE_INT))
+    {
+        return false;
+    }
 
-	return getEffectiveLevel()->toInt() <= Level::TRACE_INT;
+    return getEffectiveLevel()->toInt() <= Level::TRACE_INT;
 }
 
 bool Logger::isDebugEnabled() const
 {
-	if (repository == 0 || repository->isDisabled(Level::DEBUG_INT))
-	{
-		return false;
-	}
+    if (repository == 0 || repository->isDisabled(Level::DEBUG_INT))
+    {
+        return false;
+    }
 
-	return getEffectiveLevel()->toInt() <= Level::DEBUG_INT;
+    return getEffectiveLevel()->toInt() <= Level::DEBUG_INT;
 }
 
 bool Logger::isEnabledFor(const LevelPtr& level1) const
 {
-	if (repository == 0 || repository->isDisabled(level1->toInt()))
-	{
-		return false;
-	}
+    if (repository == 0 || repository->isDisabled(level1->toInt()))
+    {
+        return false;
+    }
 
-	return level1->isGreaterOrEqual(getEffectiveLevel());
+    return level1->isGreaterOrEqual(getEffectiveLevel());
 }
 
 
 bool Logger::isInfoEnabled() const
 {
-	if (repository == 0 || repository->isDisabled(Level::INFO_INT))
-	{
-		return false;
-	}
+    if (repository == 0 || repository->isDisabled(Level::INFO_INT))
+    {
+        return false;
+    }
 
-	return getEffectiveLevel()->toInt() <= Level::INFO_INT;
+    return getEffectiveLevel()->toInt() <= Level::INFO_INT;
 }
 
 bool Logger::isErrorEnabled() const
 {
-	if (repository == 0 || repository->isDisabled(Level::ERROR_INT))
-	{
-		return false;
-	}
+    if (repository == 0 || repository->isDisabled(Level::ERROR_INT))
+    {
+        return false;
+    }
 
-	return getEffectiveLevel()->toInt() <= Level::ERROR_INT;
+    return getEffectiveLevel()->toInt() <= Level::ERROR_INT;
 }
 
 bool Logger::isWarnEnabled() const
 {
-	if (repository == 0 || repository->isDisabled(Level::WARN_INT))
-	{
-		return false;
-	}
+    if (repository == 0 || repository->isDisabled(Level::WARN_INT))
+    {
+        return false;
+    }
 
-	return getEffectiveLevel()->toInt() <= Level::WARN_INT;
+    return getEffectiveLevel()->toInt() <= Level::WARN_INT;
 }
 
 bool Logger::isFatalEnabled() const
 {
-	if (repository == 0 || repository->isDisabled(Level::FATAL_INT))
-	{
-		return false;
-	}
+    if (repository == 0 || repository->isDisabled(Level::FATAL_INT))
+    {
+        return false;
+    }
 
-	return getEffectiveLevel()->toInt() <= Level::FATAL_INT;
+    return getEffectiveLevel()->toInt() <= Level::FATAL_INT;
 }
 
 /*void Logger::l7dlog(const LevelPtr& level, const String& key,
@@ -368,294 +381,293 @@
 
 
 void Logger::l7dlog(const LevelPtr& level1, const LogString& key,
-	const LocationInfo& location, const std::vector<LogString>& params) const
+                    const LocationInfo& location, const std::vector<LogString>& params) const
 {
-	if (repository == 0 || repository->isDisabled(level1->toInt()))
-	{
-		return;
-	}
+    if (repository == 0 || repository->isDisabled(level1->toInt()))
+    {
+        return;
+    }
 
-	if (level1->isGreaterOrEqual(getEffectiveLevel()))
-	{
-		LogString pattern = getResourceBundleString(key);
-		LogString msg;
+    if (level1->isGreaterOrEqual(getEffectiveLevel()))
+    {
+        LogString pattern = getResourceBundleString(key);
+        LogString msg;
 
-		if (pattern.empty())
-		{
-			msg = key;
-		}
-		else
-		{
-			msg = StringHelper::format(pattern, params);
-		}
+        if (pattern.empty())
+        {
+            msg = key;
+        }
+        else
+        {
+            msg = StringHelper::format(pattern, params);
+        }
 
-		forcedLogLS(level1, msg, location);
-	}
+        forcedLogLS(level1, msg, location);
+    }
 }
 
 void Logger::l7dlog(const LevelPtr& level1, const std::string& key,
-	const LocationInfo& location) const
+                    const LocationInfo& location) const
 {
-	LOG4CXX_DECODE_CHAR(lkey, key);
+    LOG4CXX_DECODE_CHAR(lkey, key);
 
-	std::vector<LogString> values(0);
-	l7dlog(level1, lkey, location, values);
+    std::vector<LogString> values(0);
+    l7dlog(level1, lkey, location, values);
 }
 
 void Logger::l7dlog(const LevelPtr& level1, const std::string& key,
-	const LocationInfo& location, const std::string& val1) const
+                    const LocationInfo& location, const std::string& val1) const
 {
-	LOG4CXX_DECODE_CHAR(lkey, key);
-	LOG4CXX_DECODE_CHAR(lval1, val1);
+    LOG4CXX_DECODE_CHAR(lkey, key);
+    LOG4CXX_DECODE_CHAR(lval1, val1);
 
-	std::vector<LogString> values(1);
-	values[0] = lval1;
-	l7dlog(level1, lkey, location, values);
+    std::vector<LogString> values(1);
+    values[0] = lval1;
+    l7dlog(level1, lkey, location, values);
 }
 
 void Logger::l7dlog(const LevelPtr& level1, const std::string& key,
-	const LocationInfo& location,
-	const std::string& val1, const std::string& val2) const
+                    const LocationInfo& location,
+                    const std::string& val1, const std::string& val2) const
 {
-	LOG4CXX_DECODE_CHAR(lkey, key);
-	LOG4CXX_DECODE_CHAR(lval1, val1);
-	LOG4CXX_DECODE_CHAR(lval2, val2);
+    LOG4CXX_DECODE_CHAR(lkey, key);
+    LOG4CXX_DECODE_CHAR(lval1, val1);
+    LOG4CXX_DECODE_CHAR(lval2, val2);
 
-	std::vector<LogString> values(2);
-	values[0] = lval1;
-	values[1] = lval2;
-	l7dlog(level1, lkey, location, values);
+    std::vector<LogString> values(2);
+    values[0] = lval1;
+    values[1] = lval2;
+    l7dlog(level1, lkey, location, values);
 }
 
 void Logger::l7dlog(const LevelPtr& level1, const std::string& key,
-	const LocationInfo& location,
-	const std::string& val1, const std::string& val2, const std::string& val3) const
+                    const LocationInfo& location,
+                    const std::string& val1, const std::string& val2, const std::string& val3) const
 {
-	LOG4CXX_DECODE_CHAR(lkey, key);
-	LOG4CXX_DECODE_CHAR(lval1, val1);
-	LOG4CXX_DECODE_CHAR(lval2, val2);
-	LOG4CXX_DECODE_CHAR(lval3, val3);
+    LOG4CXX_DECODE_CHAR(lkey, key);
+    LOG4CXX_DECODE_CHAR(lval1, val1);
+    LOG4CXX_DECODE_CHAR(lval2, val2);
+    LOG4CXX_DECODE_CHAR(lval3, val3);
 
-	std::vector<LogString> values(3);
-	values[0] = lval1;
-	values[1] = lval2;
-	values[2] = lval3;
-	l7dlog(level1, lkey, location, values);
+    std::vector<LogString> values(3);
+    values[0] = lval1;
+    values[1] = lval2;
+    values[2] = lval3;
+    l7dlog(level1, lkey, location, values);
 }
 
 
 
 void Logger::removeAllAppenders()
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
-	if (aai != 0)
-	{
-		aai->removeAllAppenders();
-		aai = 0;
-	}
+    if (aai != 0)
+    {
+        aai->removeAllAppenders();
+        aai = 0;
+    }
 }
 
-void Logger::removeAppender(const AppenderPtr& appender)
+void Logger::removeAppender(const AppenderPtr appender)
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
-	if (appender == 0 || aai == 0)
-	{
-		return;
-	}
+    if (appender == 0 || aai == 0)
+    {
+        return;
+    }
 
-	aai->removeAppender(appender);
+    aai->removeAppender(appender);
 }
 
 void Logger::removeAppender(const LogString& name1)
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
-	if (name1.empty() || aai == 0)
-	{
-		return;
-	}
+    if (name1.empty() || aai == 0)
+    {
+        return;
+    }
 
-	aai->removeAppender(name1);
+    aai->removeAppender(name1);
 }
 
 void Logger::setAdditivity(bool additive1)
 {
-	LOCK_W sync(mutex);
-	this->additive = additive1;
+    this->additive = additive1;
 }
 
 void Logger::setHierarchy(spi::LoggerRepository* repository1)
 {
-	this->repository = repository1;
+    this->repository = repository1;
 }
 
-void Logger::setLevel(const LevelPtr& level1)
+void Logger::setLevel(const LevelPtr level1)
 {
-	this->level = level1;
+    this->level = level1;
 }
 
 
 
 LoggerPtr Logger::getLogger(const std::string& name)
 {
-	return LogManager::getLogger(name);
+    return LogManager::getLogger(name);
 }
 
 
 LoggerPtr Logger::getLogger(const char* const name)
 {
-	return LogManager::getLogger(name);
+    return LogManager::getLogger(name);
 }
 
 
 
 LoggerPtr Logger::getRootLogger()
 {
-	return LogManager::getRootLogger();
+    return LogManager::getRootLogger();
 }
 
 LoggerPtr Logger::getLoggerLS(const LogString& name,
-	const spi::LoggerFactoryPtr& factory)
+                              const spi::LoggerFactoryPtr& factory)
 {
-	return LogManager::getLoggerLS(name, factory);
+    return LogManager::getLoggerLS(name, factory);
 }
 
 void Logger::getName(std::string& rv) const
 {
-	Transcoder::encode(name, rv);
+    Transcoder::encode(name, rv);
 }
 
 
 void Logger::trace(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isTraceEnabled())
-	{
-		forcedLog(log4cxx::Level::getTrace(), msg, location);
-	}
+    if (isTraceEnabled())
+    {
+        forcedLog(log4cxx::Level::getTrace(), msg, location);
+    }
 }
 
 
 void Logger::trace(const std::string& msg) const
 {
-	if (isTraceEnabled())
-	{
-		forcedLog(log4cxx::Level::getTrace(), msg);
-	}
+    if (isTraceEnabled())
+    {
+        forcedLog(log4cxx::Level::getTrace(), msg);
+    }
 }
 
 void Logger::debug(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isDebugEnabled())
-	{
-		forcedLog(log4cxx::Level::getDebug(), msg, location);
-	}
+    if (isDebugEnabled())
+    {
+        forcedLog(log4cxx::Level::getDebug(), msg, location);
+    }
 }
 
 void Logger::debug(const std::string& msg) const
 {
-	if (isDebugEnabled())
-	{
-		forcedLog(log4cxx::Level::getDebug(), msg);
-	}
+    if (isDebugEnabled())
+    {
+        forcedLog(log4cxx::Level::getDebug(), msg);
+    }
 }
 
 
 void Logger::error(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isErrorEnabled())
-	{
-		forcedLog(log4cxx::Level::getError(), msg, location);
-	}
+    if (isErrorEnabled())
+    {
+        forcedLog(log4cxx::Level::getError(), msg, location);
+    }
 }
 
 
 void Logger::error(const std::string& msg) const
 {
-	if (isErrorEnabled())
-	{
-		forcedLog(log4cxx::Level::getError(), msg);
-	}
+    if (isErrorEnabled())
+    {
+        forcedLog(log4cxx::Level::getError(), msg);
+    }
 }
 
 void Logger::fatal(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isFatalEnabled())
-	{
-		forcedLog(log4cxx::Level::getFatal(), msg, location);
-	}
+    if (isFatalEnabled())
+    {
+        forcedLog(log4cxx::Level::getFatal(), msg, location);
+    }
 }
 
 void Logger::fatal(const std::string& msg) const
 {
-	if (isFatalEnabled())
-	{
-		forcedLog(log4cxx::Level::getFatal(), msg);
-	}
+    if (isFatalEnabled())
+    {
+        forcedLog(log4cxx::Level::getFatal(), msg);
+    }
 }
 
 void Logger::info(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isInfoEnabled())
-	{
-		forcedLog(log4cxx::Level::getInfo(), msg, location);
-	}
+    if (isInfoEnabled())
+    {
+        forcedLog(log4cxx::Level::getInfo(), msg, location);
+    }
 }
 
 void Logger::info(const std::string& msg) const
 {
-	if (isInfoEnabled())
-	{
-		forcedLog(log4cxx::Level::getInfo(), msg);
-	}
+    if (isInfoEnabled())
+    {
+        forcedLog(log4cxx::Level::getInfo(), msg);
+    }
 }
 
 void Logger::log(const LevelPtr& level1, const std::string& message,
-	const log4cxx::spi::LocationInfo& location) const
+                 const log4cxx::spi::LocationInfo& location) const
 {
-	if (isEnabledFor(level1))
-	{
-		forcedLog(level1, message, location);
-	}
+    if (isEnabledFor(level1))
+    {
+        forcedLog(level1, message, location);
+    }
 }
 
 void Logger::log(const LevelPtr& level1, const std::string& message) const
 {
-	if (isEnabledFor(level1))
-	{
-		forcedLog(level1, message);
-	}
+    if (isEnabledFor(level1))
+    {
+        forcedLog(level1, message);
+    }
 }
 
 void Logger::logLS(const LevelPtr& level1, const LogString& message,
-	const log4cxx::spi::LocationInfo& location) const
+                   const log4cxx::spi::LocationInfo& location) const
 {
-	if (isEnabledFor(level1))
-	{
-		forcedLogLS(level1, message, location);
-	}
+    if (isEnabledFor(level1))
+    {
+        forcedLogLS(level1, message, location);
+    }
 }
 
 void Logger::warn(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isWarnEnabled())
-	{
-		forcedLog(log4cxx::Level::getWarn(), msg, location);
-	}
+    if (isWarnEnabled())
+    {
+        forcedLog(log4cxx::Level::getWarn(), msg, location);
+    }
 }
 
 void Logger::warn(const std::string& msg) const
 {
-	if (isWarnEnabled())
-	{
-		forcedLog(log4cxx::Level::getWarn(), msg);
-	}
+    if (isWarnEnabled())
+    {
+        forcedLog(log4cxx::Level::getWarn(), msg);
+    }
 }
 
 LoggerPtr Logger::getLoggerLS(const LogString& name)
 {
-	return LogManager::getLoggerLS(name);
+    return LogManager::getLoggerLS(name);
 }
 
 
@@ -663,150 +675,150 @@
 
 #if LOG4CXX_WCHAR_T_API
 void Logger::forcedLog(const LevelPtr& level1, const std::wstring& message,
-	const LocationInfo& location) const
+                       const LocationInfo& location) const
 {
-	Pool p;
-	LOG4CXX_DECODE_WCHAR(msg, message);
-	LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
-	callAppenders(event, p);
+    Pool p;
+    LOG4CXX_DECODE_WCHAR(msg, message);
+    LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
+    callAppenders(event, p);
 }
 
 void Logger::forcedLog(const LevelPtr& level1, const std::wstring& message) const
 {
-	Pool p;
-	LOG4CXX_DECODE_WCHAR(msg, message);
-	LoggingEventPtr event(new LoggingEvent(name, level1, msg,
-			LocationInfo::getLocationUnavailable()));
-	callAppenders(event, p);
+    Pool p;
+    LOG4CXX_DECODE_WCHAR(msg, message);
+    LoggingEventPtr event(new LoggingEvent(name, level1, msg,
+                                           LocationInfo::getLocationUnavailable()));
+    callAppenders(event, p);
 }
 
 void Logger::getName(std::wstring& rv) const
 {
-	Transcoder::encode(name, rv);
+    Transcoder::encode(name, rv);
 }
 
 LoggerPtr Logger::getLogger(const std::wstring& name)
 {
-	return LogManager::getLogger(name);
+    return LogManager::getLogger(name);
 }
 
 LoggerPtr Logger::getLogger(const wchar_t* const name)
 {
-	return LogManager::getLogger(name);
+    return LogManager::getLogger(name);
 }
 
 void Logger::trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isTraceEnabled())
-	{
-		forcedLog(log4cxx::Level::getTrace(), msg, location);
-	}
+    if (isTraceEnabled())
+    {
+        forcedLog(log4cxx::Level::getTrace(), msg, location);
+    }
 }
 
 
 void Logger::trace(const std::wstring& msg) const
 {
-	if (isTraceEnabled())
-	{
-		forcedLog(log4cxx::Level::getTrace(), msg);
-	}
+    if (isTraceEnabled())
+    {
+        forcedLog(log4cxx::Level::getTrace(), msg);
+    }
 }
 
 void Logger::debug(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isDebugEnabled())
-	{
-		forcedLog(log4cxx::Level::getDebug(), msg, location);
-	}
+    if (isDebugEnabled())
+    {
+        forcedLog(log4cxx::Level::getDebug(), msg, location);
+    }
 }
 
 void Logger::debug(const std::wstring& msg) const
 {
-	if (isDebugEnabled())
-	{
-		forcedLog(log4cxx::Level::getDebug(), msg);
-	}
+    if (isDebugEnabled())
+    {
+        forcedLog(log4cxx::Level::getDebug(), msg);
+    }
 }
 
 void Logger::error(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isErrorEnabled())
-	{
-		forcedLog(log4cxx::Level::getError(), msg, location);
-	}
+    if (isErrorEnabled())
+    {
+        forcedLog(log4cxx::Level::getError(), msg, location);
+    }
 }
 
 void Logger::error(const std::wstring& msg) const
 {
-	if (isErrorEnabled())
-	{
-		forcedLog(log4cxx::Level::getError(), msg);
-	}
+    if (isErrorEnabled())
+    {
+        forcedLog(log4cxx::Level::getError(), msg);
+    }
 }
 
 void Logger::fatal(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isFatalEnabled())
-	{
-		forcedLog(log4cxx::Level::getFatal(), msg, location);
-	}
+    if (isFatalEnabled())
+    {
+        forcedLog(log4cxx::Level::getFatal(), msg, location);
+    }
 }
 
 void Logger::fatal(const std::wstring& msg) const
 {
-	if (isFatalEnabled())
-	{
-		forcedLog(log4cxx::Level::getFatal(), msg);
-	}
+    if (isFatalEnabled())
+    {
+        forcedLog(log4cxx::Level::getFatal(), msg);
+    }
 }
 
 void Logger::info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isInfoEnabled())
-	{
-		forcedLog(log4cxx::Level::getInfo(), msg, location);
-	}
+    if (isInfoEnabled())
+    {
+        forcedLog(log4cxx::Level::getInfo(), msg, location);
+    }
 }
 
 void Logger::info(const std::wstring& msg) const
 {
-	if (isInfoEnabled())
-	{
-		forcedLog(log4cxx::Level::getInfo(), msg);
-	}
+    if (isInfoEnabled())
+    {
+        forcedLog(log4cxx::Level::getInfo(), msg);
+    }
 }
 
 void Logger::log(const LevelPtr& level1, const std::wstring& message,
-	const log4cxx::spi::LocationInfo& location) const
+                 const log4cxx::spi::LocationInfo& location) const
 {
-	if (isEnabledFor(level1))
-	{
-		forcedLog(level1, message, location);
-	}
+    if (isEnabledFor(level1))
+    {
+        forcedLog(level1, message, location);
+    }
 }
 
 void Logger::log(const LevelPtr& level1, const std::wstring& message) const
 {
-	if (isEnabledFor(level1))
-	{
-		forcedLog(level1, message);
-	}
+    if (isEnabledFor(level1))
+    {
+        forcedLog(level1, message);
+    }
 }
 
 void Logger::warn(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isWarnEnabled())
-	{
-		forcedLog(log4cxx::Level::getWarn(), msg, location);
-	}
+    if (isWarnEnabled())
+    {
+        forcedLog(log4cxx::Level::getWarn(), msg, location);
+    }
 }
 
 void Logger::warn(const std::wstring& msg) const
 {
-	if (isWarnEnabled())
-	{
-		forcedLog(log4cxx::Level::getWarn(), msg);
-	}
+    if (isWarnEnabled())
+    {
+        forcedLog(log4cxx::Level::getWarn(), msg);
+    }
 }
 
 #endif
@@ -814,147 +826,147 @@
 
 #if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
 void Logger::forcedLog(const LevelPtr& level1, const std::basic_string<UniChar>& message,
-	const LocationInfo& location) const
+                       const LocationInfo& location) const
 {
-	Pool p;
-	LOG4CXX_DECODE_UNICHAR(msg, message);
-	LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
-	callAppenders(event, p);
+    Pool p;
+    LOG4CXX_DECODE_UNICHAR(msg, message);
+    LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
+    callAppenders(event, p);
 }
 
 void Logger::forcedLog(const LevelPtr& level1, const std::basic_string<UniChar>& message) const
 {
-	Pool p;
-	LOG4CXX_DECODE_UNICHAR(msg, message);
-	LoggingEventPtr event(new LoggingEvent(name, level1, msg,
-			LocationInfo::getLocationUnavailable()));
-	callAppenders(event, p);
+    Pool p;
+    LOG4CXX_DECODE_UNICHAR(msg, message);
+    LoggingEventPtr event(new LoggingEvent(name, level1, msg,
+                                           LocationInfo::getLocationUnavailable()));
+    callAppenders(event, p);
 }
 #endif
 
 #if LOG4CXX_UNICHAR_API
 void Logger::getName(std::basic_string<UniChar>& rv) const
 {
-	Transcoder::encode(name, rv);
+    Transcoder::encode(name, rv);
 }
 
 LoggerPtr Logger::getLogger(const std::basic_string<UniChar>& name)
 {
-	return LogManager::getLogger(name);
+    return LogManager::getLogger(name);
 }
 
 void Logger::trace(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isTraceEnabled())
-	{
-		forcedLog(log4cxx::Level::getTrace(), msg, location);
-	}
+    if (isTraceEnabled())
+    {
+        forcedLog(log4cxx::Level::getTrace(), msg, location);
+    }
 }
 
 
 void Logger::trace(const std::basic_string<UniChar>& msg) const
 {
-	if (isTraceEnabled())
-	{
-		forcedLog(log4cxx::Level::getTrace(), msg);
-	}
+    if (isTraceEnabled())
+    {
+        forcedLog(log4cxx::Level::getTrace(), msg);
+    }
 }
 
 void Logger::debug(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isDebugEnabled())
-	{
-		forcedLog(log4cxx::Level::getDebug(), msg, location);
-	}
+    if (isDebugEnabled())
+    {
+        forcedLog(log4cxx::Level::getDebug(), msg, location);
+    }
 }
 
 void Logger::debug(const std::basic_string<UniChar>& msg) const
 {
-	if (isDebugEnabled())
-	{
-		forcedLog(log4cxx::Level::getDebug(), msg);
-	}
+    if (isDebugEnabled())
+    {
+        forcedLog(log4cxx::Level::getDebug(), msg);
+    }
 }
 
 void Logger::error(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isErrorEnabled())
-	{
-		forcedLog(log4cxx::Level::getError(), msg, location);
-	}
+    if (isErrorEnabled())
+    {
+        forcedLog(log4cxx::Level::getError(), msg, location);
+    }
 }
 
 void Logger::error(const std::basic_string<UniChar>& msg) const
 {
-	if (isErrorEnabled())
-	{
-		forcedLog(log4cxx::Level::getError(), msg);
-	}
+    if (isErrorEnabled())
+    {
+        forcedLog(log4cxx::Level::getError(), msg);
+    }
 }
 
 void Logger::fatal(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isFatalEnabled())
-	{
-		forcedLog(log4cxx::Level::getFatal(), msg, location);
-	}
+    if (isFatalEnabled())
+    {
+        forcedLog(log4cxx::Level::getFatal(), msg, location);
+    }
 }
 
 void Logger::fatal(const std::basic_string<UniChar>& msg) const
 {
-	if (isFatalEnabled())
-	{
-		forcedLog(log4cxx::Level::getFatal(), msg);
-	}
+    if (isFatalEnabled())
+    {
+        forcedLog(log4cxx::Level::getFatal(), msg);
+    }
 }
 
 void Logger::info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isInfoEnabled())
-	{
-		forcedLog(log4cxx::Level::getInfo(), msg, location);
-	}
+    if (isInfoEnabled())
+    {
+        forcedLog(log4cxx::Level::getInfo(), msg, location);
+    }
 }
 
 void Logger::info(const std::basic_string<UniChar>& msg) const
 {
-	if (isInfoEnabled())
-	{
-		forcedLog(log4cxx::Level::getInfo(), msg);
-	}
+    if (isInfoEnabled())
+    {
+        forcedLog(log4cxx::Level::getInfo(), msg);
+    }
 }
 
 void Logger::log(const LevelPtr& level1, const std::basic_string<UniChar>& message,
-	const log4cxx::spi::LocationInfo& location) const
+                 const log4cxx::spi::LocationInfo& location) const
 {
-	if (isEnabledFor(level1))
-	{
-		forcedLog(level1, message, location);
-	}
+    if (isEnabledFor(level1))
+    {
+        forcedLog(level1, message, location);
+    }
 }
 
 void Logger::log(const LevelPtr& level1, const std::basic_string<UniChar>& message) const
 {
-	if (isEnabledFor(level1))
-	{
-		forcedLog(level1, message);
-	}
+    if (isEnabledFor(level1))
+    {
+        forcedLog(level1, message);
+    }
 }
 
 void Logger::warn(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isWarnEnabled())
-	{
-		forcedLog(log4cxx::Level::getWarn(), msg, location);
-	}
+    if (isWarnEnabled())
+    {
+        forcedLog(log4cxx::Level::getWarn(), msg, location);
+    }
 }
 
 void Logger::warn(const std::basic_string<UniChar>& msg) const
 {
-	if (isWarnEnabled())
-	{
-		forcedLog(log4cxx::Level::getWarn(), msg);
-	}
+    if (isWarnEnabled())
+    {
+        forcedLog(log4cxx::Level::getWarn(), msg);
+    }
 }
 
 #endif
@@ -962,145 +974,145 @@
 
 #if LOG4CXX_CFSTRING_API
 void Logger::forcedLog(const LevelPtr& level1, const CFStringRef& message,
-	const LocationInfo& location) const
+                       const LocationInfo& location) const
 {
-	Pool p;
-	LOG4CXX_DECODE_CFSTRING(msg, message);
-	LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
-	callAppenders(event, p);
+    Pool p;
+    LOG4CXX_DECODE_CFSTRING(msg, message);
+    LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
+    callAppenders(event, p);
 }
 
 void Logger::forcedLog(const LevelPtr& level1, const CFStringRef& message) const
 {
-	Pool p;
-	LOG4CXX_DECODE_CFSTRING(msg, message);
-	LoggingEventPtr event(new LoggingEvent(name, level1, msg,
-			LocationInfo::getLocationUnavailable()));
-	callAppenders(event, p);
+    Pool p;
+    LOG4CXX_DECODE_CFSTRING(msg, message);
+    LoggingEventPtr event(new LoggingEvent(name, level1, msg,
+                                           LocationInfo::getLocationUnavailable()));
+    callAppenders(event, p);
 }
 
 void Logger::getName(CFStringRef& rv) const
 {
-	rv = Transcoder::encode(name);
+    rv = Transcoder::encode(name);
 }
 
 LoggerPtr Logger::getLogger(const CFStringRef& name)
 {
-	return LogManager::getLogger(name);
+    return LogManager::getLogger(name);
 }
 
 void Logger::trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isTraceEnabled())
-	{
-		forcedLog(log4cxx::Level::getTrace(), msg, location);
-	}
+    if (isTraceEnabled())
+    {
+        forcedLog(log4cxx::Level::getTrace(), msg, location);
+    }
 }
 
 
 void Logger::trace(const CFStringRef& msg) const
 {
-	if (isTraceEnabled())
-	{
-		forcedLog(log4cxx::Level::getTrace(), msg);
-	}
+    if (isTraceEnabled())
+    {
+        forcedLog(log4cxx::Level::getTrace(), msg);
+    }
 }
 
 void Logger::debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isDebugEnabled())
-	{
-		forcedLog(log4cxx::Level::getDebug(), msg, location);
-	}
+    if (isDebugEnabled())
+    {
+        forcedLog(log4cxx::Level::getDebug(), msg, location);
+    }
 }
 
 void Logger::debug(const CFStringRef& msg) const
 {
-	if (isDebugEnabled())
-	{
-		forcedLog(log4cxx::Level::getDebug(), msg);
-	}
+    if (isDebugEnabled())
+    {
+        forcedLog(log4cxx::Level::getDebug(), msg);
+    }
 }
 
 void Logger::error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isErrorEnabled())
-	{
-		forcedLog(log4cxx::Level::getError(), msg, location);
-	}
+    if (isErrorEnabled())
+    {
+        forcedLog(log4cxx::Level::getError(), msg, location);
+    }
 }
 
 void Logger::error(const CFStringRef& msg) const
 {
-	if (isErrorEnabled())
-	{
-		forcedLog(log4cxx::Level::getError(), msg);
-	}
+    if (isErrorEnabled())
+    {
+        forcedLog(log4cxx::Level::getError(), msg);
+    }
 }
 
 void Logger::fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isFatalEnabled())
-	{
-		forcedLog(log4cxx::Level::getFatal(), msg, location);
-	}
+    if (isFatalEnabled())
+    {
+        forcedLog(log4cxx::Level::getFatal(), msg, location);
+    }
 }
 
 void Logger::fatal(const CFStringRef& msg) const
 {
-	if (isFatalEnabled())
-	{
-		forcedLog(log4cxx::Level::getFatal(), msg);
-	}
+    if (isFatalEnabled())
+    {
+        forcedLog(log4cxx::Level::getFatal(), msg);
+    }
 }
 
 void Logger::info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isInfoEnabled())
-	{
-		forcedLog(log4cxx::Level::getInfo(), msg, location);
-	}
+    if (isInfoEnabled())
+    {
+        forcedLog(log4cxx::Level::getInfo(), msg, location);
+    }
 }
 
 void Logger::info(const CFStringRef& msg) const
 {
-	if (isInfoEnabled())
-	{
-		forcedLog(log4cxx::Level::getInfo(), msg);
-	}
+    if (isInfoEnabled())
+    {
+        forcedLog(log4cxx::Level::getInfo(), msg);
+    }
 }
 
 void Logger::log(const LevelPtr& level1, const CFStringRef& message,
-	const log4cxx::spi::LocationInfo& location) const
+                 const log4cxx::spi::LocationInfo& location) const
 {
-	if (isEnabledFor(level1))
-	{
-		forcedLog(level1, message, location);
-	}
+    if (isEnabledFor(level1))
+    {
+        forcedLog(level1, message, location);
+    }
 }
 
 void Logger::log(const LevelPtr& level1, const CFStringRef& message) const
 {
-	if (isEnabledFor(level1))
-	{
-		forcedLog(level1, message);
-	}
+    if (isEnabledFor(level1))
+    {
+        forcedLog(level1, message);
+    }
 }
 
 void Logger::warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
 {
-	if (isWarnEnabled())
-	{
-		forcedLog(log4cxx::Level::getWarn(), msg, location);
-	}
+    if (isWarnEnabled())
+    {
+        forcedLog(log4cxx::Level::getWarn(), msg, location);
+    }
 }
 
 void Logger::warn(const CFStringRef& msg) const
 {
-	if (isWarnEnabled())
-	{
-		forcedLog(log4cxx::Level::getWarn(), msg);
-	}
+    if (isWarnEnabled())
+    {
+        forcedLog(log4cxx::Level::getWarn(), msg);
+    }
 }
 
 #endif
diff --git a/src/main/cpp/loggerpatternconverter.cpp b/src/main/cpp/loggerpatternconverter.cpp
index f9c0246..d058b97 100644
--- a/src/main/cpp/loggerpatternconverter.cpp
+++ b/src/main/cpp/loggerpatternconverter.cpp
@@ -46,7 +46,7 @@
 		return def;
 	}
 
-	return new LoggerPatternConverter(options);
+    return PatternConverterPtr(new LoggerPatternConverter(options));
 }
 
 void LoggerPatternConverter::format(
diff --git a/src/main/cpp/loggingeventpatternconverter.cpp b/src/main/cpp/loggingeventpatternconverter.cpp
index 60ab32b..33c98e7 100644
--- a/src/main/cpp/loggingeventpatternconverter.cpp
+++ b/src/main/cpp/loggingeventpatternconverter.cpp
@@ -40,7 +40,7 @@
 	LogString& output,
 	log4cxx::helpers::Pool& p) const
 {
-	LoggingEventPtr le(obj);
+    LoggingEventPtr le = log4cxx::cast<LoggingEvent>(obj);
 
 	if (le != NULL)
 	{
diff --git a/src/main/cpp/loglog.cpp b/src/main/cpp/loglog.cpp
index 7b1e867..b0bf27d 100644
--- a/src/main/cpp/loglog.cpp
+++ b/src/main/cpp/loglog.cpp
@@ -23,19 +23,16 @@
 	#define LOG4CXX 1
 #endif
 #include <log4cxx/private/log4cxx_private.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/aprinitializer.h>
 #include <log4cxx/helpers/systemerrwriter.h>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
 
-LogLog::LogLog() : mutex(APRInitializer::getRootPool())
+LogLog::LogLog()
 {
-	synchronized sync(mutex);
-
-	debugEnabled	= false;
-	quietMode		= false;
+	debugEnabled    = false;
+	quietMode       = false;
 }
 
 LogLog& LogLog::getInstance()
@@ -47,7 +44,7 @@
 
 void LogLog::setInternalDebugging(bool debugEnabled1)
 {
-	synchronized sync(getInstance().mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(getInstance().mutex);
 
 	getInstance().debugEnabled = debugEnabled1;
 }
@@ -59,7 +56,7 @@
 		return;
 	}
 
-	synchronized sync(getInstance().mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(getInstance().mutex);
 
 	emit(msg);
 }
@@ -71,47 +68,47 @@
 		return;
 	}
 
-	synchronized sync(getInstance().mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(getInstance().mutex);
 
-	debug(msg);
+    emit(msg);
 	emit(e);
 }
 
 
 void LogLog::error(const LogString& msg)
 {
-	synchronized sync(getInstance().mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(getInstance().mutex);
 
 	emit(msg);
 }
 
 void LogLog::error(const LogString& msg, const std::exception& e)
 {
-	synchronized sync(getInstance().mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(getInstance().mutex);
 
-	error(msg);
+    emit(msg);
 	emit(e);
 }
 
 void LogLog::setQuietMode(bool quietMode1)
 {
-	synchronized sync(getInstance().mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(getInstance().mutex);
 
 	getInstance().quietMode = quietMode1;
 }
 
 void LogLog::warn(const LogString& msg)
 {
-	synchronized sync(getInstance().mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(getInstance().mutex);
 
 	emit(msg);
 }
 
 void LogLog::warn(const LogString& msg, const std::exception& e)
 {
-	synchronized sync(getInstance().mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(getInstance().mutex);
 
-	warn(msg);
+    emit(msg);
 	emit(e);
 }
 
diff --git a/src/main/cpp/logmanager.cpp b/src/main/cpp/logmanager.cpp
index 41c1155..7797900 100644
--- a/src/main/cpp/logmanager.cpp
+++ b/src/main/cpp/logmanager.cpp
@@ -32,8 +32,6 @@
 #include <log4cxx/helpers/optionconverter.h>
 #include <log4cxx/helpers/loglog.h>
 
-#include <apr_general.h>
-
 #include <log4cxx/spi/loggingevent.h>
 #include <log4cxx/file.h>
 #include <log4cxx/helpers/transcoder.h>
@@ -49,17 +47,22 @@
 IMPLEMENT_LOG4CXX_OBJECT(DefaultRepositorySelector)
 
 void* LogManager::guard = 0;
+spi::RepositorySelectorPtr LogManager::repositorySelector;
 
 
-
-RepositorySelectorPtr& LogManager::getRepositorySelector()
+RepositorySelectorPtr LogManager::getRepositorySelector()
 {
 	//
 	//     call to initialize APR and trigger "start" of logging clock
 	//
-	APRInitializer::initialize();
-	static spi::RepositorySelectorPtr selector;
-	return selector;
+    APRInitializer::initialize();
+    if (!repositorySelector)
+    {
+        LoggerRepositoryPtr hierarchy(new Hierarchy());
+        RepositorySelectorPtr selector(new DefaultRepositorySelector(hierarchy));
+        repositorySelector = selector;
+    }
+    return repositorySelector;
 }
 
 void LogManager::setRepositorySelector(spi::RepositorySelectorPtr selector,
@@ -81,15 +84,8 @@
 
 
 
-LoggerRepositoryPtr& LogManager::getLoggerRepository()
+LoggerRepositoryPtr LogManager::getLoggerRepository()
 {
-	if (getRepositorySelector() == 0)
-	{
-		LoggerRepositoryPtr hierarchy(new Hierarchy());
-		RepositorySelectorPtr selector(new DefaultRepositorySelector(hierarchy));
-		getRepositorySelector() = selector;
-	}
-
 	return getRepositorySelector()->getLoggerRepository();
 }
 
@@ -211,6 +207,7 @@
 
 void LogManager::shutdown()
 {
+    LoggerRepositoryPtr repPtr = getLoggerRepository();
 	getLoggerRepository()->shutdown();
 }
 
diff --git a/src/main/cpp/mutex.cpp b/src/main/cpp/mutex.cpp
deleted file mode 100644
index 25344a7..0000000
--- a/src/main/cpp/mutex.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/exception.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/pool.h>
-#include <apr_thread_mutex.h>
-#include <apr_thread_rwlock.h>
-#include <assert.h>
-#if !defined(LOG4CXX)
-	#define LOG4CXX 1
-#endif
-#include <log4cxx/helpers/aprinitializer.h>
-
-#if defined(NON_BLOCKING)
-
-	#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
-		#include <windows.h>
-	#else
-		// POSIX
-		#include <semaphore.h>
-	#endif
-
-#endif // NON_BLOCKING
-
-using namespace log4cxx::helpers;
-using namespace log4cxx;
-
-
-Mutex::Mutex(Pool& p)
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_mutex_create(&mutex,
-			APR_THREAD_MUTEX_NESTED, p.getAPRPool());
-
-	if (stat != APR_SUCCESS)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-Mutex::Mutex(apr_pool_t* p)
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_mutex_create(&mutex,
-			APR_THREAD_MUTEX_NESTED, p);
-
-	if (stat != APR_SUCCESS)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-
-Mutex::~Mutex()
-{
-#if APR_HAS_THREADS
-
-	// LOGCXX-322
-	if (APRInitializer::isDestructed)
-	{
-		return;
-	}
-
-	apr_thread_mutex_destroy(mutex);
-#endif
-}
-
-apr_thread_mutex_t* Mutex::getAPRMutex() const
-{
-	return mutex;
-}
-
-#if defined(RW_MUTEX)
-
-RWMutex::RWMutex(Pool& p)
-	: id((apr_os_thread_t) -1)
-	, count(0)
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_rwlock_create(&mutex,
-			p.getAPRPool());
-
-	if (stat != APR_SUCCESS)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-RWMutex::RWMutex(apr_pool_t* p)
-	: id((apr_os_thread_t) -1)
-	, count(0)
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_rwlock_create(&mutex, p);
-
-	if (stat != APR_SUCCESS)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-
-RWMutex::~RWMutex()
-{
-#if APR_HAS_THREADS
-	apr_thread_rwlock_destroy(mutex);
-#endif
-}
-
-void RWMutex::rdLock() const
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_rwlock_rdlock(mutex);
-#endif
-}
-
-void RWMutex::rdUnlock() const
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_rwlock_unlock(mutex);
-#endif
-}
-
-void RWMutex::wrLock() const
-{
-#if APR_HAS_THREADS
-	apr_os_thread_t self = apr_os_thread_current();
-
-	if (id == self)
-	{
-		++count;
-	}
-	else
-	{
-		apr_status_t stat = apr_thread_rwlock_wrlock(mutex);
-		id = self;
-		count = 1;
-	}
-
-#endif
-}
-
-void RWMutex::wrUnlock() const
-{
-#if APR_HAS_THREADS
-
-	if (--count == 0)
-	{
-		id = (apr_os_thread_t) -1; // id_ = "not a thread"
-		apr_status_t stat = apr_thread_rwlock_unlock(mutex);
-	}
-	else
-	{
-	}
-
-#endif
-}
-
-#endif // RW_MUTEX
-
-#if defined(NON_BLOCKING)
-
-#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
-
-namespace log4cxx
-{
-namespace helpers
-{
-struct SemaphoreImpl
-{
-	HANDLE semaphore;
-};
-}
-}
-
-static const LONG cMax = 10000; // arbitrary high value
-
-Semaphore::Semaphore(log4cxx::helpers::Pool& p)
-	: impl(nullptr)
-{
-#if APR_HAS_THREADS
-	impl = (SemaphoreImpl*)p.palloc(sizeof(SemaphoreImpl));
-
-	if (nullptr == impl)
-	{
-		throw MutexException(APR_ENOMEM);
-	}
-
-	impl->semaphore = CreateSemaphore(
-			NULL,  // default security attributes
-			0,     // initial count
-			cMax,  // maximum count
-			NULL); // unnamed semaphore
-
-	if (impl->semaphore == NULL)
-	{
-		throw MutexException(APR_ENOSHMAVAIL);
-	}
-
-#endif
-}
-
-Semaphore::~Semaphore()
-{
-#if APR_HAS_THREADS
-
-	if (impl && impl->semaphore)
-	{
-		CloseHandle(impl->semaphore);
-	}
-
-#endif
-}
-
-void Semaphore::await() const
-{
-#if APR_HAS_THREADS
-	DWORD dwWaitResult = WaitForSingleObject(impl->semaphore, INFINITE);
-
-	if (stat != 0)
-	{
-		throw MutexException(1);
-	}
-
-#endif
-}
-
-void Semaphore::signalAll() const
-{
-#if APR_HAS_THREADS
-	BOOL stat = ReleaseSemaphore(impl->semaphore, 1, NULL);
-
-	if (!stat)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-#else
-// POSIX
-
-namespace log4cxx
-{
-namespace helpers
-{
-struct SemaphoreImpl
-{
-	sem_t semaphore;
-};
-}
-}
-
-Semaphore::Semaphore(log4cxx::helpers::Pool& p)
-	: impl(nullptr)
-{
-#if APR_HAS_THREADS
-	impl = (SemaphoreImpl*)p.palloc(sizeof(SemaphoreImpl));
-
-	if (nullptr == impl)
-	{
-		throw MutexException(APR_ENOMEM);
-	}
-
-	int stat = sem_init(&impl->semaphore, 0, 0);
-
-	if (stat != 0)
-	{
-		throw MutexException(APR_ENOSHMAVAIL);
-	}
-
-#endif
-}
-
-Semaphore::~Semaphore()
-{
-#if APR_HAS_THREADS
-
-	if (impl)
-	{
-		int stat = sem_destroy(&impl->semaphore);
-	}
-
-#endif
-}
-
-void Semaphore::await() const
-{
-#if APR_HAS_THREADS
-	int stat = sem_wait(&impl->semaphore);
-
-	if (stat != 0)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-void Semaphore::signalAll() const
-{
-#if APR_HAS_THREADS
-	int stat = sem_post(&impl->semaphore);
-
-	if (stat != 0)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-#endif // POSIX
-
-#endif // NON_BLOCKING
diff --git a/src/main/cpp/nameabbreviator.cpp b/src/main/cpp/nameabbreviator.cpp
index 02f56fc..fbea7b9 100644
--- a/src/main/cpp/nameabbreviator.cpp
+++ b/src/main/cpp/nameabbreviator.cpp
@@ -291,7 +291,7 @@
 		//
 		if (i == trimmed.length())
 		{
-			return new MaxElementAbbreviator(StringHelper::toInt(trimmed));
+            return NameAbbreviatorPtr(new MaxElementAbbreviator(StringHelper::toInt(trimmed)));
 		}
 
 		std::vector<PatternAbbreviatorFragment> fragments;
diff --git a/src/main/cpp/objectimpl.cpp b/src/main/cpp/objectimpl.cpp
deleted file mode 100644
index 47515a4..0000000
--- a/src/main/cpp/objectimpl.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/objectimpl.h>
-#include <apr_atomic.h>
-#if !defined(LOG4CXX)
-	#define LOG4CXX 1
-#endif
-#include <log4cxx/helpers/aprinitializer.h>
-
-using namespace log4cxx::helpers;
-
-ObjectImpl::ObjectImpl() : ref( 0 )
-{
-	log4cxx::helpers::APRInitializer::initialize();
-}
-
-ObjectImpl::~ObjectImpl()
-{
-}
-
-void ObjectImpl::addRef() const
-{
-	apr_atomic_inc32( & ref );
-}
-
-void ObjectImpl::releaseRef() const
-{
-	if ( apr_atomic_dec32( & ref ) == 0 )
-	{
-		delete this;
-	}
-}
diff --git a/src/main/cpp/objectoutputstream.cpp b/src/main/cpp/objectoutputstream.cpp
index 017ad12..6beb1a2 100644
--- a/src/main/cpp/objectoutputstream.cpp
+++ b/src/main/cpp/objectoutputstream.cpp
@@ -23,7 +23,6 @@
 #include <log4cxx/helpers/bytebuffer.h>
 #include <log4cxx/helpers/outputstream.h>
 #include <log4cxx/helpers/charsetencoder.h>
-#include "apr_pools.h"
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
diff --git a/src/main/cpp/objectptr.cpp b/src/main/cpp/objectptr.cpp
deleted file mode 100644
index 09e57e4..0000000
--- a/src/main/cpp/objectptr.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <log4cxx/helpers/objectptr.h>
-#include <log4cxx/helpers/exception.h>
-#include <apr_atomic.h>
-
-using namespace log4cxx::helpers;
-
-ObjectPtrBase::ObjectPtrBase()
-{
-}
-
-ObjectPtrBase::~ObjectPtrBase()
-{
-}
-
-void ObjectPtrBase::checkNull(const int& null)
-{
-	if (null != 0)
-	{
-		throw IllegalArgumentException(LOG4CXX_STR("Attempt to set pointer to a non-zero numeric value."));
-	}
-}
-
-void* ObjectPtrBase::exchange(void** destination, void* newValue)
-{
-#if _WIN32 && (!defined(_MSC_VER) || _MSC_VER >= 1300)
-	return InterlockedExchangePointer(destination, newValue);
-#elif APR_SIZEOF_VOIDP == 4
-	return (void*) apr_atomic_xchg32((volatile apr_uint32_t*) destination,
-			(apr_uint32_t) newValue);
-#else
-	void* oldValue = *destination;
-	*destination = newValue;
-	return oldValue;
-#endif
-}
diff --git a/src/main/cpp/obsoleterollingfileappender.cpp b/src/main/cpp/obsoleterollingfileappender.cpp
index f069115..ff14602 100644
--- a/src/main/cpp/obsoleterollingfileappender.cpp
+++ b/src/main/cpp/obsoleterollingfileappender.cpp
@@ -39,9 +39,9 @@
 		{
 			return LOG4CXX_STR("org.apache.log4j.RollingFileAppender");
 		}
-		virtual ObjectPtr newInstance() const
+        virtual Object* newInstance() const
 		{
-			return new RollingFileAppender();
+            return new RollingFileAppender();
 		}
 };
 }
diff --git a/src/main/cpp/odbcappender.cpp b/src/main/cpp/odbcappender.cpp
index 218df13..d95a77c 100644
--- a/src/main/cpp/odbcappender.cpp
+++ b/src/main/cpp/odbcappender.cpp
@@ -344,11 +344,13 @@
 
 	if (getLayout() == 0)
 	{
-		this->setLayout(new PatternLayout(s));
+        this->setLayout(PatternLayoutPtr(new PatternLayout(s)));
 	}
 	else
 	{
-		PatternLayoutPtr patternLayout = this->getLayout();
+        PatternLayoutPtr patternLayout;
+        LayoutPtr asLayout = this->getLayout();
+        patternLayout = log4cxx::cast<PatternLayout>(asLayout);
 
 		if (patternLayout != 0)
 		{
diff --git a/src/main/cpp/onlyonceerrorhandler.cpp b/src/main/cpp/onlyonceerrorhandler.cpp
index 96e73e1..0671aa7 100644
--- a/src/main/cpp/onlyonceerrorhandler.cpp
+++ b/src/main/cpp/onlyonceerrorhandler.cpp
@@ -32,16 +32,6 @@
 {
 }
 
-void OnlyOnceErrorHandler::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void OnlyOnceErrorHandler::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
 void OnlyOnceErrorHandler::setLogger(const LoggerPtr&)
 {
 }
diff --git a/src/main/cpp/optionconverter.cpp b/src/main/cpp/optionconverter.cpp
index 71a1513..5791c0b 100644
--- a/src/main/cpp/optionconverter.cpp
+++ b/src/main/cpp/optionconverter.cpp
@@ -355,7 +355,7 @@
 		try
 		{
 			const Class& classObj = Loader::loadClass(className);
-			ObjectPtr newObject =  classObj.newInstance();
+            ObjectPtr newObject =  ObjectPtr(classObj.newInstance());
 
 			if (!newObject->instanceof(superClass))
 			{
@@ -375,7 +375,7 @@
 }
 
 void OptionConverter::selectAndConfigure(const File& configFileName,
-	const LogString& _clazz, spi::LoggerRepositoryPtr& hierarchy)
+    const LogString& _clazz, spi::LoggerRepositoryPtr hierarchy)
 {
 	ConfiguratorPtr configurator;
 	LogString clazz = _clazz;
@@ -394,9 +394,9 @@
 	if (!clazz.empty())
 	{
 		LogLog::debug(LOG4CXX_STR("Preferred configurator class: ") + clazz);
-		configurator = instantiateByClassName(clazz,
-				Configurator::getStaticClass(),
-				0);
+        const Class& clazzObj = Loader::loadClass(clazz);
+        ObjectPtr obj = ObjectPtr(clazzObj.newInstance());
+        configurator = log4cxx::cast<Configurator>(obj);
 
 		if (configurator == 0)
 		{
@@ -407,7 +407,7 @@
 	}
 	else
 	{
-		configurator = new PropertyConfigurator();
+        configurator = ConfiguratorPtr(new PropertyConfigurator());
 	}
 
 	configurator->doConfigure(configFileName, hierarchy);
diff --git a/src/main/cpp/patternlayout.cpp b/src/main/cpp/patternlayout.cpp
index e3bd201..95c2655 100644
--- a/src/main/cpp/patternlayout.cpp
+++ b/src/main/cpp/patternlayout.cpp
@@ -131,7 +131,8 @@
 		converterIter != converters.end();
 		converterIter++)
 	{
-		LoggingEventPatternConverterPtr eventConverter(*converterIter);
+        LoggingEventPatternConverterPtr eventConverter =
+                log4cxx::cast<LoggingEventPatternConverter>(*converterIter);
 
 		if (eventConverter != NULL)
 		{
diff --git a/src/main/cpp/patternparser.cpp b/src/main/cpp/patternparser.cpp
index 6e45fde..bf18755 100644
--- a/src/main/cpp/patternparser.cpp
+++ b/src/main/cpp/patternparser.cpp
@@ -179,10 +179,10 @@
 				switch (c)
 				{
 					case 0x2D: // '-'
-						formattingInfo =
+                        formattingInfo = FormattingInfoPtr(
 							new FormattingInfo(
 							true, formattingInfo->getMinLength(),
-							formattingInfo->getMaxLength());
+                            formattingInfo->getMaxLength()));
 
 						break;
 
@@ -195,10 +195,10 @@
 
 						if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */))
 						{
-							formattingInfo =
+                            formattingInfo = FormattingInfoPtr(
 								new FormattingInfo(
 								formattingInfo->isLeftAligned(), c - 0x30 /* '0' */,
-								formattingInfo->getMaxLength());
+                                formattingInfo->getMaxLength()));
 							state = MIN_STATE;
 						}
 						else
@@ -225,11 +225,11 @@
 
 				if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */))
 				{
-					formattingInfo =
+                    formattingInfo = FormattingInfoPtr(
 						new FormattingInfo(
 						formattingInfo->isLeftAligned(),
 						(formattingInfo->getMinLength() * 10) + (c - 0x30 /* '0' */),
-						formattingInfo->getMaxLength());
+                        formattingInfo->getMaxLength()));
 				}
 				else if (c == 0x2E /* '.' */)
 				{
@@ -256,10 +256,10 @@
 
 				if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */))
 				{
-					formattingInfo =
+                    formattingInfo = FormattingInfoPtr(
 						new FormattingInfo(
 						formattingInfo->isLeftAligned(), formattingInfo->getMinLength(),
-						c - 0x30 /* '0' */);
+                        c - 0x30 /* '0' */));
 					state = MAX_STATE;
 				}
 				else
@@ -276,10 +276,10 @@
 
 				if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */))
 				{
-					formattingInfo =
+                    formattingInfo = FormattingInfoPtr(
 						new FormattingInfo(
 						formattingInfo->isLeftAligned(), formattingInfo->getMinLength(),
-						(formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */));
+                        (formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */)));
 				}
 				else
 				{
@@ -332,9 +332,8 @@
 	}
 
 	LogLog::error(LogString(LOG4CXX_STR("Unrecognized format specifier ")) + converterId);
-	ObjectPtr converterObj;
 
-	return converterObj;
+    return PatternConverterPtr();
 }
 
 size_t PatternParser::finalizeConverter(
diff --git a/src/main/cpp/propertyconfigurator.cpp b/src/main/cpp/propertyconfigurator.cpp
index 905f968..615d33a 100644
--- a/src/main/cpp/propertyconfigurator.cpp
+++ b/src/main/cpp/propertyconfigurator.cpp
@@ -32,12 +32,9 @@
 #include <log4cxx/config/propertysetter.h>
 #include <log4cxx/spi/loggerrepository.h>
 #include <log4cxx/helpers/stringtokenizer.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <apr_file_io.h>
-#include <apr_file_info.h>
-#include <apr_pools.h>
 #include <log4cxx/helpers/transcoder.h>
 #include <log4cxx/helpers/fileinputstream.h>
+#include <log4cxx/helpers/loader.h>
 
 #define LOG4CXX 1
 #include <log4cxx/helpers/aprinitializer.h>
@@ -55,21 +52,21 @@
 {
 class PropertyWatchdog  : public FileWatchdog
 {
-	public:
-		PropertyWatchdog(const File& filename) : FileWatchdog(filename)
-		{
-		}
+public:
+    PropertyWatchdog(const File& filename) : FileWatchdog(filename)
+    {
+    }
 
-		/**
-		Call PropertyConfigurator#doConfigure(const String& configFileName,
-		const spi::LoggerRepositoryPtr& hierarchy) with the
-		<code>filename</code> to reconfigure log4cxx.
-		*/
-		void doOnChange()
-		{
-			PropertyConfigurator().doConfigure(file,
-				LogManager::getLoggerRepository());
-		}
+    /**
+    Call PropertyConfigurator#doConfigure(const String& configFileName,
+    const spi::LoggerRepositoryPtr& hierarchy) with the
+    <code>filename</code> to reconfigure log4cxx.
+    */
+    void doOnChange()
+    {
+        PropertyConfigurator().doConfigure(file,
+                                           LogManager::getLoggerRepository());
+    }
 };
 }
 
@@ -80,406 +77,402 @@
 IMPLEMENT_LOG4CXX_OBJECT(PropertyConfigurator)
 
 PropertyConfigurator::PropertyConfigurator()
-	: registry(new std::map<LogString, AppenderPtr>()), loggerFactory(new DefaultLoggerFactory())
+    : registry(new std::map<LogString, AppenderPtr>()), loggerFactory(new DefaultLoggerFactory())
 {
 }
 
 PropertyConfigurator::~PropertyConfigurator()
 {
-	delete registry;
-}
-
-void PropertyConfigurator::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void PropertyConfigurator::releaseRef() const
-{
-	ObjectImpl::releaseRef();
+    delete registry;
 }
 
 void PropertyConfigurator::doConfigure(const File& configFileName,
-	spi::LoggerRepositoryPtr& hierarchy)
+                                       spi::LoggerRepositoryPtr hierarchy)
 {
-	hierarchy->setConfigured(true);
+    hierarchy->setConfigured(true);
 
-	Properties props;
+    Properties props;
 
-	try
-	{
-		InputStreamPtr inputStream = new FileInputStream(configFileName);
-		props.load(inputStream);
-	}
-	catch (const IOException&)
-	{
-		LogLog::error(((LogString) LOG4CXX_STR("Could not read configuration file ["))
-			+ configFileName.getPath() + LOG4CXX_STR("]."));
-		return;
-	}
+    try
+    {
+        InputStreamPtr inputStream = InputStreamPtr( new FileInputStream(configFileName) );
+        props.load(inputStream);
+    }
+    catch (const IOException&)
+    {
+        LogLog::error(((LogString) LOG4CXX_STR("Could not read configuration file ["))
+                      + configFileName.getPath() + LOG4CXX_STR("]."));
+        return;
+    }
 
-	try
-	{
-		doConfigure(props, hierarchy);
-	}
-	catch (const std::exception& ex)
-	{
-		LogLog::error(((LogString) LOG4CXX_STR("Could not parse configuration file ["))
-			+ configFileName.getPath() + LOG4CXX_STR("]."), ex);
-	}
+    try
+    {
+        doConfigure(props, hierarchy);
+    }
+    catch (const std::exception& ex)
+    {
+        LogLog::error(((LogString) LOG4CXX_STR("Could not parse configuration file ["))
+                      + configFileName.getPath() + LOG4CXX_STR("]."), ex);
+    }
 }
 
 void PropertyConfigurator::configure(const File& configFilename)
 {
-	PropertyConfigurator().doConfigure(configFilename, LogManager::getLoggerRepository());
+    PropertyConfigurator().doConfigure(configFilename, LogManager::getLoggerRepository());
 }
 
 void PropertyConfigurator::configure(helpers::Properties& properties)
 {
-	PropertyConfigurator().doConfigure(properties, LogManager::getLoggerRepository());
+    PropertyConfigurator().doConfigure(properties, LogManager::getLoggerRepository());
 }
 
 #if APR_HAS_THREADS
 void PropertyConfigurator::configureAndWatch(const File& configFilename)
 {
-	configureAndWatch(configFilename, FileWatchdog::DEFAULT_DELAY);
+    configureAndWatch(configFilename, FileWatchdog::DEFAULT_DELAY);
 }
 
 
 
 void PropertyConfigurator::configureAndWatch(
-	const File& configFilename, long delay)
+    const File& configFilename, long delay)
 {
-	if (pdog)
-	{
-		APRInitializer::unregisterCleanup(pdog);
-		delete pdog;
-	}
+    if (pdog)
+    {
+        APRInitializer::unregisterCleanup(pdog);
+        delete pdog;
+    }
 
-	pdog = new PropertyWatchdog(configFilename);
-	APRInitializer::registerCleanup(pdog);
-	pdog->setDelay(delay);
-	pdog->start();
+    pdog = new PropertyWatchdog(configFilename);
+    APRInitializer::registerCleanup(pdog);
+    pdog->setDelay(delay);
+    pdog->start();
 }
 #endif
 
 void PropertyConfigurator::doConfigure(helpers::Properties& properties,
-	spi::LoggerRepositoryPtr& hierarchy)
+                                       spi::LoggerRepositoryPtr hierarchy)
 {
-	hierarchy->setConfigured(true);
+    hierarchy->setConfigured(true);
 
-	static const LogString DEBUG_KEY(LOG4CXX_STR("log4j.debug"));
-	LogString value(properties.getProperty(DEBUG_KEY));
+    static const LogString DEBUG_KEY(LOG4CXX_STR("log4j.debug"));
+    LogString value(properties.getProperty(DEBUG_KEY));
 
-	if (!value.empty())
-	{
-		LogLog::setInternalDebugging(OptionConverter::toBoolean(value, true));
-	}
+    if (!value.empty())
+    {
+        LogLog::setInternalDebugging(OptionConverter::toBoolean(value, true));
+    }
 
-	static const LogString THRESHOLD_PREFIX(LOG4CXX_STR("log4j.threshold"));
-	LogString thresholdStr =
-		OptionConverter::findAndSubst(THRESHOLD_PREFIX, properties);
+    static const LogString THRESHOLD_PREFIX(LOG4CXX_STR("log4j.threshold"));
+    LogString thresholdStr =
+        OptionConverter::findAndSubst(THRESHOLD_PREFIX, properties);
 
-	if (!thresholdStr.empty())
-	{
-		hierarchy->setThreshold(OptionConverter::toLevel(thresholdStr, Level::getAll()));
-		LogLog::debug(((LogString) LOG4CXX_STR("Hierarchy threshold set to ["))
-			+ hierarchy->getThreshold()->toString()
-			+ LOG4CXX_STR("]."));
-	}
+    if (!thresholdStr.empty())
+    {
+        hierarchy->setThreshold(OptionConverter::toLevel(thresholdStr, Level::getAll()));
+        LogLog::debug(((LogString) LOG4CXX_STR("Hierarchy threshold set to ["))
+                      + hierarchy->getThreshold()->toString()
+                      + LOG4CXX_STR("]."));
+    }
 
-	static const LogString STRINGSTREAM_KEY(LOG4CXX_STR("log4j.stringstream"));
-	LogString strstrValue(properties.getProperty(STRINGSTREAM_KEY));
+    static const LogString STRINGSTREAM_KEY(LOG4CXX_STR("log4j.stringstream"));
+    LogString strstrValue(properties.getProperty(STRINGSTREAM_KEY));
 
-	if (strstrValue == LOG4CXX_STR("static"))
-	{
-		MessageBufferUseStaticStream();
-	}
+    if (strstrValue == LOG4CXX_STR("static"))
+    {
+        MessageBufferUseStaticStream();
+    }
 
-	configureRootLogger(properties, hierarchy);
-	configureLoggerFactory(properties);
-	parseCatsAndRenderers(properties, hierarchy);
+    configureRootLogger(properties, hierarchy);
+    configureLoggerFactory(properties);
+    parseCatsAndRenderers(properties, hierarchy);
 
-	LogLog::debug(LOG4CXX_STR("Finished configuring."));
+    LogLog::debug(LOG4CXX_STR("Finished configuring."));
 
-	// We don't want to hold references to appenders preventing their
-	// destruction.
-	registry->clear();
+    // We don't want to hold references to appenders preventing their
+    // destruction.
+    registry->clear();
 }
 
 void PropertyConfigurator::configureLoggerFactory(helpers::Properties& props)
 {
-	static const LogString LOGGER_FACTORY_KEY(LOG4CXX_STR("log4j.loggerFactory"));
+    static const LogString LOGGER_FACTORY_KEY(LOG4CXX_STR("log4j.loggerFactory"));
 
-	LogString factoryClassName =
-		OptionConverter::findAndSubst(LOGGER_FACTORY_KEY, props);
+    LogString factoryClassName =
+        OptionConverter::findAndSubst(LOGGER_FACTORY_KEY, props);
 
-	if (!factoryClassName.empty())
-	{
-		LogString msg(LOG4CXX_STR("Setting logger factory to ["));
-		msg += factoryClassName;
-		msg += LOG4CXX_STR("].");
-		LogLog::debug(msg);
-		loggerFactory =
-			OptionConverter::instantiateByClassName(
-				factoryClassName, LoggerFactory::getStaticClass(), loggerFactory);
-		static const LogString FACTORY_PREFIX(LOG4CXX_STR("log4j.factory."));
-		Pool p;
-		PropertySetter::setProperties(loggerFactory, props, FACTORY_PREFIX, p);
-	}
+    if (!factoryClassName.empty())
+    {
+        LogString msg(LOG4CXX_STR("Setting logger factory to ["));
+        msg += factoryClassName;
+        msg += LOG4CXX_STR("].");
+        LogLog::debug(msg);
+        std::shared_ptr<Object> instance = std::shared_ptr<Object>(
+                    Loader::loadClass(factoryClassName).newInstance() );
+
+        loggerFactory = log4cxx::cast<LoggerFactory>( instance );
+        static const LogString FACTORY_PREFIX(LOG4CXX_STR("log4j.factory."));
+        Pool p;
+        PropertySetter::setProperties(loggerFactory, props, FACTORY_PREFIX, p);
+    }
 }
 
 void PropertyConfigurator::configureRootLogger(helpers::Properties& props,
-	spi::LoggerRepositoryPtr& hierarchy)
+        spi::LoggerRepositoryPtr& hierarchy)
 {
-	static const LogString ROOT_CATEGORY_PREFIX(LOG4CXX_STR("log4j.rootCategory"));
-	static const LogString ROOT_LOGGER_PREFIX(LOG4CXX_STR("log4j.rootLogger"));
+    static const LogString ROOT_CATEGORY_PREFIX(LOG4CXX_STR("log4j.rootCategory"));
+    static const LogString ROOT_LOGGER_PREFIX(LOG4CXX_STR("log4j.rootLogger"));
 
 
 
-	LogString effectiveFrefix(ROOT_LOGGER_PREFIX);
-	LogString value = OptionConverter::findAndSubst(ROOT_LOGGER_PREFIX, props);
+    LogString effectiveFrefix(ROOT_LOGGER_PREFIX);
+    LogString value = OptionConverter::findAndSubst(ROOT_LOGGER_PREFIX, props);
 
-	if (value.empty())
-	{
-		value = OptionConverter::findAndSubst(ROOT_CATEGORY_PREFIX, props);
-		effectiveFrefix = ROOT_CATEGORY_PREFIX;
-	}
+    if (value.empty())
+    {
+        value = OptionConverter::findAndSubst(ROOT_CATEGORY_PREFIX, props);
+        effectiveFrefix = ROOT_CATEGORY_PREFIX;
+    }
 
-	if (value.empty())
-	{
-		LogLog::debug(LOG4CXX_STR("Could not find root logger information. Is this OK?"));
-	}
-	else
-	{
-		LoggerPtr root = hierarchy->getRootLogger();
+    if (value.empty())
+    {
+        LogLog::debug(LOG4CXX_STR("Could not find root logger information. Is this OK?"));
+    }
+    else
+    {
+        LoggerPtr root = hierarchy->getRootLogger();
 
-		LOCK_W sync(root->getMutex());
-		static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
-		parseLogger(props, root, effectiveFrefix, INTERNAL_ROOT_NAME, value);
-	}
+        static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
+        parseLogger(props, root, effectiveFrefix, INTERNAL_ROOT_NAME, value, true);
+    }
 }
 
 void PropertyConfigurator::parseCatsAndRenderers(helpers::Properties& props,
-	spi::LoggerRepositoryPtr& hierarchy)
+        spi::LoggerRepositoryPtr& hierarchy)
 {
-	static const LogString CATEGORY_PREFIX(LOG4CXX_STR("log4j.category."));
-	static const LogString LOGGER_PREFIX(LOG4CXX_STR("log4j.logger."));
+    static const LogString CATEGORY_PREFIX(LOG4CXX_STR("log4j.category."));
+    static const LogString LOGGER_PREFIX(LOG4CXX_STR("log4j.logger."));
 
-	std::vector<LogString> names = props.propertyNames();
+    std::vector<LogString> names = props.propertyNames();
 
-	std::vector<LogString>::iterator it = names.begin();
-	std::vector<LogString>::iterator itEnd = names.end();
+    std::vector<LogString>::iterator it = names.begin();
+    std::vector<LogString>::iterator itEnd = names.end();
 
-	while (it != itEnd)
-	{
-		LogString key = *it++;
+    while (it != itEnd)
+    {
+        LogString key = *it++;
 
-		if (key.find(CATEGORY_PREFIX) == 0 || key.find(LOGGER_PREFIX) == 0)
-		{
-			LogString loggerName;
+        if (key.find(CATEGORY_PREFIX) == 0 || key.find(LOGGER_PREFIX) == 0)
+        {
+            LogString loggerName;
 
-			if (key.find(CATEGORY_PREFIX) == 0)
-			{
-				loggerName = key.substr(CATEGORY_PREFIX.length());
-			}
-			else if (key.find(LOGGER_PREFIX) == 0)
-			{
-				loggerName = key.substr(LOGGER_PREFIX.length());
-			}
+            if (key.find(CATEGORY_PREFIX) == 0)
+            {
+                loggerName = key.substr(CATEGORY_PREFIX.length());
+            }
+            else if (key.find(LOGGER_PREFIX) == 0)
+            {
+                loggerName = key.substr(LOGGER_PREFIX.length());
+            }
 
-			LogString value = OptionConverter::findAndSubst(key, props);
-			LoggerPtr logger = hierarchy->getLogger(loggerName, loggerFactory);
+            LogString value = OptionConverter::findAndSubst(key, props);
+            LoggerPtr logger = hierarchy->getLogger(loggerName, loggerFactory);
 
-			LOCK_W sync(logger->getMutex());
-			parseLogger(props, logger, key, loggerName, value);
-			parseAdditivityForLogger(props, logger, loggerName);
-		}
-	}
+            bool additivity = parseAdditivityForLogger(props, logger, loggerName);
+            parseLogger(props, logger, key, loggerName, value, additivity);
+
+        }
+    }
 }
 
-void PropertyConfigurator::parseAdditivityForLogger(helpers::Properties& props,
-	LoggerPtr& cat, const LogString& loggerName)
+bool PropertyConfigurator::parseAdditivityForLogger(helpers::Properties& props,
+        LoggerPtr& cat, const LogString& loggerName)
 {
 
-	static const LogString ADDITIVITY_PREFIX(LOG4CXX_STR("log4j.additivity."));
+    static const LogString ADDITIVITY_PREFIX(LOG4CXX_STR("log4j.additivity."));
 
 
 
-	LogString value(OptionConverter::findAndSubst(ADDITIVITY_PREFIX + loggerName, props));
-	LogLog::debug((LogString) LOG4CXX_STR("Handling ") + ADDITIVITY_PREFIX
-		+ loggerName + LOG4CXX_STR("=[") +  value + LOG4CXX_STR("]"));
+    LogString value(OptionConverter::findAndSubst(ADDITIVITY_PREFIX + loggerName, props));
+    LogLog::debug((LogString) LOG4CXX_STR("Handling ") + ADDITIVITY_PREFIX
+                  + loggerName + LOG4CXX_STR("=[") +  value + LOG4CXX_STR("]"));
 
-	// touch additivity only if necessary
-	if (!value.empty())
-	{
-		bool additivity = OptionConverter::toBoolean(value, true);
-		LogLog::debug(((LogString) LOG4CXX_STR("Setting additivity for \""))
-			+ loggerName
-			+ ((additivity) ?  LOG4CXX_STR("\" to true") :
-				LOG4CXX_STR("\" to false")));
-		cat->setAdditivity(additivity);
-	}
+    // touch additivity only if necessary
+    if (!value.empty())
+    {
+        bool additivity = OptionConverter::toBoolean(value, true);
+        LogLog::debug(((LogString) LOG4CXX_STR("Setting additivity for \""))
+                      + loggerName
+                      + ((additivity) ?  LOG4CXX_STR("\" to true") :
+                         LOG4CXX_STR("\" to false")));
+
+        return additivity;
+    }
+
+    return true;
 }
 
 /**
         This method must work for the root logger as well.
 */
 void PropertyConfigurator::parseLogger(
-	helpers::Properties& props, LoggerPtr& logger, const LogString& /* optionKey */,
-	const LogString& loggerName, const LogString& value)
+    helpers::Properties& props, LoggerPtr& logger, const LogString& /* optionKey */,
+    const LogString& loggerName, const LogString& value, bool additivity)
 {
-	LogLog::debug(((LogString) LOG4CXX_STR("Parsing for ["))
-		+ loggerName
-		+ LOG4CXX_STR("] with value=[")
-		+ value + LOG4CXX_STR("]."));
+    LogLog::debug(((LogString) LOG4CXX_STR("Parsing for ["))
+                  + loggerName
+                  + LOG4CXX_STR("] with value=[")
+                  + value + LOG4CXX_STR("]."));
 
-	// We must skip over ',' but not white space
-	StringTokenizer st(value, LOG4CXX_STR(","));
+    // We must skip over ',' but not white space
+    StringTokenizer st(value, LOG4CXX_STR(","));
 
-	// If value is not in the form ", appender.." or "", then we should set
-	// the level of the logger.
-	if (!(value.find(LOG4CXX_STR(",")) == 0 || value.empty()))
-	{
-		// just to be on the safe side...
-		if (!st.hasMoreTokens())
-		{
-			return;
-		}
+    // If value is not in the form ", appender.." or "", then we should set
+    // the level of the logger.
+    if (!(value.find(LOG4CXX_STR(",")) == 0 || value.empty()))
+    {
+        // just to be on the safe side...
+        if (!st.hasMoreTokens())
+        {
+            return;
+        }
 
-		LogString levelStr = st.nextToken();
-		LogLog::debug((LogString) LOG4CXX_STR("Level token is [")
-			+ levelStr +  LOG4CXX_STR("]."));
+        LogString levelStr = st.nextToken();
+        LogLog::debug((LogString) LOG4CXX_STR("Level token is [")
+                      + levelStr +  LOG4CXX_STR("]."));
 
 
-		// If the level value is inherited, set logger level value to
-		// null. We also check that the user has not specified inherited for the
-		// root logger.
-		if (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited"))
-			|| StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
-		{
-			static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
+        // If the level value is inherited, set logger level value to
+        // null. We also check that the user has not specified inherited for the
+        // root logger.
+        if (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited"))
+                || StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
+        {
+            static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
 
-			if (loggerName == INTERNAL_ROOT_NAME)
-			{
-				LogLog::warn(LOG4CXX_STR("The root logger cannot be set to null."));
-			}
-			else
-			{
-				logger->setLevel(0);
-				LogLog::debug((LogString) LOG4CXX_STR("Logger ")
-					+ loggerName + LOG4CXX_STR(" set to null"));
-			}
-		}
-		else
-		{
-			logger->setLevel(OptionConverter::toLevel(levelStr, Level::getDebug()));
+            if (loggerName == INTERNAL_ROOT_NAME)
+            {
+                LogLog::warn(LOG4CXX_STR("The root logger cannot be set to null."));
+            }
+            else
+            {
+                logger->setLevel(0);
+                LogLog::debug((LogString) LOG4CXX_STR("Logger ")
+                              + loggerName + LOG4CXX_STR(" set to null"));
+            }
+        }
+        else
+        {
+            logger->setLevel(OptionConverter::toLevel(levelStr, Level::getDebug()));
 
-			LogLog::debug((LogString) LOG4CXX_STR("Logger ")
-				+ loggerName + LOG4CXX_STR(" set to ")
-				+ logger->getLevel()->toString());
-		}
+            LogLog::debug((LogString) LOG4CXX_STR("Logger ")
+                          + loggerName + LOG4CXX_STR(" set to ")
+                          + logger->getLevel()->toString());
+        }
 
-	}
+    }
 
-	// Begin by removing all existing appenders.
-	logger->removeAllAppenders();
+    AppenderPtr appender;
+    LogString appenderName;
+    std::vector<AppenderPtr> newappenders;
 
-	AppenderPtr appender;
-	LogString appenderName;
+    while (st.hasMoreTokens())
+    {
+        appenderName = StringHelper::trim(st.nextToken());
 
-	while (st.hasMoreTokens())
-	{
-		appenderName = StringHelper::trim(st.nextToken());
+        if (appenderName.empty() || appenderName == LOG4CXX_STR(","))
+        {
+            continue;
+        }
 
-		if (appenderName.empty() || appenderName == LOG4CXX_STR(","))
-		{
-			continue;
-		}
+        LogLog::debug(LOG4CXX_STR("Parsing appender named ")
+                      + appenderName + LOG4CXX_STR("\"."));
+        appender = parseAppender(props, appenderName);
 
-		LogLog::debug(LOG4CXX_STR("Parsing appender named ")
-			+ appenderName + LOG4CXX_STR("\"."));
-		appender = parseAppender(props, appenderName);
+        if (appender != 0)
+        {
+            newappenders.push_back(appender);
+        }
+    }
 
-		if (appender != 0)
-		{
-			logger->addAppender(appender);
-		}
-	}
+    logger->reconfigure( newappenders, additivity );
 }
 
 AppenderPtr PropertyConfigurator::parseAppender(
-	helpers::Properties& props, const LogString& appenderName)
+    helpers::Properties& props, const LogString& appenderName)
 {
-	AppenderPtr appender = registryGet(appenderName);
+    AppenderPtr appender = registryGet(appenderName);
 
-	if (appender != 0)
-	{
-		LogLog::debug((LogString) LOG4CXX_STR("Appender \"")
-			+ appenderName + LOG4CXX_STR("\" was already parsed."));
+    if (appender != 0)
+    {
+        LogLog::debug((LogString) LOG4CXX_STR("Appender \"")
+                      + appenderName + LOG4CXX_STR("\" was already parsed."));
 
-		return appender;
-	}
+        return appender;
+    }
 
-	static const LogString APPENDER_PREFIX(LOG4CXX_STR("log4j.appender."));
+    static const LogString APPENDER_PREFIX(LOG4CXX_STR("log4j.appender."));
 
-	// Appender was not previously initialized.
-	LogString prefix = APPENDER_PREFIX + appenderName;
-	LogString layoutPrefix = prefix + LOG4CXX_STR(".layout");
+    // Appender was not previously initialized.
+    LogString prefix = APPENDER_PREFIX + appenderName;
+    LogString layoutPrefix = prefix + LOG4CXX_STR(".layout");
 
-	appender =
-		OptionConverter::instantiateByKey(
-			props, prefix, Appender::getStaticClass(), 0);
+    std::shared_ptr<Object> obj =
+        OptionConverter::instantiateByKey(
+            props, prefix, Appender::getStaticClass(), 0);
+    appender = log4cxx::cast<Appender>( obj );
 
-	if (appender == 0)
-	{
-		LogLog::error((LogString) LOG4CXX_STR("Could not instantiate appender named \"")
-			+ appenderName + LOG4CXX_STR("\"."));
-		return 0;
-	}
+    if (appender == 0)
+    {
+        LogLog::error((LogString) LOG4CXX_STR("Could not instantiate appender named \"")
+                      + appenderName + LOG4CXX_STR("\"."));
+        return 0;
+    }
 
-	appender->setName(appenderName);
+    appender->setName(appenderName);
 
-	if (appender->instanceof(OptionHandler::getStaticClass()))
-	{
-		Pool p;
+    if (appender->instanceof(OptionHandler::getStaticClass()))
+    {
+        Pool p;
 
-		if (appender->requiresLayout())
-		{
-			LayoutPtr layout =
-				OptionConverter::instantiateByKey(
-					props, layoutPrefix, Layout::getStaticClass(), 0);
+        if (appender->requiresLayout())
+        {
+            LayoutPtr layout;
+            std::shared_ptr<Object> obj =
+                OptionConverter::instantiateByKey(
+                    props, layoutPrefix, Layout::getStaticClass(), 0);
+            layout = log4cxx::cast<Layout>( obj );
 
-			if (layout != 0)
-			{
-				appender->setLayout(layout);
-				LogLog::debug((LogString) LOG4CXX_STR("Parsing layout options for \"")
-					+ appenderName + LOG4CXX_STR("\"."));
+            if (layout != 0)
+            {
+                appender->setLayout(layout);
+                LogLog::debug((LogString) LOG4CXX_STR("Parsing layout options for \"")
+                              + appenderName + LOG4CXX_STR("\"."));
 
-				//configureOptionHandler(layout, layoutPrefix + ".", props);
-				PropertySetter::setProperties(layout, props, layoutPrefix + LOG4CXX_STR("."), p);
-				LogLog::debug((LogString) LOG4CXX_STR("End of parsing for \"")
-					+ appenderName +  LOG4CXX_STR("\"."));
-			}
-		}
+                //configureOptionHandler(layout, layoutPrefix + ".", props);
+                PropertySetter::setProperties(layout, props, layoutPrefix + LOG4CXX_STR("."), p);
+                LogLog::debug((LogString) LOG4CXX_STR("End of parsing for \"")
+                              + appenderName +  LOG4CXX_STR("\"."));
+            }
+        }
 
-		//configureOptionHandler((OptionHandler) appender, prefix + _T("."), props);
-		PropertySetter::setProperties(appender, props, prefix + LOG4CXX_STR("."), p);
-		LogLog::debug((LogString) LOG4CXX_STR("Parsed \"")
-			+ appenderName + LOG4CXX_STR("\" options."));
-	}
+        //configureOptionHandler((OptionHandler) appender, prefix + _T("."), props);
+        PropertySetter::setProperties(appender, props, prefix + LOG4CXX_STR("."), p);
+        LogLog::debug((LogString) LOG4CXX_STR("Parsed \"")
+                      + appenderName + LOG4CXX_STR("\" options."));
+    }
 
-	registryPut(appender);
+    registryPut(appender);
 
-	return appender;
+    return appender;
 }
 
 void PropertyConfigurator::registryPut(const AppenderPtr& appender)
 {
-	(*registry)[appender->getName()] = appender;
+    (*registry)[appender->getName()] = appender;
 }
 
 AppenderPtr PropertyConfigurator::registryGet(const LogString& name)
 {
-	return (*registry)[name];
+    return (*registry)[name];
 }
diff --git a/src/main/cpp/propertyresourcebundle.cpp b/src/main/cpp/propertyresourcebundle.cpp
index 2ae4ae7..41d49e1 100644
--- a/src/main/cpp/propertyresourcebundle.cpp
+++ b/src/main/cpp/propertyresourcebundle.cpp
@@ -36,7 +36,7 @@
 LogString PropertyResourceBundle::getString(const LogString& key) const
 {
 	LogString resource;
-	PropertyResourceBundlePtr resourceBundle(const_cast<PropertyResourceBundle*>(this));
+    PropertyResourceBundle* resourceBundle(const_cast<PropertyResourceBundle*>(this));
 
 	do
 	{
@@ -47,7 +47,7 @@
 			return resource;
 		}
 
-		resourceBundle = resourceBundle->parent;
+        resourceBundle = dynamic_cast<PropertyResourceBundle*>(resourceBundle->parent.get());
 	}
 	while (resourceBundle != 0);
 
diff --git a/src/main/cpp/propertysetter.cpp b/src/main/cpp/propertysetter.cpp
index a21a186..651c4af 100644
--- a/src/main/cpp/propertysetter.cpp
+++ b/src/main/cpp/propertysetter.cpp
@@ -96,7 +96,8 @@
 	{
 		LogLog::debug(LOG4CXX_STR("Setting option name=[") +
 			option + LOG4CXX_STR("], value=[") + value + LOG4CXX_STR("]"));
-		OptionHandlerPtr(obj)->setOption(option, value);
+        OptionHandlerPtr handler = log4cxx::cast<OptionHandler>(obj);
+        handler->setOption(option, value);
 	}
 }
 
@@ -104,6 +105,7 @@
 {
 	if (obj != 0 && obj->instanceof(OptionHandler::getStaticClass()))
 	{
-		OptionHandlerPtr(obj)->activateOptions(p);
+        OptionHandlerPtr handler = log4cxx::cast<OptionHandler>(obj);
+        handler->activateOptions(p);
 	}
 }
diff --git a/src/main/cpp/resourcebundle.cpp b/src/main/cpp/resourcebundle.cpp
index c1c42c2..07de007 100644
--- a/src/main/cpp/resourcebundle.cpp
+++ b/src/main/cpp/resourcebundle.cpp
@@ -70,7 +70,8 @@
 		try
 		{
 			const Class& classObj = Loader::loadClass(bundleName);
-			current = classObj.newInstance();
+            ObjectPtr obj = ObjectPtr(classObj.newInstance());
+            current = log4cxx::cast<PropertyResourceBundle>(obj);
 		}
 		catch (ClassNotFoundException&)
 		{
@@ -91,7 +92,7 @@
 
 			try
 			{
-				current = new PropertyResourceBundle(bundleStream);
+                current = PropertyResourceBundlePtr(new PropertyResourceBundle(bundleStream));
 			}
 			catch (Exception&)
 			{
diff --git a/src/main/cpp/rollingfileappender.cpp b/src/main/cpp/rollingfileappender.cpp
index 90b5b48..0046ee8 100644
--- a/src/main/cpp/rollingfileappender.cpp
+++ b/src/main/cpp/rollingfileappender.cpp
@@ -34,7 +34,6 @@
 
 #include <log4cxx/rolling/rollingfileappender.h>
 #include <log4cxx/helpers/loglog.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/rolling/rolloverdescription.h>
 #include <log4cxx/helpers/fileoutputstream.h>
 #include <log4cxx/helpers/bytebuffer.h>
@@ -69,7 +68,7 @@
 {
 	if (rollingPolicy == NULL)
 	{
-		FixedWindowRollingPolicy* fwrp = new FixedWindowRollingPolicy();
+        FixedWindowRollingPolicyPtr fwrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
 		fwrp->setFileNamePattern(getFile() + LOG4CXX_STR(".%i"));
 		rollingPolicy = fwrp;
 	}
@@ -79,7 +78,7 @@
 	//
 	if (triggeringPolicy == NULL)
 	{
-		TriggeringPolicyPtr trig(rollingPolicy);
+        TriggeringPolicyPtr trig = log4cxx::cast<TriggeringPolicy>(rollingPolicy);
 
 		if (trig != NULL)
 		{
@@ -89,11 +88,11 @@
 
 	if (triggeringPolicy == NULL)
 	{
-		triggeringPolicy = new ManualTriggeringPolicy();
+        triggeringPolicy = TriggeringPolicyPtr(new ManualTriggeringPolicy());
 	}
 
 	{
-		LOCK_W sync(mutex);
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 		triggeringPolicy->activateOptions(p);
 		rollingPolicy->activateOptions(p);
 
@@ -111,8 +110,8 @@
 					syncAction->execute(p);
 				}
 
-				setFile(rollover1->getActiveFileName());
-				setAppend(rollover1->getAppend());
+				fileName = rollover1->getActiveFileName();
+				fileAppend = rollover1->getAppend();
 
 				//
 				//  async action not yet implemented
@@ -137,7 +136,7 @@
 				fileLength = 0;
 			}
 
-			FileAppender::activateOptions(p);
+			FileAppender::activateOptionsInternal(p);
 		}
 		catch (std::exception&)
 		{
@@ -182,6 +181,12 @@
  */
 bool RollingFileAppenderSkeleton::rollover(Pool& p)
 {
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+	return rolloverInternal(p);
+}
+
+bool RollingFileAppenderSkeleton::rolloverInternal(Pool& p)
+{
 	//
 	//   can't roll without a policy
 	//
@@ -189,7 +194,6 @@
 	{
 
 		{
-			LOCK_W sync(mutex);
 
 #ifdef LOG4CXX_MULTI_PROCESS
 			std::string fileName(getFile());
@@ -328,26 +332,26 @@
 									asyncAction->execute(p);
 								}
 
-								setFile(
+								setFileInternal(
 									rollover1->getActiveFileName(), rollover1->getAppend(),
 									bufferedIO, bufferSize, p);
 							}
 							else
 							{
-								setFile(
+								setFileInternal(
 									rollover1->getActiveFileName(), true, bufferedIO, bufferSize, p);
 							}
 						}
 						else
 						{
 							closeWriter();
-							setFile(rollover1->getActiveFileName());
+							setFileInternal(rollover1->getActiveFileName());
 							// Call activateOptions to create any intermediate directories(if required)
-							FileAppender::activateOptions(p);
+							FileAppender::activateOptionsInternal(p);
 							OutputStreamPtr os(new FileOutputStream(
 									rollover1->getActiveFileName(), rollover1->getAppend()));
 							WriterPtr newWriter(createWriter(os));
-							setWriter(newWriter);
+							setWriterInternal(newWriter);
 
 							bool success = true;
 
@@ -452,7 +456,7 @@
 		try
 		{
 			_event = &(const_cast<LoggingEventPtr&>(event));
-			rollover(p);
+			rolloverInternal(p);
 		}
 		catch (std::exception&)
 		{
diff --git a/src/main/cpp/rollingpolicybase.cpp b/src/main/cpp/rollingpolicybase.cpp
index af83c64..b5fb448 100644
--- a/src/main/cpp/rollingpolicybase.cpp
+++ b/src/main/cpp/rollingpolicybase.cpp
@@ -44,16 +44,6 @@
 {
 }
 
-void RollingPolicyBase::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void RollingPolicyBase::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
-
 void RollingPolicyBase::activateOptions(log4cxx::helpers::Pool& /* pool */)
 {
 	if (fileNamePatternStr.length() > 0)
@@ -138,7 +128,9 @@
 		converterIter != patternConverters.end();
 		converterIter++)
 	{
-		IntegerPatternConverterPtr intPattern(*converterIter);
+        IntegerPatternConverterPtr intPattern;
+        PatternConverterPtr patternptr = (*converterIter);
+        intPattern = log4cxx::cast<IntegerPatternConverter>(patternptr);
 
 		if (intPattern != NULL)
 		{
@@ -157,7 +149,9 @@
 		converterIter != patternConverters.end();
 		converterIter++)
 	{
-		DatePatternConverterPtr datePattern(*converterIter);
+        DatePatternConverterPtr datePattern;
+        PatternConverterPtr patternptr = (*converterIter);
+        datePattern = log4cxx::cast<DatePatternConverter>(patternptr);
 
 		if (datePattern != NULL)
 		{
diff --git a/src/main/cpp/rootlogger.cpp b/src/main/cpp/rootlogger.cpp
index f733806..9f3357a 100644
--- a/src/main/cpp/rootlogger.cpp
+++ b/src/main/cpp/rootlogger.cpp
@@ -24,18 +24,18 @@
 using namespace log4cxx::spi;
 using namespace log4cxx::helpers;
 
-RootLogger::RootLogger(Pool& pool, const LevelPtr& level1) :
+RootLogger::RootLogger(Pool& pool, const LevelPtr level1) :
 	Logger(pool, LOG4CXX_STR("root"))
 {
 	setLevel(level1);
 }
 
-const LevelPtr& RootLogger::getEffectiveLevel() const
+const LevelPtr RootLogger::getEffectiveLevel() const
 {
 	return level;
 }
 
-void RootLogger::setLevel(const LevelPtr& level1)
+void RootLogger::setLevel(const LevelPtr level1)
 {
 	if (level1 == 0)
 	{
diff --git a/src/main/cpp/serversocket.cpp b/src/main/cpp/serversocket.cpp
index 5af4955..6766c2a 100644
--- a/src/main/cpp/serversocket.cpp
+++ b/src/main/cpp/serversocket.cpp
@@ -16,7 +16,6 @@
  */
 
 #include <log4cxx/helpers/serversocket.h>
-#include <log4cxx/helpers/synchronized.h>
 #include "apr_network_io.h"
 #include "apr_pools.h"
 #include "apr_poll.h"
@@ -25,7 +24,7 @@
 
 /**  Creates a server socket on a specified port.
 */
-ServerSocket::ServerSocket(int port) : pool(), mutex(pool), socket(0), timeout(0)
+ServerSocket::ServerSocket(int port) : pool(), socket(0), timeout(0)
 {
 	apr_status_t status =
 		apr_socket_create(&socket, APR_INET, SOCK_STREAM,
@@ -78,7 +77,7 @@
 
 void ServerSocket::close()
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 	if (socket != 0)
 	{
@@ -98,7 +97,7 @@
 */
 SocketPtr ServerSocket::accept()
 {
-	synchronized sync(mutex);
+	log4cxx::unique_lock<log4cxx::mutex> lock(mutex);
 
 	if (socket == 0)
 	{
@@ -151,7 +150,7 @@
 		throw SocketException(status);
 	}
 
-	return new Socket(newSocket, newPool);
+    return SocketPtr(new Socket(newSocket, newPool));
 }
 
 /** Retrive setting for SO_TIMEOUT.
diff --git a/src/main/cpp/smtpappender.cpp b/src/main/cpp/smtpappender.cpp
index 3be6600..6908dd7 100644
--- a/src/main/cpp/smtpappender.cpp
+++ b/src/main/cpp/smtpappender.cpp
@@ -22,7 +22,7 @@
 #include <log4cxx/helpers/stringhelper.h>
 #include <log4cxx/helpers/stringtokenizer.h>
 #include <log4cxx/helpers/transcoder.h>
-#include <log4cxx/helpers/synchronized.h>
+#include <log4cxx/helpers/loader.h>
 #if !defined(LOG4CXX)
 	#define LOG4CXX 1
 #endif
@@ -348,7 +348,7 @@
 
 class LOG4CXX_EXPORT DefaultEvaluator :
 	public virtual spi::TriggeringEventEvaluator,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	public:
 		DECLARE_LOG4CXX_OBJECT(DefaultEvaluator)
@@ -784,7 +784,7 @@
 */
 void SMTPAppender::setEvaluatorClass(const LogString& value)
 {
-	evaluator = OptionConverter::instantiateByClassName(value,
-			TriggeringEventEvaluator::getStaticClass(), evaluator);
+    ObjectPtr obj = ObjectPtr(Loader::loadClass(value).newInstance());
+    evaluator = log4cxx::cast<TriggeringEventEvaluator>(obj);
 }
 
diff --git a/src/main/cpp/socket.cpp b/src/main/cpp/socket.cpp
index 2ede191..2849cb8 100644
--- a/src/main/cpp/socket.cpp
+++ b/src/main/cpp/socket.cpp
@@ -87,7 +87,7 @@
 			Transcoder::decode(buf, remoteip);
 		}
 
-		address = new InetAddress(remotename, remoteip);
+        address = InetAddressPtr(new InetAddress(remotename, remoteip));
 	}
 }
 
diff --git a/src/main/cpp/socketappender.cpp b/src/main/cpp/socketappender.cpp
index 5b3e158..e30d203 100644
--- a/src/main/cpp/socketappender.cpp
+++ b/src/main/cpp/socketappender.cpp
@@ -23,7 +23,6 @@
 #include <log4cxx/helpers/optionconverter.h>
 #include <log4cxx/helpers/stringhelper.h>
 #include <log4cxx/spi/loggingevent.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/objectoutputstream.h>
 #include <apr_time.h>
 #include <apr_atomic.h>
@@ -79,9 +78,10 @@
 
 void SocketAppender::setSocket(log4cxx::helpers::SocketPtr& socket, Pool& p)
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
-	oos = new ObjectOutputStream(new SocketOutputStream(socket), p);
+    SocketOutputStreamPtr sock = SocketOutputStreamPtr(new SocketOutputStream(socket));
+    oos = ObjectOutputStreamPtr(new ObjectOutputStream(sock, p));
 }
 
 void SocketAppender::cleanUp(Pool& p)
diff --git a/src/main/cpp/socketappenderskeleton.cpp b/src/main/cpp/socketappenderskeleton.cpp
index af08126..4f67dbf 100644
--- a/src/main/cpp/socketappenderskeleton.cpp
+++ b/src/main/cpp/socketappenderskeleton.cpp
@@ -24,9 +24,9 @@
 #include <log4cxx/helpers/optionconverter.h>
 #include <log4cxx/helpers/stringhelper.h>
 #include <log4cxx/spi/loggingevent.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/transcoder.h>
 #include <log4cxx/helpers/bytearrayoutputstream.h>
+#include <functional>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -38,7 +38,7 @@
 	   port(defaultPort),
 	   reconnectionDelay(reconnectionDelay1),
 	   locationInfo(false),
-	   thread()
+       thread()
 {
 }
 
@@ -66,16 +66,7 @@
 
 SocketAppenderSkeleton::~SocketAppenderSkeleton()
 {
-	finalize();
-
-	try
-	{
-		thread.join();
-	}
-	catch (ThreadException& ex)
-	{
-		LogLog::error(LOG4CXX_STR("Error closing socket appender connection thread"), ex);
-	}
+    finalize();
 }
 
 void SocketAppenderSkeleton::activateOptions(Pool& p)
@@ -86,7 +77,7 @@
 
 void SocketAppenderSkeleton::close()
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
 	if (closed)
 	{
@@ -95,7 +86,15 @@
 
 	closed = true;
 	cleanUp(pool);
-	thread.interrupt();
+
+    {
+		log4cxx::unique_lock<log4cxx::mutex> lock2(interrupt_mutex);
+        interrupt.notify_all();
+    }
+
+    if( thread.joinable() ){
+        thread.join();
+    }
 }
 
 void SocketAppenderSkeleton::connect(Pool& p)
@@ -156,56 +155,52 @@
 
 void SocketAppenderSkeleton::fireConnector()
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
-	if ( !thread.isAlive() )
+    if ( !thread.joinable() )
 	{
 		LogLog::debug(LOG4CXX_STR("Connector thread not alive: starting monitor."));
 
-		try
-		{
-			thread.run(monitor, this);
-		}
-		catch ( ThreadException& te )
-		{
-			LogLog::error(LOG4CXX_STR("Monitor not started: "), te);
-		}
+		thread = log4cxx::thread( &SocketAppenderSkeleton::monitor, this );
 	}
 }
 
-void* LOG4CXX_THREAD_FUNC SocketAppenderSkeleton::monitor(apr_thread_t* /* thread */, void* data)
+void SocketAppenderSkeleton::monitor()
 {
-	SocketAppenderSkeleton* socketAppender = (SocketAppenderSkeleton*) data;
 	SocketPtr socket;
-	bool isClosed = socketAppender->closed;
+    bool isClosed = closed;
 
 	while (!isClosed)
 	{
 		try
-		{
-			Thread::sleep(socketAppender->reconnectionDelay);
+        {
+            std::this_thread::sleep_for( std::chrono::milliseconds( reconnectionDelay ) );
 
-			if (!socketAppender->closed)
+			log4cxx::unique_lock<log4cxx::mutex> lock( interrupt_mutex );
+            interrupt.wait_for( lock, std::chrono::milliseconds( reconnectionDelay ),
+                                std::bind(&SocketAppenderSkeleton::is_closed, this) );
+
+            if (!closed)
 			{
 				LogLog::debug(LogString(LOG4CXX_STR("Attempting connection to "))
-					+ socketAppender->address->getHostName());
-				socket = new Socket(socketAppender->address, socketAppender->port);
+                    + address->getHostName());
+                socket = SocketPtr(new Socket(address, port));
 				Pool p;
-				socketAppender->setSocket(socket, p);
+                setSocket(socket, p);
 				LogLog::debug(LOG4CXX_STR("Connection established. Exiting connector thread."));
 			}
 
-			return NULL;
+            return;
 		}
 		catch (InterruptedException&)
 		{
 			LogLog::debug(LOG4CXX_STR("Connector interrupted.  Leaving loop."));
-			return NULL;
+            return;
 		}
 		catch (ConnectException&)
 		{
 			LogLog::debug(LOG4CXX_STR("Remote host ")
-				+ socketAppender->address->getHostName()
+                + address->getHostName()
 				+ LOG4CXX_STR(" refused connection."));
 		}
 		catch (IOException& e)
@@ -214,14 +209,17 @@
 			log4cxx::helpers::Transcoder::decode(e.what(), exmsg);
 
 			LogLog::debug(((LogString) LOG4CXX_STR("Could not connect to "))
-				+ socketAppender->address->getHostName()
+                + address->getHostName()
 				+ LOG4CXX_STR(". Exception is ")
 				+ exmsg);
 		}
 
-		isClosed = socketAppender->closed;
+        isClosed = closed;
 	}
 
-	LogLog::debug(LOG4CXX_STR("Exiting Connector.run() method."));
-	return NULL;
+    LogLog::debug(LOG4CXX_STR("Exiting Connector.run() method."));
+}
+
+bool SocketAppenderSkeleton::is_closed(){
+    return closed;
 }
diff --git a/src/main/cpp/sockethubappender.cpp b/src/main/cpp/sockethubappender.cpp
index 79646f7..f966b8f 100644
--- a/src/main/cpp/sockethubappender.cpp
+++ b/src/main/cpp/sockethubappender.cpp
@@ -25,7 +25,6 @@
 #include <log4cxx/helpers/stringhelper.h>
 #include <log4cxx/helpers/serversocket.h>
 #include <log4cxx/spi/loggingevent.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <apr_atomic.h>
 #include <apr_thread_proc.h>
 #include <log4cxx/helpers/objectoutputstream.h>
@@ -37,8 +36,6 @@
 using namespace log4cxx::net;
 using namespace log4cxx::spi;
 
-#if APR_HAS_THREADS
-
 IMPLEMENT_LOG4CXX_OBJECT(SocketHubAppender)
 
 int SocketHubAppender::DEFAULT_PORT = 4560;
@@ -85,7 +82,7 @@
 void SocketHubAppender::close()
 {
 	{
-		LOCK_W sync(mutex);
+		log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
 		if (closed)
 		{
@@ -99,9 +96,11 @@
 	//
 	//  wait until the server thread completes
 	//
-	thread.join();
+	if( thread.joinable() ){
+		thread.join();
+	}
 
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 	// close all of the connections
 	LogLog::debug(LOG4CXX_STR("closing client connections"));
 
@@ -175,28 +174,26 @@
 
 void SocketHubAppender::startServer()
 {
-	thread.run(monitor, this);
+	thread = log4cxx::thread( &SocketHubAppender::monitor, this );
 }
 
-void* APR_THREAD_FUNC SocketHubAppender::monitor(apr_thread_t* /* thread */, void* data)
+void SocketHubAppender::monitor()
 {
-	SocketHubAppender* pThis = (SocketHubAppender*) data;
-
 	ServerSocket* serverSocket = 0;
 
 	try
 	{
-		serverSocket = new ServerSocket(pThis->port);
+        serverSocket = new ServerSocket(port);
 		serverSocket->setSoTimeout(1000);
 	}
 	catch (SocketException& e)
 	{
 		LogLog::error(LOG4CXX_STR("exception setting timeout, shutting down server socket."), e);
 		delete serverSocket;
-		return NULL;
+        return;
 	}
 
-	bool stopRunning = pThis->closed;
+    bool stopRunning = closed;
 
 	while (!stopRunning)
 	{
@@ -233,11 +230,11 @@
 					+ LOG4CXX_STR(")"));
 
 				// add it to the oosList.
-				LOCK_W sync(pThis->mutex);
+				log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 				OutputStreamPtr os(new SocketOutputStream(socket));
 				Pool p;
 				ObjectOutputStreamPtr oos(new ObjectOutputStream(os, p));
-				pThis->streams.push_back(oos);
+                streams.push_back(oos);
 			}
 			catch (IOException& e)
 			{
@@ -245,11 +242,8 @@
 			}
 		}
 
-		stopRunning = (stopRunning || pThis->closed);
+        stopRunning = (stopRunning ||closed);
 	}
 
-	delete serverSocket;
-	return NULL;
+    delete serverSocket;
 }
-
-#endif
diff --git a/src/main/cpp/synchronized.cpp b/src/main/cpp/synchronized.cpp
deleted file mode 100644
index 03a130a..0000000
--- a/src/main/cpp/synchronized.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/exception.h>
-
-#include <apr_thread_mutex.h>
-
-using namespace log4cxx::helpers;
-using namespace log4cxx;
-
-synchronized::synchronized(const Mutex& mutex1)
-	: mutex(mutex1.getAPRMutex())
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_mutex_lock(
-			(apr_thread_mutex_t*) this->mutex);
-
-	if (stat != APR_SUCCESS)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-synchronized::synchronized(apr_thread_mutex_t* mutex1)
-	: mutex(mutex1)
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_mutex_lock(
-			(apr_thread_mutex_t*) this->mutex);
-
-	if (stat != APR_SUCCESS)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-synchronized::~synchronized()
-{
-#if APR_HAS_THREADS
-	apr_status_t stat = apr_thread_mutex_unlock(
-			(apr_thread_mutex_t*) mutex);
-
-	if (stat != APR_SUCCESS)
-	{
-		throw MutexException(stat);
-	}
-
-#endif
-}
-
-#if defined(RW_MUTEX)
-
-synchronized_read::synchronized_read(const RWMutex& mutex1)
-	: mutex(mutex1)
-{
-	mutex.rdLock();
-}
-
-synchronized_read::~synchronized_read()
-{
-	mutex.rdUnlock();
-}
-
-synchronized_write::synchronized_write(const RWMutex& mutex1)
-	: mutex(mutex1)
-{
-	mutex.wrLock();
-}
-
-synchronized_write::~synchronized_write()
-{
-	mutex.wrUnlock();
-}
-
-#endif // RW_MUTEX
diff --git a/src/main/cpp/syslogwriter.cpp b/src/main/cpp/syslogwriter.cpp
index 42c7094..a9243eb 100644
--- a/src/main/cpp/syslogwriter.cpp
+++ b/src/main/cpp/syslogwriter.cpp
@@ -44,7 +44,7 @@
 
 	try
 	{
-		this->ds = new DatagramSocket();
+        this->ds = DatagramSocketPtr(new DatagramSocket());
 	}
 	catch (SocketException& e)
 	{
diff --git a/src/main/cpp/telnetappender.cpp b/src/main/cpp/telnetappender.cpp
index 79b6edc..d7e2a10 100644
--- a/src/main/cpp/telnetappender.cpp
+++ b/src/main/cpp/telnetappender.cpp
@@ -19,7 +19,6 @@
 #include <log4cxx/helpers/loglog.h>
 #include <log4cxx/helpers/optionconverter.h>
 #include <log4cxx/helpers/stringhelper.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <apr_thread_proc.h>
 #include <apr_atomic.h>
 #include <apr_strings.h>
@@ -30,8 +29,6 @@
 using namespace log4cxx::helpers;
 using namespace log4cxx::net;
 
-#if APR_HAS_THREADS
-
 IMPLEMENT_LOG4CXX_OBJECT(TelnetAppender)
 
 /** The default telnet server port */
@@ -46,7 +43,6 @@
 	  encoder(CharsetEncoder::getUTF8Encoder()),
 	  serverSocket(NULL), sh()
 {
-	LOCK_W sync(mutex);
 	activeConnections = 0;
 }
 
@@ -64,7 +60,7 @@
 		serverSocket->setSoTimeout(1000);
 	}
 
-	sh.run(acceptConnections, this);
+	sh = log4cxx::thread( &TelnetAppender::acceptConnections, this );
 }
 
 void TelnetAppender::setOption(const LogString& option,
@@ -86,13 +82,13 @@
 
 LogString TelnetAppender::getEncoding() const
 {
-	LOCK_W sync(mutex);
+	log4cxx::shared_lock<log4cxx::shared_mutex> lock(mutex);
 	return encoding;
 }
 
 void TelnetAppender::setEncoding(const LogString& value)
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 	encoder = CharsetEncoder::getEncoder(value);
 	encoding = value;
 }
@@ -100,7 +96,7 @@
 
 void TelnetAppender::close()
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
 	if (closed)
 	{
@@ -133,13 +129,9 @@
 		}
 	}
 
-	try
-	{
+	if( sh.joinable() ){
 		sh.join();
 	}
-	catch (Exception&)
-	{
-	}
 
 	activeConnections = 0;
 }
@@ -200,7 +192,7 @@
 		LogString::const_iterator msgIter(msg.begin());
 		ByteBuffer buf(bytes, bytesSize);
 
-		LOCK_W sync(this->mutex);
+		log4cxx::shared_lock<log4cxx::shared_mutex> lock(mutex);
 
 		while (msgIter != msg.end())
 		{
@@ -223,33 +215,32 @@
 	}
 }
 
-void* APR_THREAD_FUNC TelnetAppender::acceptConnections(apr_thread_t* /* thread */, void* data)
+void TelnetAppender::acceptConnections()
 {
-	TelnetAppender* pThis = (TelnetAppender*) data;
 
 	// main loop; is left when This->closed is != 0 after an accept()
 	while (true)
 	{
 		try
 		{
-			SocketPtr newClient = pThis->serverSocket->accept();
-			bool done = pThis->closed;
+            SocketPtr newClient = serverSocket->accept();
+            bool done = closed;
 
 			if (done)
 			{
 				Pool p;
-				pThis->writeStatus(newClient, LOG4CXX_STR("Log closed.\r\n"), p);
+                writeStatus(newClient, LOG4CXX_STR("Log closed.\r\n"), p);
 				newClient->close();
 
 				break;
 			}
 
-			size_t count = pThis->activeConnections;
+            size_t count = activeConnections;
 
-			if (count >= pThis->connections.size())
+            if (count >= connections.size())
 			{
 				Pool p;
-				pThis->writeStatus(newClient, LOG4CXX_STR("Too many connections.\r\n"), p);
+                writeStatus(newClient, LOG4CXX_STR("Too many connections.\r\n"), p);
 				newClient->close();
 			}
 			else
@@ -257,16 +248,16 @@
 				//
 				//   find unoccupied connection
 				//
-				LOCK_W sync(pThis->mutex);
+				log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
-				for (ConnectionList::iterator iter = pThis->connections.begin();
-					iter != pThis->connections.end();
+                for (ConnectionList::iterator iter = connections.begin();
+                    iter != connections.end();
 					iter++)
 				{
 					if (*iter == NULL)
 					{
 						*iter = newClient;
-						pThis->activeConnections++;
+                        activeConnections++;
 
 						break;
 					}
@@ -276,19 +267,19 @@
 				LogString oss(LOG4CXX_STR("TelnetAppender v1.0 ("));
 				StringHelper::toString((int) count + 1, p, oss);
 				oss += LOG4CXX_STR(" active connections)\r\n\r\n");
-				pThis->writeStatus(newClient, oss, p);
+                writeStatus(newClient, oss, p);
 			}
 		}
 		catch (InterruptedIOException&)
 		{
-			if (pThis->closed)
+            if (closed)
 			{
 				break;
 			}
 		}
 		catch (Exception& e)
 		{
-			if (!pThis->closed)
+            if (!closed)
 			{
 				LogLog::error(LOG4CXX_STR("Encountered error while in SocketHandler loop."), e);
 			}
@@ -299,7 +290,4 @@
 		}
 	}
 
-	return NULL;
 }
-
-#endif
diff --git a/src/main/cpp/threadcxx.cpp b/src/main/cpp/threadcxx.cpp
deleted file mode 100644
index 8d17776..0000000
--- a/src/main/cpp/threadcxx.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/thread.h>
-#include <log4cxx/helpers/exception.h>
-#include <apr_thread_proc.h>
-#include <apr_atomic.h>
-#include <log4cxx/helpers/pool.h>
-#include <log4cxx/helpers/threadlocal.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <apr_thread_cond.h>
-
-using namespace log4cxx::helpers;
-using namespace log4cxx;
-
-#if APR_HAS_THREADS
-namespace
-{
-/**
- *   This class is used to encapsulate the parameters to
- *   Thread::run when they are passed to Thread::launcher.
- *
- */
-class LaunchPackage
-{
-	public:
-		/**
-		 *  Placement new to create LaunchPackage in specified pool.
-		 *  LaunchPackage needs to be dynamically allocated since
-		 *  since a stack allocated instance may go out of scope
-		 *  before thread is launched.
-		 */
-		static void* operator new (size_t sz, Pool& p)
-		{
-			return p.palloc(sz);
-		}
-		/**
-		*  operator delete would be called if exception during construction.
-		*/
-		static void operator delete (void*, Pool& p)
-		{
-		}
-		/**
-		 *  Create new instance.
-		 */
-		LaunchPackage(Thread* t, Runnable r, void* d) : thread(t), runnable(r), data(d)
-		{
-		}
-		/**
-		 * Gets thread parameter.
-		 * @return thread.
-		 */
-		Thread* getThread() const
-		{
-			return thread;
-		}
-
-		/**
-		 *  Gets runnable parameter.
-		 *  @return runnable.
-		 */
-		Runnable getRunnable() const
-		{
-			return runnable;
-		}
-		/**
-		 *  gets data parameter.
-		 *  @return thread.
-		 */
-		void* getData() const
-		{
-			return data;
-		}
-	private:
-		LaunchPackage(const LaunchPackage&);
-		LaunchPackage& operator=(const LaunchPackage&);
-		Thread* thread;
-		Runnable runnable;
-		void* data;
-};
-
-/**
- *  This object atomically sets the specified memory location
- *  to non-zero on construction and to zero on destruction.
- *  Used to maintain Thread.alive.
- */
-class LaunchStatus
-{
-	public:
-		/*
-		 *  Construct new instance.
-		 *  @param p address of memory to set to non-zero on construction, zero on destruction.
-		 */
-		LaunchStatus(volatile unsigned int* p) : alive(p)
-		{
-			apr_atomic_set32(alive, 0xFFFFFFFF);
-		}
-		/**
-		 *  Destructor.
-		 */
-		~LaunchStatus()
-		{
-			apr_atomic_set32(alive, 0);
-		}
-
-	private:
-		LaunchStatus(const LaunchStatus&);
-		LaunchStatus& operator=(const LaunchStatus&);
-		volatile unsigned int* alive;
-};
-
-/**
- *   Get a key to the thread local storage used to hold the reference to
- *   the corresponding Thread object.
- */
-ThreadLocal& getThreadLocal()
-{
-	static ThreadLocal tls;
-	return tls;
-}
-
-}
-
-void* LOG4CXX_THREAD_FUNC ThreadLaunch::launcher(apr_thread_t* thread, void* data)
-{
-	LaunchPackage* package = (LaunchPackage*) data;
-	ThreadLocal& tls = getThreadLocal();
-	tls.set(package->getThread());
-	{
-		(package->getRunnable())(thread, package->getData());
-		package->getThread()->ending();
-	}
-	apr_thread_exit(thread, 0); // this function never returns !
-	return 0;
-}
-#endif
-
-Thread::Thread() : thread(NULL), alive(0), interruptedStatus(0),
-	interruptedMutex(NULL), interruptedCondition(NULL)
-{
-}
-
-Thread::~Thread()
-{
-	join();
-}
-
-
-
-void Thread::run(Runnable start, void* data)
-{
-#if APR_HAS_THREADS
-
-	// Try to join first if previous instance did exit
-	if ( isActive() && !isAlive() )
-	{
-		join();
-	}
-
-	// now we're ready to create the thread again
-	//
-	//    if attempting a second run method on the same Thread object
-	//         throw an exception
-	//
-	if (thread != NULL)
-	{
-		throw IllegalStateException();
-	}
-
-	apr_threadattr_t* attrs;
-	apr_status_t stat = apr_threadattr_create(&attrs, p.getAPRPool());
-
-	if (stat != APR_SUCCESS)
-	{
-		throw ThreadException(stat);
-	}
-
-	stat = apr_thread_cond_create(&interruptedCondition, p.getAPRPool());
-
-	if (stat != APR_SUCCESS)
-	{
-		throw ThreadException(stat);
-	}
-
-	stat = apr_thread_mutex_create(&interruptedMutex, APR_THREAD_MUTEX_NESTED,
-			p.getAPRPool());
-
-	if (stat != APR_SUCCESS)
-	{
-		throw ThreadException(stat);
-	}
-
-	//   create LaunchPackage on the thread's memory pool
-	LaunchPackage* package = new (p) LaunchPackage(this, start, data);
-	stat = apr_thread_create(&thread, attrs,
-			ThreadLaunch::launcher, package, p.getAPRPool());
-
-	if (stat != APR_SUCCESS)
-	{
-		throw ThreadException(stat);
-	}
-
-	// we need to set alive here already, since we use isAlive() to check
-	// if run() has been called in a thread-safe way.
-	apr_atomic_set32(&alive, 0xFFFFFFFF);
-#else
-	throw ThreadException(LOG4CXX_STR("APR_HAS_THREADS is not true"));
-#endif
-}
-
-void Thread::join()
-{
-#if APR_HAS_THREADS
-
-	if (thread != NULL)
-	{
-		apr_status_t startStat;
-		apr_status_t stat = apr_thread_join(&startStat, thread);
-		thread = NULL;
-
-		if (stat != APR_SUCCESS)
-		{
-			throw ThreadException(stat);
-		}
-	}
-
-#endif
-}
-
-void Thread::currentThreadInterrupt()
-{
-#if APR_HAS_THREADS
-	void* tls = getThreadLocal().get();
-
-	if (tls != 0)
-	{
-		((Thread*) tls)->interrupt();
-	}
-
-#endif
-}
-
-void Thread::interrupt()
-{
-	apr_atomic_set32(&interruptedStatus, 0xFFFFFFFF);
-#if APR_HAS_THREADS
-
-	if (interruptedMutex != NULL)
-	{
-		synchronized sync(interruptedMutex);
-		apr_status_t stat = apr_thread_cond_signal(interruptedCondition);
-
-		if (stat != APR_SUCCESS)
-		{
-			throw ThreadException(stat);
-		}
-	}
-
-#endif
-}
-
-bool Thread::interrupted()
-{
-#if APR_HAS_THREADS
-	void* tls = getThreadLocal().get();
-
-	if (tls != 0)
-	{
-		return apr_atomic_xchg32(&(((Thread*) tls)->interruptedStatus), 0) != 0;
-	}
-
-#endif
-	return false;
-}
-
-bool Thread::isCurrentThread() const
-{
-#if APR_HAS_THREADS
-	const void* tls = getThreadLocal().get();
-	return (tls == this);
-#else
-	return true;
-#endif
-}
-
-bool Thread::isAlive()
-{
-	return apr_atomic_read32(&alive) != 0;
-}
-
-void Thread::ending()
-{
-	apr_atomic_set32(&alive, 0);
-}
-
-
-void Thread::sleep(int duration)
-{
-#if APR_HAS_THREADS
-
-	if (interrupted())
-	{
-		throw InterruptedException();
-	}
-
-	if (duration > 0)
-	{
-		Thread* pThis = (Thread*) getThreadLocal().get();
-
-		if (pThis == NULL)
-		{
-			apr_sleep(duration * 1000);
-		}
-		else
-		{
-			synchronized sync(pThis->interruptedMutex);
-			apr_status_t stat = apr_thread_cond_timedwait(pThis->interruptedCondition,
-					pThis->interruptedMutex, duration * 1000);
-
-			if (stat != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(stat))
-			{
-				throw ThreadException(stat);
-			}
-
-			if (interrupted())
-			{
-				throw InterruptedException();
-			}
-		}
-	}
-
-#else
-
-	if (duration > 0)
-	{
-		apr_sleep(duration * 1000);
-	}
-
-#endif
-}
diff --git a/src/main/cpp/timebasedrollingpolicy.cpp b/src/main/cpp/timebasedrollingpolicy.cpp
index 2c29b6c..00014eb 100644
--- a/src/main/cpp/timebasedrollingpolicy.cpp
+++ b/src/main/cpp/timebasedrollingpolicy.cpp
@@ -181,16 +181,6 @@
 }
 #endif
 
-void TimeBasedRollingPolicy::addRef() const
-{
-	TriggeringPolicy::addRef();
-}
-
-void TimeBasedRollingPolicy::releaseRef() const
-{
-	TriggeringPolicy::releaseRef();
-}
-
 void TimeBasedRollingPolicy::activateOptions(log4cxx::helpers::Pool& pool)
 {
 	// find out period from the filename pattern
@@ -292,15 +282,15 @@
 
 	if (currentActiveFile.length() > 0)
 	{
-		return new RolloverDescription(
-				currentActiveFile, append, noAction, noAction);
+        return RolloverDescriptionPtr(new RolloverDescription(
+                currentActiveFile, append, noAction, noAction));
 	}
 	else
 	{
 		bRefreshCurFile = true;
-		return new RolloverDescription(
+        return RolloverDescriptionPtr(new RolloverDescription(
 				lastFileName.substr(0, lastFileName.length() - suffixLength), append,
-				noAction, noAction);
+                noAction, noAction));
 	}
 }
 
@@ -358,24 +348,24 @@
 	//        and requires a rename plus maintaining the same name
 	if (currentActiveFile != lastBaseName)
 	{
-		renameAction =
+        renameAction = FileRenameActionPtr(
 			new FileRenameAction(
-			File().setPath(currentActiveFile), File().setPath(lastBaseName), true);
+            File().setPath(currentActiveFile), File().setPath(lastBaseName), true));
 		nextActiveFile = currentActiveFile;
 	}
 
 	if (suffixLength == 3)
 	{
-		compressAction =
+        compressAction = GZCompressActionPtr(
 			new GZCompressAction(
-			File().setPath(lastBaseName), File().setPath(lastFileName), true);
+            File().setPath(lastBaseName), File().setPath(lastFileName), true));
 	}
 
 	if (suffixLength == 4)
 	{
-		compressAction =
+        compressAction = ZipCompressActionPtr(
 			new ZipCompressAction(
-			File().setPath(lastBaseName), File().setPath(lastFileName), true);
+            File().setPath(lastBaseName), File().setPath(lastFileName), true));
 	}
 
 #ifdef LOG4CXX_MULTI_PROCESS
@@ -397,7 +387,7 @@
 	lastFileName = newFileName;
 #endif
 
-	return new RolloverDescription(nextActiveFile, append, renameAction, compressAction);
+    return RolloverDescriptionPtr(new RolloverDescription(nextActiveFile, append, renameAction, compressAction));
 }
 
 bool TimeBasedRollingPolicy::isTriggeringEvent(
diff --git a/src/main/cpp/timezone.cpp b/src/main/cpp/timezone.cpp
index 4809944..30570e1 100644
--- a/src/main/cpp/timezone.cpp
+++ b/src/main/cpp/timezone.cpp
@@ -276,7 +276,7 @@
 
 		s.append(mm);
 		apr_int32_t offset = sign * (hours * 3600 + minutes * 60);
-		return new log4cxx::helpers::TimeZoneImpl::FixedTimeZone( s, offset );
+        return TimeZonePtr(new log4cxx::helpers::TimeZoneImpl::FixedTimeZone( s, offset ));
 	}
 
 	const TimeZonePtr& ltz = getDefault();
diff --git a/src/main/cpp/transcoder.cpp b/src/main/cpp/transcoder.cpp
index 76e9361..177f3bb 100644
--- a/src/main/cpp/transcoder.cpp
+++ b/src/main/cpp/transcoder.cpp
@@ -24,8 +24,7 @@
 #include <log4cxx/helpers/charsetdecoder.h>
 #include <log4cxx/helpers/charsetencoder.h>
 #include <vector>
-#include <apr.h>
-#include <apr_strings.h>
+#include <cstring>
 #if !defined(LOG4CXX)
 	#define LOG4CXX 1
 #endif
@@ -536,7 +535,7 @@
 #endif
 	wchar_t* dst = (wchar_t*) p.palloc((tmp.length() + 1) * sizeof(wchar_t));
 	dst[tmp.length()] = 0;
-	memcpy(dst, tmp.data(), tmp.length() * sizeof(wchar_t));
+    std::memcpy(dst, tmp.data(), tmp.length() * sizeof(wchar_t));
 	return dst;
 }
 
diff --git a/src/main/cpp/triggeringpolicy.cpp b/src/main/cpp/triggeringpolicy.cpp
index 11b130b..f316a0f 100644
--- a/src/main/cpp/triggeringpolicy.cpp
+++ b/src/main/cpp/triggeringpolicy.cpp
@@ -26,13 +26,3 @@
 TriggeringPolicy::~TriggeringPolicy()
 {
 }
-
-void TriggeringPolicy::addRef() const
-{
-	ObjectImpl::addRef();
-}
-
-void TriggeringPolicy::releaseRef() const
-{
-	ObjectImpl::releaseRef();
-}
diff --git a/src/main/cpp/writerappender.cpp b/src/main/cpp/writerappender.cpp
index 6b8ee2b..80d85fd 100644
--- a/src/main/cpp/writerappender.cpp
+++ b/src/main/cpp/writerappender.cpp
@@ -17,7 +17,6 @@
 
 #include <log4cxx/writerappender.h>
 #include <log4cxx/helpers/loglog.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/layout.h>
 #include <log4cxx/helpers/stringhelper.h>
 
@@ -29,57 +28,54 @@
 
 WriterAppender::WriterAppender()
 {
-	LOCK_W sync(mutex);
-	immediateFlush = true;
+    immediateFlush = true;
 }
 
 WriterAppender::WriterAppender(const LayoutPtr& layout1,
-	log4cxx::helpers::WriterPtr& writer1)
-	: AppenderSkeleton(layout1), writer(writer1)
+                               log4cxx::helpers::WriterPtr& writer1)
+    : AppenderSkeleton(layout1), writer(writer1)
 {
-	Pool p;
-	LOCK_W sync(mutex);
-	immediateFlush = true;
-	activateOptions(p);
+    Pool p;
+    immediateFlush = true;
+    activateOptions(p);
 }
 
 WriterAppender::WriterAppender(const LayoutPtr& layout1)
-	: AppenderSkeleton(layout1)
+    : AppenderSkeleton(layout1)
 {
-	LOCK_W sync(mutex);
-	immediateFlush = true;
+    immediateFlush = true;
 }
 
 
 WriterAppender::~WriterAppender()
 {
-	finalize();
+    finalize();
 }
 
 void WriterAppender::activateOptions(Pool& p)
 {
-	int errors = 0;
+    int errors = 0;
 
-	if (layout == 0)
-	{
-		errorHandler->error(
-			((LogString) LOG4CXX_STR("No layout set for the appender named ["))
-			+ name + LOG4CXX_STR("]."));
-		errors++;
-	}
+    if (layout == 0)
+    {
+        errorHandler->error(
+            ((LogString) LOG4CXX_STR("No layout set for the appender named ["))
+            + name + LOG4CXX_STR("]."));
+        errors++;
+    }
 
-	if (writer == 0)
-	{
-		errorHandler->error(
-			((LogString) LOG4CXX_STR("No writer set for the appender named ["))
-			+ name + LOG4CXX_STR("]."));
-		errors++;
-	}
+    if (writer == 0)
+    {
+        errorHandler->error(
+            ((LogString) LOG4CXX_STR("No writer set for the appender named ["))
+            + name + LOG4CXX_STR("]."));
+        errors++;
+    }
 
-	if (errors == 0)
-	{
-		AppenderSkeleton::activateOptions(p);
-	}
+    if (errors == 0)
+    {
+        AppenderSkeleton::activateOptions(p);
+    }
 }
 
 
@@ -87,12 +83,12 @@
 void WriterAppender::append(const spi::LoggingEventPtr& event, Pool& pool1)
 {
 
-	if (!checkEntryConditions())
-	{
-		return;
-	}
+    if (!checkEntryConditions())
+    {
+        return;
+    }
 
-	subAppend(event, pool1);
+    subAppend(event, pool1);
 }
 
 /**
@@ -103,42 +99,42 @@
    value <code>false</code> is returned. */
 bool WriterAppender::checkEntryConditions() const
 {
-	static bool warnedClosed = false;
-	static bool warnedNoWriter = false;
+    static bool warnedClosed = false;
+    static bool warnedNoWriter = false;
 
-	if (closed)
-	{
-		if (!warnedClosed)
-		{
-			LogLog::warn(LOG4CXX_STR("Not allowed to write to a closed appender."));
-			warnedClosed = true;
-		}
+    if (closed)
+    {
+        if (!warnedClosed)
+        {
+            LogLog::warn(LOG4CXX_STR("Not allowed to write to a closed appender."));
+            warnedClosed = true;
+        }
 
-		return false;
-	}
+        return false;
+    }
 
-	if (writer == 0)
-	{
-		if (warnedNoWriter)
-		{
-			errorHandler->error(
-				LogString(LOG4CXX_STR("No output stream or file set for the appender named [")) +
-				name + LOG4CXX_STR("]."));
-			warnedNoWriter = true;
-		}
+    if (writer == 0)
+    {
+        if (warnedNoWriter)
+        {
+            errorHandler->error(
+                LogString(LOG4CXX_STR("No output stream or file set for the appender named [")) +
+                name + LOG4CXX_STR("]."));
+            warnedNoWriter = true;
+        }
 
-		return false;
-	}
+        return false;
+    }
 
-	if (layout == 0)
-	{
-		errorHandler->error(
-			LogString(LOG4CXX_STR("No layout set for the appender named [")) +
-			name + LOG4CXX_STR("]."));
-		return false;
-	}
+    if (layout == 0)
+    {
+        errorHandler->error(
+            LogString(LOG4CXX_STR("No layout set for the appender named [")) +
+            name + LOG4CXX_STR("]."));
+        return false;
+    }
 
-	return true;
+    return true;
 }
 
 
@@ -154,15 +150,15 @@
    */
 void WriterAppender::close()
 {
-	LOCK_W sync(mutex);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
 
-	if (closed)
-	{
-		return;
-	}
+    if (closed)
+    {
+        return;
+    }
 
-	closed = true;
-	closeWriter();
+    closed = true;
+    closeWriter();
 }
 
 /**
@@ -170,24 +166,24 @@
  * */
 void WriterAppender::closeWriter()
 {
-	if (writer != NULL)
-	{
-		try
-		{
-			// before closing we have to output out layout's footer
-			//
-			//   Using the object's pool since this is a one-shot operation
-			//    and pool is likely to be reclaimed soon when appender is destructed.
-			//
-			writeFooter(pool);
-			writer->close(pool);
-			writer = 0;
-		}
-		catch (IOException& e)
-		{
-			LogLog::error(LogString(LOG4CXX_STR("Could not close writer for WriterAppender named ")) + name, e);
-		}
-	}
+    if (writer != NULL)
+    {
+        try
+        {
+            // before closing we have to output out layout's footer
+            //
+            //   Using the object's pool since this is a one-shot operation
+            //    and pool is likely to be reclaimed soon when appender is destructed.
+            //
+            writeFooter(pool);
+            writer->close(pool);
+            writer = 0;
+        }
+        catch (IOException& e)
+        {
+            LogLog::error(LogString(LOG4CXX_STR("Could not close writer for WriterAppender named ")) + name, e);
+        }
+    }
 
 }
 
@@ -200,117 +196,114 @@
 WriterPtr WriterAppender::createWriter(OutputStreamPtr& os)
 {
 
-	LogString enc(getEncoding());
+    LogString enc(getEncoding());
 
-	CharsetEncoderPtr encoder;
+    CharsetEncoderPtr encoder;
 
-	if (enc.empty())
-	{
-		encoder = CharsetEncoder::getDefaultEncoder();
-	}
-	else
-	{
-		if (StringHelper::equalsIgnoreCase(enc,
-				LOG4CXX_STR("utf-16"), LOG4CXX_STR("UTF-16")))
-		{
-			encoder = CharsetEncoder::getEncoder(LOG4CXX_STR("UTF-16BE"));
-		}
-		else
-		{
-			encoder = CharsetEncoder::getEncoder(enc);
-		}
+    if (enc.empty())
+    {
+        encoder = CharsetEncoder::getDefaultEncoder();
+    }
+    else
+    {
+        if (StringHelper::equalsIgnoreCase(enc,
+                                           LOG4CXX_STR("utf-16"), LOG4CXX_STR("UTF-16")))
+        {
+            encoder = CharsetEncoder::getEncoder(LOG4CXX_STR("UTF-16BE"));
+        }
+        else
+        {
+            encoder = CharsetEncoder::getEncoder(enc);
+        }
 
-		if (encoder == NULL)
-		{
-			encoder = CharsetEncoder::getDefaultEncoder();
-			LogLog::warn(LOG4CXX_STR("Error initializing output writer."));
-			LogLog::warn(LOG4CXX_STR("Unsupported encoding?"));
-		}
-	}
+        if (encoder == NULL)
+        {
+            encoder = CharsetEncoder::getDefaultEncoder();
+            LogLog::warn(LOG4CXX_STR("Error initializing output writer."));
+            LogLog::warn(LOG4CXX_STR("Unsupported encoding?"));
+        }
+    }
 
-	return new OutputStreamWriter(os, encoder);
+    return WriterPtr(new OutputStreamWriter(os, encoder));
 }
 
 LogString WriterAppender::getEncoding() const
 {
-	return encoding;
+    return encoding;
 }
 
 void WriterAppender::setEncoding(const LogString& enc)
 {
-	encoding = enc;
+    encoding = enc;
 }
 
 void WriterAppender::subAppend(const spi::LoggingEventPtr& event, Pool& p)
 {
-	LogString msg;
-	layout->format(msg, event, p);
-	{
-		LOCK_W sync(mutex);
+    LogString msg;
+    layout->format(msg, event, p);
+    if (writer != NULL)
+    {
+        writer->write(msg, p);
 
-		if (writer != NULL)
-		{
-			writer->write(msg, p);
-
-			if (immediateFlush)
-			{
-				writer->flush(p);
-			}
-		}
-	}
+        if (immediateFlush)
+        {
+            writer->flush(p);
+        }
+    }
 }
 
 
 void WriterAppender::writeFooter(Pool& p)
 {
-	if (layout != NULL)
-	{
-		LogString foot;
-		layout->appendFooter(foot, p);
-		LOCK_W sync(mutex);
-		writer->write(foot, p);
-	}
+    if (layout != NULL)
+    {
+        LogString foot;
+        layout->appendFooter(foot, p);
+        writer->write(foot, p);
+    }
 }
 
 void WriterAppender::writeHeader(Pool& p)
 {
-	if (layout != NULL)
-	{
-		LogString header;
-		layout->appendHeader(header, p);
-		LOCK_W sync(mutex);
-		writer->write(header, p);
-	}
+    if (layout != NULL)
+    {
+        LogString header;
+        layout->appendHeader(header, p);
+        writer->write(header, p);
+    }
 }
 
 
 void WriterAppender::setWriter(const WriterPtr& newWriter)
 {
-	LOCK_W sync(mutex);
-	writer = newWriter;
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+    setWriterInternal(newWriter);
 }
 
+void WriterAppender::setWriterInternal(const WriterPtr& newWriter)
+{
+    writer = newWriter;
+}
 
 bool WriterAppender::requiresLayout() const
 {
-	return true;
+    return true;
 }
 
 void WriterAppender::setOption(const LogString& option, const LogString& value)
 {
-	if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("ENCODING"), LOG4CXX_STR("encoding")))
-	{
-		setEncoding(value);
-	}
-	else
-	{
-		AppenderSkeleton::setOption(option, value);
-	}
+    if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("ENCODING"), LOG4CXX_STR("encoding")))
+    {
+        setEncoding(value);
+    }
+    else
+    {
+        AppenderSkeleton::setOption(option, value);
+    }
 }
 
 
 void WriterAppender::setImmediateFlush(bool value)
 {
-	LOCK_W sync(mutex);
-	immediateFlush = value;
+    immediateFlush = value;
 }
diff --git a/src/main/cpp/xmlsocketappender.cpp b/src/main/cpp/xmlsocketappender.cpp
index 98356db..523ab52 100644
--- a/src/main/cpp/xmlsocketappender.cpp
+++ b/src/main/cpp/xmlsocketappender.cpp
@@ -24,8 +24,6 @@
 #include <log4cxx/xml/xmllayout.h>
 #include <log4cxx/level.h>
 #include <log4cxx/helpers/transform.h>
-#include <apr_time.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/transcoder.h>
 #include <log4cxx/helpers/socketoutputstream.h>
 
@@ -47,13 +45,13 @@
 XMLSocketAppender::XMLSocketAppender()
 	: SocketAppenderSkeleton(DEFAULT_PORT, DEFAULT_RECONNECTION_DELAY)
 {
-	layout = new XMLLayout();
+    layout = XMLLayoutPtr(new XMLLayout());
 }
 
 XMLSocketAppender::XMLSocketAppender(InetAddressPtr address1, int port1)
 	: SocketAppenderSkeleton(address1, port1, DEFAULT_RECONNECTION_DELAY)
 {
-	layout = new XMLLayout();
+    layout = XMLLayoutPtr(new XMLLayout());
 	Pool p;
 	activateOptions(p);
 }
@@ -61,7 +59,7 @@
 XMLSocketAppender::XMLSocketAppender(const LogString& host, int port1)
 	: SocketAppenderSkeleton(host, port1, DEFAULT_RECONNECTION_DELAY)
 {
-	layout = new XMLLayout();
+    layout = XMLLayoutPtr(new XMLLayout());
 	Pool p;
 	activateOptions(p);
 }
@@ -86,8 +84,8 @@
 {
 	OutputStreamPtr os(new SocketOutputStream(socket));
 	CharsetEncoderPtr charset(CharsetEncoder::getUTF8Encoder());
-	LOCK_W sync(mutex);
-	writer = new OutputStreamWriter(os, charset);
+	log4cxx::unique_lock<log4cxx::shared_mutex> lock(mutex);
+    writer = OutputStreamWriterPtr(new OutputStreamWriter(os, charset));
 }
 
 void XMLSocketAppender::cleanUp(Pool& p)
diff --git a/src/main/include/CMakeLists.txt b/src/main/include/CMakeLists.txt
index 97f286d..ca007bb 100644
--- a/src/main/include/CMakeLists.txt
+++ b/src/main/include/CMakeLists.txt
@@ -1,33 +1,29 @@
 # Configure
+
 if(WIN32)
-add_custom_target(configure_log4cxx
-  COMMAND "${CMAKE_COMMAND}" -E copy_if_different
-    ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/log4cxx.hw
-    ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/log4cxx.h
-  COMMAND "${CMAKE_COMMAND}" -E copy_if_different
-    ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/private/log4cxx_private.hw
-    ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/private/log4cxx_private.h
-  DEPENDS
-    ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/log4cxx.hw
-    ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/private/log4cxx_private.hw
-)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/version_info.h.in
-               ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/version_info.h
-               @ONLY
-)
+    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/version_info.h.in
+	           ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/version_info.h
+		   @ONLY
+    )
+    set(LOG4CXX_CHAR "utf-8" CACHE STRING "Interal character representation, choice of utf-8, wchar_t(default), unichar")
+    set_property(CACHE LOG4CXX_CHAR PROPERTY STRINGS "utf-8" "wchar_t" "unichar")
+    set(LOGCHAR_IS_UNICHAR 0)
+    set(LOGCHAR_IS_WCHAR 1)
+    set(LOGCHAR_IS_UTF8 0)
 else()
+    set(LOG4CXX_CHAR "utf-8" CACHE STRING "Interal character representation, choice of utf-8 (default), wchar_t, unichar")
+    set_property(CACHE LOG4CXX_CHAR PROPERTY STRINGS "utf-8" "wchar_t" "unichar")
+    set(LOGCHAR_IS_UNICHAR 0)
+    set(LOGCHAR_IS_WCHAR 0)
+    set(LOGCHAR_IS_UTF8 1)
+endif()
+
 # Configure log4cxx.h
-set(LOG4CXX_CHAR "utf-8" CACHE STRING "Interal character representation, choice of utf-8 (default), wchar_t, unichar")
-set_property(CACHE LOG4CXX_CHAR PROPERTY STRINGS "utf-8" "wchar_t" "unichar")
-set(LOGCHAR_IS_UNICHAR 0)
-set(LOGCHAR_IS_WCHAR 0)
-set(LOGCHAR_IS_UTF8 0)
+
 if(${LOG4CXX_CHAR} STREQUAL "unichar")
   set(LOGCHAR_IS_UNICHAR 1)
 elseif(${LOG4CXX_CHAR} STREQUAL "wchar_t")
   set(LOGCHAR_IS_WCHAR 1)
-else()
-  set(LOGCHAR_IS_UTF8 1)
 endif()
 option(LOG4CXX_WCHAR_T "Enable wchar_t API methods" ON)
 option(LOG4CXX_UNICHAR "Enable UniChar API methods" OFF)
@@ -44,10 +40,7 @@
     set("${varName}_API" 0)
   endif()
 endforeach()
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/log4cxx.h.in
-               ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/log4cxx.h
-               @ONLY
-)
+
 
 # Configure log4cxx_private.h
 set(LOG4CXX_CHARSET "locale" CACHE STRING "LogString characters, choice of locale (default), utf-8, ISO-8859-1, US-ASCII, EBCDIC")
@@ -97,17 +90,24 @@
   endif()
 endforeach()
 
+# Check for standard headers that we need, fall back to boost if they're not found
+include(${CMAKE_SOURCE_DIR}/src/cmake/boost-fallback/boost-fallback.cmake)
+set(NAMESPACE_ALIAS log4cxx)
 
+# Configure both our private header and our public header
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/private/log4cxx_private.h.in
                ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/private/log4cxx_private.h
                @ONLY
 )
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/log4cxx.h.in
+               ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/log4cxx.h
+	       @ONLY
+)
+configure_file(${CMAKE_SOURCE_DIR}/src/cmake/boost-fallback/boost-std-configuration.h.cmake
+                ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/boost-std-configuration.h
+)
 
 # Provide the dependencies
 add_custom_target(configure_log4cxx
   COMMAND "${CMAKE_COMMAND}" -E echo "Checking configuration"
-  DEPENDS
-    ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/log4cxx.h.in
-    ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/private/log4cxx_private.h.in
 )
-endif()
diff --git a/src/main/include/log4cxx/appender.h b/src/main/include/log4cxx/appender.h
index 0f58dfc..d3c3b76 100644
--- a/src/main/include/log4cxx/appender.h
+++ b/src/main/include/log4cxx/appender.h
@@ -25,7 +25,6 @@
 
 
 #include <log4cxx/spi/optionhandler.h>
-#include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/helpers/object.h>
 #include <vector>
 
@@ -36,17 +35,17 @@
 namespace spi
 {
 class LoggingEvent;
-typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
+typedef std::shared_ptr<LoggingEvent> LoggingEventPtr;
 
 class Filter;
-typedef helpers::ObjectPtrT<Filter> FilterPtr;
+typedef std::shared_ptr<Filter> FilterPtr;
 
 class ErrorHandler;
-typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
+typedef std::shared_ptr<ErrorHandler> ErrorHandlerPtr;
 }
 
 class Layout;
-typedef log4cxx::helpers::ObjectPtrT<Layout> LayoutPtr;
+typedef std::shared_ptr<Layout> LayoutPtr;
 
 
 /**
@@ -61,6 +60,8 @@
 
 		virtual ~Appender() {}
 
+		void asdf();
+
 		/**
 		 Add a filter to the end of the filter list.
 		*/
diff --git a/src/main/include/log4cxx/appenderskeleton.h b/src/main/include/log4cxx/appenderskeleton.h
index 3face72..1d71fb0 100644
--- a/src/main/include/log4cxx/appenderskeleton.h
+++ b/src/main/include/log4cxx/appenderskeleton.h
@@ -28,12 +28,10 @@
 #include <log4cxx/layout.h>
 #include <log4cxx/spi/errorhandler.h>
 #include <log4cxx/spi/filter.h>
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/mutex.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/pool.h>
 #include <log4cxx/level.h>
 
-
 namespace log4cxx
 {
 /**
@@ -44,7 +42,7 @@
 * */
 class LOG4CXX_EXPORT AppenderSkeleton :
 	public virtual Appender,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	protected:
 		/** The layout variable does not need to be set if the appender
@@ -76,7 +74,7 @@
 		bool closed;
 
 		log4cxx::helpers::Pool pool;
-		mutable SHARED_MUTEX mutex;
+		mutable log4cxx::shared_mutex mutex;
 
 		/**
 		Subclasses of <code>AppenderSkeleton</code> should implement this
@@ -98,9 +96,6 @@
 		AppenderSkeleton();
 		AppenderSkeleton(const LayoutPtr& layout);
 
-		void addRef() const;
-		void releaseRef() const;
-
 		/**
 		Finalize this appender by calling the derived class'
 		<code>close</code> method.
@@ -196,7 +191,7 @@
 		/**
 		Set the {@link spi::ErrorHandler ErrorHandler} for this Appender.
 		*/
-		void setErrorHandler(const spi::ErrorHandlerPtr& eh);
+        void setErrorHandler(const spi::ErrorHandlerPtr eh);
 
 		/**
 		Set the layout for this appender. Note that some appenders have
diff --git a/src/main/include/log4cxx/asyncappender.h b/src/main/include/log4cxx/asyncappender.h
index fcd4cdf..545c1ae 100644
--- a/src/main/include/log4cxx/asyncappender.h
+++ b/src/main/include/log4cxx/asyncappender.h
@@ -28,9 +28,6 @@
 #include <log4cxx/helpers/appenderattachableimpl.h>
 #include <deque>
 #include <log4cxx/spi/loggingevent.h>
-#include <log4cxx/helpers/thread.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/condition.h>
 
 #if defined(NON_BLOCKING)
 	#include <boost/lockfree/queue.hpp>
@@ -76,15 +73,12 @@
 		 */
 		virtual ~AsyncAppender();
 
-		void addRef() const;
-		void releaseRef() const;
-
 		/**
 		 * Add appender.
 		 *
 		 * @param newAppender appender to add, may not be null.
 		*/
-		void addAppender(const AppenderPtr& newAppender);
+        void addAppender(const AppenderPtr newAppender);
 
 		virtual void doAppend(const spi::LoggingEventPtr& event,
 			log4cxx::helpers::Pool& pool1);
@@ -124,7 +118,7 @@
 		* @param appender appender.
 		* @return true if attached.
 		*/
-		bool isAttached(const AppenderPtr& appender) const;
+        bool isAttached(const AppenderPtr appender) const;
 
 		virtual bool requiresLayout() const;
 
@@ -137,7 +131,7 @@
 		 * Removes an appender.
 		 * @param appender appender to remove.
 		*/
-		void removeAppender(const AppenderPtr& appender);
+        void removeAppender(const AppenderPtr appender);
 		/**
 		* Remove appender by name.
 		* @param name name.
@@ -211,14 +205,14 @@
 		/**
 		 *  Mutex used to guard access to buffer and discardMap.
 		 */
-		SHARED_MUTEX bufferMutex;
+		log4cxx::mutex bufferMutex;
 
 #if defined(NON_BLOCKING)
 		::log4cxx::helpers::Semaphore bufferNotFull;
 		::log4cxx::helpers::Semaphore bufferNotEmpty;
 #else
-		::log4cxx::helpers::Condition bufferNotFull;
-		::log4cxx::helpers::Condition bufferNotEmpty;
+		log4cxx::condition_variable bufferNotFull;
+		log4cxx::condition_variable bufferNotEmpty;
 #endif
 		class DiscardSummary
 		{
@@ -283,7 +277,7 @@
 		/**
 		 *  Dispatcher.
 		 */
-		helpers::Thread dispatcher;
+		log4cxx::thread dispatcher;
 
 		/**
 		 * Should location info be included in dispatched messages.
@@ -298,7 +292,7 @@
 		/**
 		 *  Dispatch routine.
 		 */
-		static void* LOG4CXX_THREAD_FUNC dispatch(apr_thread_t* thread, void* data);
+		void dispatch();
 
 }; // class AsyncAppender
 LOG4CXX_PTR_DEF(AsyncAppender);
diff --git a/src/main/include/log4cxx/basicconfigurator.h b/src/main/include/log4cxx/basicconfigurator.h
index 739ecda..282f66e 100644
--- a/src/main/include/log4cxx/basicconfigurator.h
+++ b/src/main/include/log4cxx/basicconfigurator.h
@@ -18,8 +18,7 @@
 #ifndef _LOG4CXX_BASIC_CONFIGURATOR_H
 #define _LOG4CXX_BASIC_CONFIGURATOR_H
 
-#include <log4cxx/helpers/objectptr.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/logger.h>
 #include <log4cxx/logstring.h>
 #include <log4cxx/spi/configurator.h>
@@ -27,7 +26,7 @@
 namespace log4cxx
 {
 class Appender;
-typedef helpers::ObjectPtrT<Appender> AppenderPtr;
+typedef std::shared_ptr<Appender> AppenderPtr;
 
 /**
 Use this class to quickly configure the package.
diff --git a/src/main/include/log4cxx/config/propertysetter.h b/src/main/include/log4cxx/config/propertysetter.h
index dcbf4ed..3c70fb2 100644
--- a/src/main/include/log4cxx/config/propertysetter.h
+++ b/src/main/include/log4cxx/config/propertysetter.h
@@ -19,14 +19,14 @@
 #define _LOG4CXX_CONFIG_PROPERTYSETTER_H
 
 #include <log4cxx/logstring.h>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 
 namespace log4cxx
 {
 namespace helpers
 {
 class Object;
-typedef ObjectPtrT<Object> ObjectPtr;
+typedef std::shared_ptr<Object> ObjectPtr;
 
 class Properties;
 class Pool;
diff --git a/src/main/include/log4cxx/dailyrollingfileappender.h b/src/main/include/log4cxx/dailyrollingfileappender.h
index e8384c6..96aa9f0 100644
--- a/src/main/include/log4cxx/dailyrollingfileappender.h
+++ b/src/main/include/log4cxx/dailyrollingfileappender.h
@@ -39,7 +39,7 @@
 namespace spi
 {
 class ErrorHandler;
-typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
+typedef std::shared_ptr<ErrorHandler> ErrorHandlerPtr;
 }
 
 
diff --git a/src/main/include/log4cxx/defaultconfigurator.h b/src/main/include/log4cxx/defaultconfigurator.h
index 615937e..2e563bc 100644
--- a/src/main/include/log4cxx/defaultconfigurator.h
+++ b/src/main/include/log4cxx/defaultconfigurator.h
@@ -25,7 +25,7 @@
 namespace spi
 {
 class LoggerRepository;
-typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
+typedef std::shared_ptr<LoggerRepository> LoggerRepositoryPtr;
 }
 
 /**
@@ -42,7 +42,7 @@
 		Add a ConsoleAppender that uses PatternLayout
 		using the PatternLayout#TTCC_CONVERSION_PATTERN and
 		prints to <code>stdout</code> to the root logger.*/
-		static void configure(log4cxx::spi::LoggerRepository*);
+        static void configure(log4cxx::spi::LoggerRepositoryPtr repository);
 
 	private:
 		static const LogString getConfigurationFileName();
diff --git a/src/main/include/log4cxx/defaultloggerfactory.h b/src/main/include/log4cxx/defaultloggerfactory.h
index ba9255e..f0d5d3a 100644
--- a/src/main/include/log4cxx/defaultloggerfactory.h
+++ b/src/main/include/log4cxx/defaultloggerfactory.h
@@ -19,16 +19,16 @@
 #define _LOG4CXX_DEFAULT_LOGGER_FACTORY_H
 
 #include <log4cxx/spi/loggerfactory.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 
 namespace log4cxx
 {
 class Logger;
-typedef helpers::ObjectPtrT<Logger> LoggerPtr;
+typedef std::shared_ptr<Logger> LoggerPtr;
 
 class LOG4CXX_EXPORT DefaultLoggerFactory :
 	public virtual spi::LoggerFactory,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultLoggerFactory)
diff --git a/src/main/include/log4cxx/fileappender.h b/src/main/include/log4cxx/fileappender.h
index 1b737c1..9bc3f79 100644
--- a/src/main/include/log4cxx/fileappender.h
+++ b/src/main/include/log4cxx/fileappender.h
@@ -128,28 +128,6 @@
 		virtual void setFile(const LogString& file);
 
 		/**
-		Sets and <i>opens</i> the file where the log output will
-		go. The specified file must be writable.
-
-		<p>If there was already an opened file, then the previous file
-		is closed first.
-
-		<p><b>Do not use this method directly. To configure a FileAppender
-		or one of its subclasses, set its properties one by one and then
-		call activateOptions.</b>
-
-		@param file The path to the log file.
-		@param append If true will append to fileName. Otherwise will
-		truncate fileName.
-		@param bufferedIO Do we do bufferedIO?
-		@param bufferSize How big should the IO buffer be?
-		@param p memory pool for operation.
-		*/
-		virtual void setFile(const LogString& file, bool append,
-			bool bufferedIO, size_t bufferSize,
-			log4cxx::helpers::Pool& p);
-
-		/**
 		Returns the value of the <b>Append</b> option.
 		*/
 		inline bool getAppend() const
@@ -232,6 +210,35 @@
 		 */
 		static LogString stripDuplicateBackslashes(const LogString& name);
 
+protected:
+		void activateOptionsInternal(log4cxx::helpers::Pool& p);
+
+		/**
+		Sets and <i>opens</i> the file where the log output will
+		go. The specified file must be writable.
+
+		<p>If there was already an opened file, then the previous file
+		is closed first.
+
+		<p><b>Do not use this method directly. To configure a FileAppender
+		or one of its subclasses, set its properties one by one and then
+		call activateOptions.</b>
+
+		The mutex must be locked before calling this function.
+
+		@param file The path to the log file.
+		@param append If true will append to fileName. Otherwise will
+		truncate fileName.
+		@param bufferedIO Do we do bufferedIO?
+		@param bufferSize How big should the IO buffer be?
+		@param p memory pool for operation.
+		*/
+		void setFileInternal(const LogString& file, bool append,
+					bool bufferedIO, size_t bufferSize,
+					log4cxx::helpers::Pool& p);
+
+		void setFileInternal(const LogString& file);
+
 	private:
 		FileAppender(const FileAppender&);
 		FileAppender& operator=(const FileAppender&);
diff --git a/src/main/include/log4cxx/helpers/appenderattachableimpl.h b/src/main/include/log4cxx/helpers/appenderattachableimpl.h
index 4c3caeb..b71f7f7 100644
--- a/src/main/include/log4cxx/helpers/appenderattachableimpl.h
+++ b/src/main/include/log4cxx/helpers/appenderattachableimpl.h
@@ -25,16 +25,16 @@
 
 
 #include <log4cxx/spi/appenderattachable.h>
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/mutex.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/pool.h>
+#include <log4cxx/log4cxx.h>
 
 namespace log4cxx
 {
 namespace spi
 {
 class LoggingEvent;
-typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
+typedef log4cxx::shared_ptr<LoggingEvent> LoggingEventPtr;
 }
 
 namespace helpers
@@ -42,7 +42,7 @@
 
 class LOG4CXX_EXPORT AppenderAttachableImpl :
 	public virtual spi::AppenderAttachable,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	protected:
 		/** Array of appenders. */
@@ -61,14 +61,11 @@
 		LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
 		END_LOG4CXX_CAST_MAP()
 
-		void addRef() const;
-		void releaseRef() const;
-
 		// Methods
 		/**
 		 * Add an appender.
 		 */
-		virtual void addAppender(const AppenderPtr& newAppender);
+        virtual void addAppender(const AppenderPtr newAppender);
 
 		/**
 		 Call the <code>doAppend</code> method on all attached appenders.
@@ -90,7 +87,7 @@
 		 Returns <code>true</code> if the specified appender is in the
 		 list of attached appenders, <code>false</code> otherwise.
 		*/
-		virtual bool isAttached(const AppenderPtr& appender) const;
+        virtual bool isAttached(const AppenderPtr appender) const;
 
 		/**
 		 * Remove all previously added appenders.
@@ -100,7 +97,7 @@
 		/**
 		 * Remove the appender passed as parameter from the list of appenders.
 		 */
-		virtual void removeAppender(const AppenderPtr& appender);
+        virtual void removeAppender(const AppenderPtr appender);
 
 		/**
 		 * Remove the appender with the name passed as parameter from the
@@ -108,13 +105,13 @@
 		 */
 		virtual void removeAppender(const LogString& name);
 
-		inline const log4cxx::helpers::Mutex& getMutex() const
+		inline mutex& getMutex() const
 		{
-			return mutex;
+			return m_mutex;
 		}
 
 	private:
-		log4cxx::helpers::Mutex mutex;
+		mutable mutex m_mutex;
 		AppenderAttachableImpl(const AppenderAttachableImpl&);
 		AppenderAttachableImpl& operator=(const AppenderAttachableImpl&);
 };
diff --git a/src/main/include/log4cxx/helpers/aprinitializer.h b/src/main/include/log4cxx/helpers/aprinitializer.h
index b2f1f05..24202b9 100644
--- a/src/main/include/log4cxx/helpers/aprinitializer.h
+++ b/src/main/include/log4cxx/helpers/aprinitializer.h
@@ -58,7 +58,7 @@
 		APRInitializer(const APRInitializer&);
 		APRInitializer& operator=(const APRInitializer&);
 		apr_pool_t* p;
-		apr_thread_mutex_t* mutex;
+		log4cxx::mutex mutex;
 		std::list<FileWatchdog*> watchdogs;
 		apr_time_t startTime;
 		apr_threadkey_t* tlsKey;
diff --git a/src/main/include/log4cxx/helpers/charsetdecoder.h b/src/main/include/log4cxx/helpers/charsetdecoder.h
index 7b6e3f9..535cb08 100644
--- a/src/main/include/log4cxx/helpers/charsetdecoder.h
+++ b/src/main/include/log4cxx/helpers/charsetdecoder.h
@@ -18,7 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_CHARSETDECODER_H
 #define _LOG4CXX_HELPERS_CHARSETDECODER_H
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 
 namespace log4cxx
 {
@@ -33,7 +33,7 @@
 *   An abstract engine to transform a sequences of bytes in a specific charset
 *   into a LogString.
 */
-class LOG4CXX_EXPORT CharsetDecoder : public ObjectImpl
+class LOG4CXX_EXPORT CharsetDecoder : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(CharsetDecoder)
diff --git a/src/main/include/log4cxx/helpers/charsetencoder.h b/src/main/include/log4cxx/helpers/charsetencoder.h
index 1a1c3ae..c54e35d 100644
--- a/src/main/include/log4cxx/helpers/charsetencoder.h
+++ b/src/main/include/log4cxx/helpers/charsetencoder.h
@@ -18,7 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_CHARSETENCODER_H
 #define _LOG4CXX_HELPERS_CHARSETENCODER_H
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/pool.h>
 
 namespace log4cxx
@@ -34,7 +34,7 @@
 *   An engine to transform LogStrings into bytes
 *     for the specific character set.
 */
-class LOG4CXX_EXPORT CharsetEncoder : public ObjectImpl
+class LOG4CXX_EXPORT CharsetEncoder : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(CharsetEncoder)
diff --git a/src/main/include/log4cxx/helpers/class.h b/src/main/include/log4cxx/helpers/class.h
index 7c9fdf6..ed39924 100644
--- a/src/main/include/log4cxx/helpers/class.h
+++ b/src/main/include/log4cxx/helpers/class.h
@@ -25,7 +25,6 @@
 
 
 #include <log4cxx/logstring.h>
-#include <log4cxx/helpers/objectptr.h>
 #include <map>
 
 namespace log4cxx
@@ -33,14 +32,13 @@
 namespace helpers
 {
 class Object;
-typedef ObjectPtrT<Object> ObjectPtr;
 
 
 class LOG4CXX_EXPORT Class
 {
 	public:
 		virtual ~Class();
-		virtual ObjectPtr newInstance() const;
+        virtual Object* newInstance() const;
 		LogString toString() const;
 		virtual LogString getName() const = 0;
 		static const Class& forName(const LogString& className);
@@ -56,8 +54,8 @@
 		static ClassMap& getRegistry();
 		static void registerClasses();
 };
-}  // namespace log4cxx
-} // namespace helper
+}  // namespace helpers
+} // namespace log4cxx
 
 #if defined(_MSC_VER)
 	#pragma warning (pop)
diff --git a/src/main/include/log4cxx/helpers/condition.h b/src/main/include/log4cxx/helpers/condition.h
deleted file mode 100644
index 9ceb790..0000000
--- a/src/main/include/log4cxx/helpers/condition.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_CONDITION_H
-#define _LOG4CXX_HELPERS_CONDITION_H
-
-#include <log4cxx/log4cxx.h>
-#include <log4cxx/helpers/mutex.h>
-
-extern "C" {
-	struct apr_thread_cond_t;
-}
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Pool;
-
-/**
- *   This class provides a means for one thread to suspend exception until
- *   notified by another thread to resume.  This class should have
- *   similar semantics to java.util.concurrent.locks.Condition.
- */
-class LOG4CXX_EXPORT Condition
-{
-	public:
-		/**
-		 *  Create new instance.
-		 *  @param p pool on which condition will be created.  Needs to be
-		 *  longer-lived than created instance.
-		 */
-		Condition(log4cxx::helpers::Pool& p);
-		/**
-		 *  Destructor.
-		 */
-		~Condition();
-		/**
-		 *   Signal all waiting threads.
-		 */
-		log4cxx_status_t signalAll();
-		/**
-		 *  Await signaling of condition.
-		 *  @param lock lock associated with condition, calling thread must
-		 *  own lock.  Lock will be released while waiting and reacquired
-		 *  before returning from wait.
-		 *  @throws InterruptedException if thread is interrupted.
-		 */
-		void await(Mutex& lock);
-
-	private:
-		apr_thread_cond_t* condition;
-		Condition(const Condition&);
-		Condition& operator=(const Condition&);
-};
-} // namespace helpers
-} // namespace log4cxx
-
-#endif //_LOG4CXX_HELPERS_CONDITION_H
diff --git a/src/main/include/log4cxx/helpers/datagrampacket.h b/src/main/include/log4cxx/helpers/datagrampacket.h
index 093d0c6..1ac1f6b 100644
--- a/src/main/include/log4cxx/helpers/datagrampacket.h
+++ b/src/main/include/log4cxx/helpers/datagrampacket.h
@@ -18,8 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_DATAGRAM_PACKET
 #define _LOG4CXX_HELPERS_DATAGRAM_PACKET
 
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/inetaddress.h>
 
 namespace log4cxx
@@ -34,7 +33,7 @@
 packets sent from one machine to another might be routed differently,
 and might arrive in any order.
 */
-class LOG4CXX_EXPORT DatagramPacket : public helpers::ObjectImpl
+class LOG4CXX_EXPORT DatagramPacket : public helpers::Object
 {
 	protected:
 		/** the data for this packet. */
diff --git a/src/main/include/log4cxx/helpers/datagramsocket.h b/src/main/include/log4cxx/helpers/datagramsocket.h
index 619ae17..2f8924e 100644
--- a/src/main/include/log4cxx/helpers/datagramsocket.h
+++ b/src/main/include/log4cxx/helpers/datagramsocket.h
@@ -18,8 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_DATAGRAM_SOCKET_H
 #define _LOG4CXX_HELPERS_DATAGRAM_SOCKET_H
 
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/inetaddress.h>
 #include <log4cxx/helpers/pool.h>
 #include <log4cxx/helpers/datagrampacket.h>
@@ -34,7 +33,7 @@
 {
 /** This class represents a socket for sending and receiving
 datagram packets.*/
-class LOG4CXX_EXPORT DatagramSocket : public helpers::ObjectImpl
+class LOG4CXX_EXPORT DatagramSocket : public helpers::Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramSocket)
diff --git a/src/main/include/log4cxx/helpers/date.h b/src/main/include/log4cxx/helpers/date.h
index 0629994..facace7 100644
--- a/src/main/include/log4cxx/helpers/date.h
+++ b/src/main/include/log4cxx/helpers/date.h
@@ -18,7 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_DATE_H
 #define _LOG4CXX_HELPERS_DATE_H
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/log4cxx.h>
 
 
@@ -32,7 +32,7 @@
 *      internal strings.
 *
 */
-class LOG4CXX_EXPORT Date : public ObjectImpl
+class LOG4CXX_EXPORT Date : public Object
 {
 		const log4cxx_time_t time;
 
diff --git a/src/main/include/log4cxx/helpers/dateformat.h b/src/main/include/log4cxx/helpers/dateformat.h
index 39ff206..756bd8f 100644
--- a/src/main/include/log4cxx/helpers/dateformat.h
+++ b/src/main/include/log4cxx/helpers/dateformat.h
@@ -30,7 +30,7 @@
 *  DateFormat is an abstract class for date/time formatting
 * patterned after java.text.DateFormat.
 */
-class LOG4CXX_EXPORT DateFormat : public ObjectImpl
+class LOG4CXX_EXPORT DateFormat : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(DateFormat)
diff --git a/src/main/include/log4cxx/helpers/exception.h b/src/main/include/log4cxx/helpers/exception.h
index 2749544..0349927 100644
--- a/src/main/include/log4cxx/helpers/exception.h
+++ b/src/main/include/log4cxx/helpers/exception.h
@@ -119,16 +119,6 @@
 };
 
 
-class LOG4CXX_EXPORT MutexException : public Exception
-{
-	public:
-		MutexException(log4cxx_status_t stat);
-		MutexException(const MutexException& src);
-		MutexException& operator=(const MutexException&);
-	private:
-		static LogString formatMessage(log4cxx_status_t stat);
-};
-
 class LOG4CXX_EXPORT InterruptedException : public Exception
 {
 	public:
diff --git a/src/main/include/log4cxx/helpers/filewatchdog.h b/src/main/include/log4cxx/helpers/filewatchdog.h
index bc07d03..d88c3ad 100644
--- a/src/main/include/log4cxx/helpers/filewatchdog.h
+++ b/src/main/include/log4cxx/helpers/filewatchdog.h
@@ -21,8 +21,8 @@
 #include <log4cxx/logstring.h>
 #include <time.h>
 #include <log4cxx/helpers/pool.h>
-#include <log4cxx/helpers/thread.h>
 #include <log4cxx/file.h>
+#include <atomic>
 
 namespace log4cxx
 {
@@ -54,7 +54,7 @@
 		long delay;
 		log4cxx_time_t lastModif;
 		bool warnedAlready;
-		volatile unsigned int interrupted;
+		volatile int interrupted;
 
 	protected:
 		FileWatchdog(const File& filename);
@@ -73,9 +73,12 @@
 		void start();
 
 	private:
-		static void* LOG4CXX_THREAD_FUNC run(apr_thread_t* thread, void* data);
+		void run();
+		bool is_interrupted();
 		Pool pool;
-		Thread thread;
+		log4cxx::thread thread;
+		log4cxx::condition_variable interrupt;
+		log4cxx::mutex interrupt_mutex;
 
 		FileWatchdog(const FileWatchdog&);
 		FileWatchdog& operator=(const FileWatchdog&);
diff --git a/src/main/include/log4cxx/helpers/inetaddress.h b/src/main/include/log4cxx/helpers/inetaddress.h
index 53c0910..6205a1a 100644
--- a/src/main/include/log4cxx/helpers/inetaddress.h
+++ b/src/main/include/log4cxx/helpers/inetaddress.h
@@ -25,8 +25,7 @@
 
 
 
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/logstring.h>
 #include <vector>
 #include <log4cxx/helpers/exception.h>
@@ -48,7 +47,7 @@
 LOG4CXX_PTR_DEF(InetAddress);
 LOG4CXX_LIST_DEF(InetAddressList, InetAddressPtr);
 
-class LOG4CXX_EXPORT InetAddress : public ObjectImpl
+class LOG4CXX_EXPORT InetAddress : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(InetAddress)
diff --git a/src/main/include/log4cxx/helpers/inputstream.h b/src/main/include/log4cxx/helpers/inputstream.h
index 9f3acc5..5835964 100644
--- a/src/main/include/log4cxx/helpers/inputstream.h
+++ b/src/main/include/log4cxx/helpers/inputstream.h
@@ -18,7 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_INPUTSTREAM_H
 #define _LOG4CXX_HELPERS_INPUTSTREAM_H
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 
 namespace log4cxx
 {
@@ -31,7 +31,7 @@
  * Abstract class for reading from character streams.
  *
  */
-class LOG4CXX_EXPORT InputStream : public ObjectImpl
+class LOG4CXX_EXPORT InputStream : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(InputStream)
diff --git a/src/main/include/log4cxx/helpers/integer.h b/src/main/include/log4cxx/helpers/integer.h
index 241e44f..056cd4d 100644
--- a/src/main/include/log4cxx/helpers/integer.h
+++ b/src/main/include/log4cxx/helpers/integer.h
@@ -18,14 +18,14 @@
 #ifndef _LOG4CXX_HELPERS_INTEGER_H
 #define _LOG4CXX_HELPERS_INTEGER_H
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 
 
 namespace log4cxx
 {
 namespace helpers
 {
-class LOG4CXX_EXPORT Integer : public ObjectImpl
+class LOG4CXX_EXPORT Integer : public Object
 {
 		const int val;
 	public:
diff --git a/src/main/include/log4cxx/helpers/loader.h b/src/main/include/log4cxx/helpers/loader.h
index f8a5374..80b85a6 100644
--- a/src/main/include/log4cxx/helpers/loader.h
+++ b/src/main/include/log4cxx/helpers/loader.h
@@ -18,7 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_LOADER_H
 #define _LOG4CXX_HELPERS_LOADER_H
 
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/exception.h>
 #include <log4cxx/helpers/inputstream.h>
diff --git a/src/main/include/log4cxx/helpers/loglog.h b/src/main/include/log4cxx/helpers/loglog.h
index 0f0b8b5..dd8db31 100644
--- a/src/main/include/log4cxx/helpers/loglog.h
+++ b/src/main/include/log4cxx/helpers/loglog.h
@@ -19,7 +19,6 @@
 #define _LOG4CXX_HELPERS_LOG_LOG_H
 
 #include <log4cxx/logstring.h>
-#include <log4cxx/helpers/mutex.h>
 #include <exception>
 
 namespace log4cxx
@@ -48,7 +47,7 @@
 		       In quietMode not even errors generate any output.
 		 */
 		bool quietMode;
-		Mutex mutex;
+		log4cxx::mutex mutex;
 		LogLog();
 		LogLog(const LogLog&);
 		LogLog& operator=(const LogLog&);
diff --git a/src/main/include/log4cxx/helpers/mutex.h b/src/main/include/log4cxx/helpers/mutex.h
deleted file mode 100644
index 67c73ad..0000000
--- a/src/main/include/log4cxx/helpers/mutex.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_MUTEX_H
-#define _LOG4CXX_HELPERS_MUTEX_H
-
-#include <log4cxx/log4cxx.h>
-
-#if defined(RW_MUTEX)
-	#include <apr_portable.h>
-	#include <atomic>
-#endif
-
-extern "C" {
-	struct apr_thread_mutex_t;
-	struct apr_pool_t;
-	struct apr_thread_rwlock_t;
-}
-
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Pool;
-
-class LOG4CXX_EXPORT Mutex
-{
-	public:
-		Mutex(log4cxx::helpers::Pool& p);
-		Mutex(apr_pool_t* p);
-		~Mutex();
-		apr_thread_mutex_t* getAPRMutex() const;
-
-	private:
-		Mutex(const Mutex&);
-		Mutex& operator=(const Mutex&);
-		apr_thread_mutex_t* mutex;
-};
-} // namespace helpers
-} // namespace log4cxx
-
-
-#if defined(RW_MUTEX)
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Pool;
-
-class LOG4CXX_EXPORT RWMutex
-{
-	public:
-		RWMutex(log4cxx::helpers::Pool& p);
-		RWMutex(apr_pool_t* p);
-		~RWMutex();
-
-		void rdLock() const;
-		void rdUnlock() const;
-
-		void wrLock() const;
-		void wrUnlock() const;
-
-	private:
-		mutable std::atomic<apr_os_thread_t> id;
-		mutable unsigned count;
-		RWMutex(const RWMutex&);
-		RWMutex& operator=(const RWMutex&);
-		apr_thread_rwlock_t* mutex;
-};
-} // namespace helpers
-} // namespace log4cxx
-
-#define SHARED_MUTEX log4cxx::helpers::RWMutex
-
-#else // no RW_MUTEX
-
-#define SHARED_MUTEX log4cxx::helpers::Mutex
-
-#endif // RW_MUTEX
-
-#define SHARED_MUTEX_INIT(mutex, p) mutex(p)
-
-#if defined(NON_BLOCKING)
-
-namespace log4cxx
-{
-namespace helpers
-{
-struct SemaphoreImpl;
-
-class LOG4CXX_EXPORT Semaphore
-{
-	public:
-		Semaphore(log4cxx::helpers::Pool& p);
-		~Semaphore();
-
-		void await() const;
-		void signalAll() const;
-
-	private:
-		Semaphore(const Semaphore&);
-		Semaphore& operator=(const Semaphore&);
-
-		SemaphoreImpl* impl;
-};
-} // namespace helpers
-} // namespace log4cxx
-
-#endif // NON_BLOCKING
-
-#endif //_LOG4CXX_HELPERS_MUTEX_H
diff --git a/src/main/include/log4cxx/helpers/object.h b/src/main/include/log4cxx/helpers/object.h
index 55f63cd..a266dbf 100644
--- a/src/main/include/log4cxx/helpers/object.h
+++ b/src/main/include/log4cxx/helpers/object.h
@@ -20,7 +20,6 @@
 
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/class.h>
-#include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/helpers/classregistration.h>
 
 
@@ -45,7 +44,7 @@
 			Clazz##object() : helpers::Class() {}\
 			virtual ~Clazz##object() {}\
 			virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \
-			virtual helpers::ObjectPtr newInstance() const\
+            virtual object* newInstance() const\
 			{\
 				return new object();\
 			}\
@@ -103,14 +102,25 @@
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(Object)
-		virtual ~Object() {}
-		virtual void addRef() const = 0;
-		virtual void releaseRef() const = 0;
+        virtual ~Object() {}
 		virtual bool instanceof(const Class& clazz) const = 0;
 		virtual const void* cast(const Class& clazz) const = 0;
 };
 LOG4CXX_PTR_DEF(Object);
 }
+
+template<typename Ret,
+         typename Type,
+         bool = std::is_base_of<Ret,helpers::Object>::value,
+         bool = std::is_base_of<Type,helpers::Object>::value>
+std::shared_ptr<Ret> cast(const std::shared_ptr<Type>& incoming){
+    Ret* casted = reinterpret_cast<Ret*>(const_cast<void*>(incoming->cast(Ret::getStaticClass())));
+    if( casted ){
+        return std::shared_ptr<Ret>( incoming, casted );
+    }
+    return std::shared_ptr<Ret>();
+}
+
 }
 
 #define BEGIN_LOG4CXX_CAST_MAP()\
diff --git a/src/main/include/log4cxx/helpers/objectimpl.h b/src/main/include/log4cxx/helpers/objectimpl.h
deleted file mode 100644
index a638f56..0000000
--- a/src/main/include/log4cxx/helpers/objectimpl.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_OBJECT_IMPL_H
-#define _LOG4CXX_HELPERS_OBJECT_IMPL_H
-
-#include <log4cxx/helpers/object.h>
-
-namespace log4cxx
-{
-namespace helpers
-{
-/** Implementation class for Object.*/
-class LOG4CXX_EXPORT ObjectImpl : public virtual Object
-{
-	public:
-		ObjectImpl();
-		virtual ~ObjectImpl();
-		void addRef() const;
-		void releaseRef() const;
-
-	protected:
-		mutable unsigned int volatile ref;
-
-	private:
-		//
-		//   prevent object copy and assignment
-		//
-		ObjectImpl(const ObjectImpl&);
-		ObjectImpl& operator=(const ObjectImpl&);
-};
-}
-}
-
-#endif //_LOG4CXX_HELPERS_OBJECT_IMPL_H
diff --git a/src/main/include/log4cxx/helpers/objectoutputstream.h b/src/main/include/log4cxx/helpers/objectoutputstream.h
index 946e957..7763770 100644
--- a/src/main/include/log4cxx/helpers/objectoutputstream.h
+++ b/src/main/include/log4cxx/helpers/objectoutputstream.h
@@ -18,7 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_OBJECTOUTPUTSTREAM_H
 #define _LOG4CXX_HELPERS_OBJECTOUTPUTSTREAM_H
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/mdc.h>
 #include <log4cxx/helpers/outputstream.h>
 #include <log4cxx/helpers/charsetencoder.h>
@@ -30,7 +30,7 @@
 /**
  *  Emulates java serialization.
  */
-class LOG4CXX_EXPORT ObjectOutputStream : public ObjectImpl
+class LOG4CXX_EXPORT ObjectOutputStream : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(ObjectOutputStream)
diff --git a/src/main/include/log4cxx/helpers/objectptr.h b/src/main/include/log4cxx/helpers/objectptr.h
deleted file mode 100644
index a831dd9..0000000
--- a/src/main/include/log4cxx/helpers/objectptr.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_OBJECT_PTR_H
-#define _LOG4CXX_HELPERS_OBJECT_PTR_H
-
-#include <log4cxx/log4cxx.h>
-
-//
-//   Helgrind (race detection tool for Valgrind) will complain if pointer
-//   is not initialized in an atomic operation.  Static analysis tools
-//   (gcc's -Weffc++, for example) will complain if pointer is not initialized
-//   in member initialization list.  The use of a macro allows quick
-//   switching between the initialization styles.
-//
-#if LOG4CXX_HELGRIND
-	#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase() { exchange(x);
-#else
-	#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase(), p(x) {
-#endif
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Class;
-
-class LOG4CXX_EXPORT ObjectPtrBase
-{
-	public:
-		ObjectPtrBase();
-		virtual ~ObjectPtrBase();
-		static void checkNull(const int& null);
-		static void* exchange(void** destination, void* newValue);
-		virtual void* cast(const Class& cls) const = 0;
-};
-
-
-/** smart pointer to a Object descendant */
-template<typename T> class ObjectPtrT : public ObjectPtrBase
-{
-	public:
-		ObjectPtrT(const int& null)
-		_LOG4CXX_OBJECTPTR_INIT(0)
-		ObjectPtrBase::checkNull(null);
-}
-
-ObjectPtrT()
-_LOG4CXX_OBJECTPTR_INIT(0)
-}
-
-ObjectPtrT(T* p1)
-_LOG4CXX_OBJECTPTR_INIT(p1)
-
-if (this->p != 0)
-{
-	this->p->addRef();
-}
-}
-
-
-ObjectPtrT(const ObjectPtrT& p1)
-_LOG4CXX_OBJECTPTR_INIT(p1.p)
-
-if (this->p != 0)
-{
-	this->p->addRef();
-}
-}
-
-ObjectPtrT(const ObjectPtrBase& p1)
-_LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStaticClass())))
-
-if (this->p != 0)
-{
-	this->p->addRef();
-}
-}
-
-ObjectPtrT(ObjectPtrBase& p1)
-_LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStaticClass())))
-
-if (this->p != 0)
-{
-	this->p->addRef();
-}
-}
-
-
-~ObjectPtrT()
-{
-	if (p != 0)
-	{
-		p->releaseRef();
-	}
-}
-
-ObjectPtrT& operator=(const ObjectPtrT& p1)
-{
-	T* newPtr = p1.p;
-
-	if (newPtr != 0)
-	{
-		newPtr->addRef();
-	}
-
-	T* oldPtr = exchange(newPtr);
-
-	if (oldPtr != 0)
-	{
-		oldPtr->releaseRef();
-	}
-
-	return *this;
-}
-
-ObjectPtrT& operator=(const int& null)   //throw(IllegalArgumentException)
-{
-	//
-	//   throws IllegalArgumentException if null != 0
-	//
-	ObjectPtrBase::checkNull(null);
-	T* oldPtr = exchange(0);
-
-	if (oldPtr != 0)
-	{
-		oldPtr->releaseRef();
-	}
-
-	return *this;
-}
-
-ObjectPtrT& operator=(T* p1)
-{
-	if (p1 != 0)
-	{
-		p1->addRef();
-	}
-
-	T* oldPtr = exchange(p1);
-
-	if (oldPtr != 0)
-	{
-		oldPtr->releaseRef();
-	}
-
-	return *this;
-}
-
-
-ObjectPtrT& operator=(ObjectPtrBase& p1)
-{
-	T* newPtr = reinterpret_cast<T*>(p1.cast(T::getStaticClass()));
-	return operator=(newPtr);
-}
-
-ObjectPtrT& operator=(const ObjectPtrBase& p1)
-{
-	T* newPtr = reinterpret_cast<T*>(p1.cast(T::getStaticClass()));
-	return operator=(newPtr);
-}
-
-bool operator==(const ObjectPtrT& p1) const
-{
-	return (this->p == p1.p);
-}
-bool operator!=(const ObjectPtrT& p1) const
-{
-	return (this->p != p1.p);
-}
-bool operator<(const ObjectPtrT& p1) const
-{
-	return (this->p < p1.p);
-}
-bool operator==(const T* p1) const
-{
-	return (this->p == p1);
-}
-bool operator!=(const T* p1) const
-{
-	return (this->p != p1);
-}
-bool operator<(const T* p1) const
-{
-	return (this->p < p1);
-}
-T* operator->() const
-{
-	return p;
-}
-T& operator*() const
-{
-	return *p;
-}
-operator T* () const
-{
-	return p;
-}
-
-
-
-private:
-T* p;
-virtual void* cast(const Class& cls) const
-{
-	if (p != 0)
-	{
-		return const_cast<void*>(p->cast(cls));
-	}
-
-	return 0;
-}
-T* exchange(const T* newValue)
-{
-	// Avoid GCC strict aliasing warnings
-	union
-	{
-		T** in;
-		void** out;
-	} temp = { &p };
-	return static_cast<T*>(ObjectPtrBase::exchange(
-				temp.out,
-				const_cast<T*>(newValue)));
-}
-
-};
-
-
-}
-}
-
-#endif //_LOG4CXX_HELPERS_OBJECT_PTR_H
diff --git a/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h b/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h
index 47ea467..7561911 100644
--- a/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h
+++ b/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h
@@ -19,7 +19,7 @@
 #define _LOG4CXX_HELPERS_ONLY_ONCE_ERROR_HANDLER_H
 
 #include <log4cxx/spi/errorhandler.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 
 #ifdef _MSC_VER
 	#pragma warning ( push )
@@ -42,7 +42,7 @@
 */
 class LOG4CXX_EXPORT OnlyOnceErrorHandler :
 	public virtual spi::ErrorHandler,
-	public virtual ObjectImpl
+    public virtual Object
 {
 	private:
 		LogString WARN_PREFIX;
@@ -56,9 +56,7 @@
 		LOG4CXX_CAST_ENTRY(spi::ErrorHandler)
 		END_LOG4CXX_CAST_MAP()
 
-		OnlyOnceErrorHandler();
-		void addRef() const;
-		void releaseRef() const;
+        OnlyOnceErrorHandler();
 
 		/**
 		 Does not do anything.
diff --git a/src/main/include/log4cxx/helpers/optionconverter.h b/src/main/include/log4cxx/helpers/optionconverter.h
index f51777c..91e316f 100644
--- a/src/main/include/log4cxx/helpers/optionconverter.h
+++ b/src/main/include/log4cxx/helpers/optionconverter.h
@@ -19,18 +19,18 @@
 #define _LOG4CXX_HELPER_OPTION_CONVERTER_H
 
 #include <log4cxx/logstring.h>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 
 namespace log4cxx
 {
 class Level;
 class File;
-typedef helpers::ObjectPtrT<Level> LevelPtr;
+typedef std::shared_ptr<Level> LevelPtr;
 
 namespace spi
 {
 class LoggerRepository;
-typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
+typedef std::shared_ptr<LoggerRepository> LoggerRepositoryPtr;
 }
 
 namespace helpers
@@ -38,7 +38,7 @@
 class Properties;
 
 class Object;
-typedef ObjectPtrT<Object> ObjectPtr;
+typedef std::shared_ptr<Object> ObjectPtr;
 
 class Class;
 
@@ -155,7 +155,7 @@
 		@param hierarchy The Hierarchy to act on.
 		*/
 		static void selectAndConfigure(const File& configFileName,
-			const LogString& clazz, spi::LoggerRepositoryPtr& hierarchy);
+            const LogString& clazz, spi::LoggerRepositoryPtr hierarchy);
 };
 }  // namespace helpers
 } // namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/outputstream.h b/src/main/include/log4cxx/helpers/outputstream.h
index 58e1a62..a72e45f 100644
--- a/src/main/include/log4cxx/helpers/outputstream.h
+++ b/src/main/include/log4cxx/helpers/outputstream.h
@@ -18,7 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_OUTPUTSTREAM_H
 #define _LOG4CXX_HELPERS_OUTPUTSTREAM_H
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #ifdef LOG4CXX_MULTI_PROCESS
 	#include <apr_file_io.h>
 #endif
@@ -33,7 +33,7 @@
 /**
 *   Abstract class for writing to character streams.
 */
-class LOG4CXX_EXPORT OutputStream : public ObjectImpl
+class LOG4CXX_EXPORT OutputStream : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(OutputStream)
diff --git a/src/main/include/log4cxx/helpers/properties.h b/src/main/include/log4cxx/helpers/properties.h
index e1182d2..4ca5234 100644
--- a/src/main/include/log4cxx/helpers/properties.h
+++ b/src/main/include/log4cxx/helpers/properties.h
@@ -25,8 +25,7 @@
 
 
 #include <log4cxx/logstring.h>
-#include <log4cxx/helpers/objectptr.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/inputstream.h>
 #include <map>
 #include <vector>
diff --git a/src/main/include/log4cxx/helpers/reader.h b/src/main/include/log4cxx/helpers/reader.h
index d3ed41a..0b4e0d3 100644
--- a/src/main/include/log4cxx/helpers/reader.h
+++ b/src/main/include/log4cxx/helpers/reader.h
@@ -18,7 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_READER_H
 #define _LOG4CXX_HELPERS_READER_H
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 
 namespace log4cxx
 {
@@ -30,7 +30,7 @@
  * Abstract class for reading from character streams.
  *
  */
-class LOG4CXX_EXPORT Reader : public ObjectImpl
+class LOG4CXX_EXPORT Reader : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(Reader)
diff --git a/src/main/include/log4cxx/helpers/resourcebundle.h b/src/main/include/log4cxx/helpers/resourcebundle.h
index 56ada06..aed5ece 100644
--- a/src/main/include/log4cxx/helpers/resourcebundle.h
+++ b/src/main/include/log4cxx/helpers/resourcebundle.h
@@ -18,8 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_RESOURCE_BUNDLE_H
 #define _LOG4CXX_HELPERS_RESOURCE_BUNDLE_H
 
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 
 namespace log4cxx
 {
@@ -33,7 +32,7 @@
 /**
 Resource bundles contain locale-specific objects
 */
-class LOG4CXX_EXPORT ResourceBundle : public ObjectImpl
+class LOG4CXX_EXPORT ResourceBundle : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(ResourceBundle)
diff --git a/src/main/include/log4cxx/helpers/serversocket.h b/src/main/include/log4cxx/helpers/serversocket.h
index 322dcd0..e16b5c7 100644
--- a/src/main/include/log4cxx/helpers/serversocket.h
+++ b/src/main/include/log4cxx/helpers/serversocket.h
@@ -19,7 +19,6 @@
 #define _LOG4CXX_HELPERS_SERVER_SOCKET_H
 
 #include <log4cxx/helpers/socket.h>
-#include <log4cxx/helpers/mutex.h>
 
 namespace log4cxx
 {
@@ -53,7 +52,7 @@
 
 	private:
 		Pool pool;
-		Mutex mutex;
+		log4cxx::mutex mutex;
 		apr_socket_t* socket;
 		int timeout;
 
diff --git a/src/main/include/log4cxx/helpers/socket.h b/src/main/include/log4cxx/helpers/socket.h
index 4bfbd1f..9284490 100644
--- a/src/main/include/log4cxx/helpers/socket.h
+++ b/src/main/include/log4cxx/helpers/socket.h
@@ -40,7 +40,7 @@
 implementation, can configure itself to create sockets appropriate to the
 local firewall.
 */
-class LOG4CXX_EXPORT Socket : public helpers::ObjectImpl
+class LOG4CXX_EXPORT Socket : public helpers::Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(Socket)
diff --git a/src/main/include/log4cxx/helpers/synchronized.h b/src/main/include/log4cxx/helpers/synchronized.h
deleted file mode 100644
index ad0bf2f..0000000
--- a/src/main/include/log4cxx/helpers/synchronized.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_SYNCHRONIZED_H
-#define _LOG4CXX_HELPERS_SYNCHRONIZED_H
-#include <log4cxx/log4cxx.h>
-
-extern "C" {
-	typedef struct apr_thread_mutex_t apr_thread_mutex_t;
-}
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Mutex;
-
-/** utility class for objects multi-thread synchronization.*/
-class LOG4CXX_EXPORT synchronized
-{
-	public:
-		synchronized(const Mutex& mutex);
-		synchronized(apr_thread_mutex_t* mutex);
-		~synchronized();
-
-
-	private:
-		void* mutex;
-		//  prevent use of copy and assignment
-		synchronized(const synchronized&);
-		synchronized& operator=(const synchronized&);
-};
-}
-}
-
-#if defined(RW_MUTEX)
-
-namespace log4cxx
-{
-namespace helpers
-{
-class RWMutex;
-
-// utility class for objects multi-thread synchronization.
-class LOG4CXX_EXPORT synchronized_read
-{
-	public:
-		synchronized_read(const RWMutex& mutex);
-		~synchronized_read();
-
-
-	private:
-		const RWMutex& mutex;
-		//  prevent use of copy and assignment
-		synchronized_read(const synchronized_read&);
-		synchronized_read& operator=(const synchronized_read&);
-};
-}
-}
-
-namespace log4cxx
-{
-namespace helpers
-{
-class RWMutex;
-
-// utility class for objects multi-thread synchronization.
-class LOG4CXX_EXPORT synchronized_write
-{
-	public:
-		synchronized_write(const RWMutex& mutex);
-		~synchronized_write();
-
-
-	private:
-		const RWMutex& mutex;
-		//  prevent use of copy and assignment
-		synchronized_write(const synchronized_write&);
-		synchronized_write& operator=(const synchronized_write&);
-};
-}
-}
-
-#define LOCK_R synchronized_read
-#define LOCK_W synchronized_write
-
-#else
-
-#define LOCK_R synchronized
-#define LOCK_W synchronized
-
-#endif // RW_MUTEX
-
-#endif //_LOG4CXX_HELPERS_SYNCHRONIZED_H
diff --git a/src/main/include/log4cxx/helpers/syslogwriter.h b/src/main/include/log4cxx/helpers/syslogwriter.h
index 7063dfb..2071f01 100644
--- a/src/main/include/log4cxx/helpers/syslogwriter.h
+++ b/src/main/include/log4cxx/helpers/syslogwriter.h
@@ -19,7 +19,7 @@
 #define _LOG4CXX_SYSLOG_WRITER_H
 
 
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/inetaddress.h>
 #include <log4cxx/helpers/datagramsocket.h>
 
diff --git a/src/main/include/log4cxx/helpers/thread.h b/src/main/include/log4cxx/helpers/thread.h
deleted file mode 100644
index c131c03..0000000
--- a/src/main/include/log4cxx/helpers/thread.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_THREAD_H
-#define _LOG4CXX_HELPERS_THREAD_H
-
-#include <log4cxx/log4cxx.h>
-#include <log4cxx/helpers/pool.h>
-
-#if !defined(LOG4CXX_THREAD_FUNC)
-	#if defined(_WIN32)
-		#if defined(__MINGW32__)
-			#define LOG4CXX_THREAD_FUNC
-		#else
-			#define LOG4CXX_THREAD_FUNC __stdcall
-		#endif
-	#else
-		#define LOG4CXX_THREAD_FUNC
-	#endif
-#endif
-
-extern "C" {
-	typedef struct apr_thread_t apr_thread_t;
-	typedef struct apr_thread_cond_t apr_thread_cond_t;
-	typedef struct apr_thread_mutex_t apr_thread_mutex_t;
-}
-
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Pool;
-class ThreadLocal;
-
-typedef void* (LOG4CXX_THREAD_FUNC* Runnable)(apr_thread_t* thread, void* data);
-namespace ThreadLaunch
-{
-extern "C" void* LOG4CXX_THREAD_FUNC launcher(apr_thread_t* thread, void* data);
-}
-
-/**
- *  This class implements an approximation of java.util.Thread.
- */
-class LOG4CXX_EXPORT Thread
-{
-	public:
-		/**
-		 *  Create new instance.
-		 */
-		Thread();
-		/**
-		 *  Destructor.
-		 */
-		~Thread();
-
-		/**
-		 *  Runs the specified method on a newly created thread.
-		 */
-		void run(Runnable start, void* data);
-		void join();
-
-		inline bool isActive()
-		{
-			return thread != 0;
-		}
-
-		/**
-		 * Causes the currently executing thread to sleep for the
-		 * specified number of milliseconds.
-		 * @param millis milliseconds.
-		 * @throws Interrupted Exception if the thread is interrupted.
-		 */
-		static void sleep(int millis);
-		/**
-		 *  Sets interrupted status for current thread to true.
-		 */
-		static void currentThreadInterrupt();
-		/**
-		 *  Sets interrupted status to true.
-		 */
-		void interrupt();
-		/**
-		 *  Tests if the current thread has been interrupted and
-		 *  sets the interrupted status to false.
-		 */
-		static bool interrupted();
-
-		bool isAlive();
-		bool isCurrentThread() const;
-		void ending();
-
-
-	private:
-		Pool p;
-		apr_thread_t* thread;
-		volatile unsigned int alive;
-		volatile unsigned int interruptedStatus;
-		apr_thread_mutex_t* interruptedMutex;
-		apr_thread_cond_t* interruptedCondition;
-		Thread(const Thread&);
-		Thread& operator=(const Thread&);
-		friend void* LOG4CXX_THREAD_FUNC ThreadLaunch::launcher(apr_thread_t* thread, void* data);
-};
-} // namespace helpers
-} // namespace log4cxx
-
-#endif //_LOG4CXX_HELPERS_THREAD_H
diff --git a/src/main/include/log4cxx/helpers/timezone.h b/src/main/include/log4cxx/helpers/timezone.h
index c6e8504..cf35e8c 100644
--- a/src/main/include/log4cxx/helpers/timezone.h
+++ b/src/main/include/log4cxx/helpers/timezone.h
@@ -19,8 +19,7 @@
 #define _LOG4CXX_HELPERS_TIMEZONE_H
 
 #include <log4cxx/logstring.h>
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 
 #if defined(_MSC_VER)
 	#pragma warning ( push )
@@ -36,7 +35,7 @@
 class TimeZone;
 LOG4CXX_PTR_DEF(TimeZone);
 
-class LOG4CXX_EXPORT TimeZone : public helpers::ObjectImpl
+class LOG4CXX_EXPORT TimeZone : public helpers::Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(TimeZone)
diff --git a/src/main/include/log4cxx/helpers/writer.h b/src/main/include/log4cxx/helpers/writer.h
index b5bc98f..a7c054d 100644
--- a/src/main/include/log4cxx/helpers/writer.h
+++ b/src/main/include/log4cxx/helpers/writer.h
@@ -18,7 +18,7 @@
 #ifndef _LOG4CXX_HELPERS_WRITER_H
 #define _LOG4CXX_HELPERS_WRITER_H
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/outputstream.h>
 
 namespace log4cxx
@@ -30,7 +30,7 @@
 /**
 *   Abstract class for writing to character streams.
 */
-class LOG4CXX_EXPORT Writer : public ObjectImpl
+class LOG4CXX_EXPORT Writer : public Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(Writer)
diff --git a/src/main/include/log4cxx/helpers/xml.h b/src/main/include/log4cxx/helpers/xml.h
index c132578..925f500 100644
--- a/src/main/include/log4cxx/helpers/xml.h
+++ b/src/main/include/log4cxx/helpers/xml.h
@@ -25,7 +25,6 @@
 
 
 #include <log4cxx/logstring.h>
-#include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/exception.h>
 
@@ -35,13 +34,13 @@
 namespace helpers
 {
 class XMLDOMNode;
-typedef helpers::ObjectPtrT<XMLDOMNode> XMLDOMNodePtr;
+typedef std::shared_ptr<XMLDOMNode> XMLDOMNodePtr;
 
 class XMLDOMDocument;
-typedef helpers::ObjectPtrT<XMLDOMDocument> XMLDOMDocumentPtr;
+typedef std::shared_ptr<XMLDOMDocument> XMLDOMDocumentPtr;
 
 class XMLDOMNodeList;
-typedef helpers::ObjectPtrT<XMLDOMNodeList> XMLDOMNodeListPtr;
+typedef std::shared_ptr<XMLDOMNodeList> XMLDOMNodeListPtr;
 
 class LOG4CXX_EXPORT DOMException : public RuntimeException
 {
diff --git a/src/main/include/log4cxx/hierarchy.h b/src/main/include/log4cxx/hierarchy.h
index a8448c3..361db5e 100644
--- a/src/main/include/log4cxx/hierarchy.h
+++ b/src/main/include/log4cxx/hierarchy.h
@@ -28,7 +28,7 @@
 #include <vector>
 #include <map>
 #include <log4cxx/provisionnode.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/spi/hierarchyeventlistener.h>
 #include <log4cxx/helpers/pool.h>
 
@@ -54,21 +54,22 @@
 */
 class LOG4CXX_EXPORT Hierarchy :
 	public virtual spi::LoggerRepository,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object,
+    public std::enable_shared_from_this<Hierarchy>
 {
 	private:
 		log4cxx::helpers::Pool pool;
-		log4cxx::helpers::Mutex mutex;
+		mutable log4cxx::mutex mutex;
 		bool configured;
 
 		spi::LoggerFactoryPtr defaultFactory;
 		spi::HierarchyEventListenerList listeners;
 
 		typedef std::map<LogString, LoggerPtr> LoggerMap;
-		LoggerMap* loggers;
+        std::unique_ptr<LoggerMap> loggers;
 
 		typedef std::map<LogString, ProvisionNode> ProvisionNodeMap;
-		ProvisionNodeMap* provisionNodes;
+        std::unique_ptr<ProvisionNodeMap> provisionNodes;
 
 		LoggerPtr root;
 
@@ -91,9 +92,6 @@
 
 		~Hierarchy();
 
-		void addRef() const;
-		void releaseRef() const;
-
 		void addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener);
 
 		/**
@@ -106,7 +104,7 @@
 		*/
 		void clear();
 
-		void emitNoAppenderWarning(const LoggerPtr& logger);
+        void emitNoAppenderWarning(const Logger* logger);
 
 		/**
 		Check if the named logger exists in the hierarchy. If so return
@@ -130,10 +128,10 @@
 		their appenders.  */
 		void setThreshold(const LevelPtr& l);
 
-		void fireAddAppenderEvent(const LoggerPtr& logger, const AppenderPtr& appender);
+        void fireAddAppenderEvent(const Logger* logger, const Appender* appender);
 
-		void fireRemoveAppenderEvent(const LoggerPtr& logger,
-			const AppenderPtr& appender);
+        void fireRemoveAppenderEvent(const Logger* logger,
+            const Appender* appender);
 
 		/**
 		Returns a Level representation of the <code>enable</code>
@@ -232,6 +230,16 @@
 	private:
 
 		/**
+		 * Set the threshold.  The mutex must already be locked.
+		 */
+		void setThresholdInternal(const LevelPtr& l);
+
+		/**
+		 * Internal shutdown.  The mutex must already be locked.
+		 */
+		void shutdownInternal();
+
+		/**
 		This method loops through all the *potential* parents of
 		'cat'. There 3 possible cases:
 
diff --git a/src/main/include/log4cxx/layout.h b/src/main/include/log4cxx/layout.h
index 0bf623c..77877d0 100644
--- a/src/main/include/log4cxx/layout.h
+++ b/src/main/include/log4cxx/layout.h
@@ -24,8 +24,7 @@
 #endif
 
 
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/spi/optionhandler.h>
 #include <log4cxx/spi/loggingevent.h>
 
@@ -37,7 +36,7 @@
 */
 class LOG4CXX_EXPORT Layout :
 	public virtual spi::OptionHandler,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(Layout)
@@ -46,10 +45,7 @@
 		LOG4CXX_CAST_ENTRY(spi::OptionHandler)
 		END_LOG4CXX_CAST_MAP()
 
-		virtual ~Layout();
-		void addRef() const;
-		void releaseRef() const;
-
+        virtual ~Layout();
 
 		/**
 		Implement this method to create your own layout format.
diff --git a/src/main/include/log4cxx/level.h b/src/main/include/log4cxx/level.h
index 10b0762..d5258ae 100644
--- a/src/main/include/log4cxx/level.h
+++ b/src/main/include/log4cxx/level.h
@@ -21,8 +21,7 @@
 
 #include <log4cxx/logstring.h>
 #include <limits.h>
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 
 #if defined(_MSC_VER)
 	#pragma warning ( push )
@@ -40,7 +39,7 @@
  * https://issues.apache.org/jira/browse/LOGCXX-394
  */
 class Level;
-typedef log4cxx::helpers::ObjectPtrT<Level> LevelPtr;
+typedef log4cxx::shared_ptr<Level> LevelPtr;
 
 /**
 Defines the minimum set of levels recognized by the system, that is
@@ -50,7 +49,7 @@
 <p>The <code>Level</code> class may be subclassed to define a larger
 level set.
 */
-class LOG4CXX_EXPORT Level : public helpers::ObjectImpl
+class LOG4CXX_EXPORT Level : public helpers::Object
 {
 	public:
 		class LOG4CXX_EXPORT LevelClass : public helpers::Class
@@ -224,6 +223,7 @@
 		};
 
 
+        static void initializeLevels();
 		static LevelPtr getAll();
 		static LevelPtr getFatal();
 		static LevelPtr getError();
@@ -278,7 +278,18 @@
 			return level;
 		}
 
-	private:
+    private:
+        static volatile bool initialized;
+		static mutex initMutex;
+        static LevelPtr allLevel;
+        static LevelPtr fatalLevel;
+        static LevelPtr errorLevel;
+        static LevelPtr warnLevel;
+        static LevelPtr infoLevel;
+        static LevelPtr debugLevel;
+        static LevelPtr traceLevel;
+        static LevelPtr offLevel;
+
 		int level;
 		LogString name;
 		int syslogEquivalent;
@@ -286,35 +297,6 @@
 		Level& operator=(const Level&);
 };
 
-/**
- * We need to double some logic from LOG4CXX_PTR_DEF or else we are unable to override the
- * comparison operator, which we need to properly fix LOGCXX-394.
- *
- * https://issues.apache.org/jira/browse/LOGCXX-394
- */
-namespace helpers
-{
-
-/** @class log4cxx::helpers::ObjectPtr */
-template<> inline bool LevelPtr::operator==(const LevelPtr& rhs) const
-{
-	return (*this)->equals(rhs);
-}
-template<> inline bool LevelPtr::operator!=(const LevelPtr& rhs) const
-{
-	return !(*this == rhs);
-}
-#if defined(_MSC_VER) && !defined(LOG4CXX_STATIC) && defined(LOG4CXX)
-	template class LOG4CXX_EXPORT log4cxx::helpers::ObjectPtrT<Level>;
-#elif defined(_MSC_VER) && !defined(LOG4CXX_STATIC)
-	#pragma warning(push)
-	#pragma warning(disable: 4231)
-	extern template class LOG4CXX_EXPORT log4cxx::helpers::ObjectPtrT<Level>;
-	#pragma warning(pop)
-#endif
-
-}
-
 }
 
 #define DECLARE_LOG4CXX_LEVEL(level)\
diff --git a/src/main/include/log4cxx/log4cxx.h.in b/src/main/include/log4cxx/log4cxx.h.in
index 4260631..b258e8a 100644
--- a/src/main/include/log4cxx/log4cxx.h.in
+++ b/src/main/include/log4cxx/log4cxx.h.in
@@ -42,10 +42,24 @@
 typedef int log4cxx_status_t;
 typedef unsigned int log4cxx_uint32_t;
 
+#include "boost-std-configuration.h"
 
-#define LOG4CXX_EXPORT
-#define LOG4CXX_PTR_DEF(T) typedef log4cxx::helpers::ObjectPtrT<T> T##Ptr
+#define LOG4CXX_PTR_DEF(T) typedef log4cxx::shared_ptr<T> T##Ptr
 #define LOG4CXX_LIST_DEF(N, T) typedef std::vector<T> N
 
+#if _WIN32
+//  definitions used when using static library
+#if defined(LOG4CXX_STATIC)
+#define LOG4CXX_EXPORT
+//   definitions used when building DLL
+#elif defined(LOG4CXX)
+#define LOG4CXX_EXPORT __declspec(dllexport)
+#else
+//    definitions used when using DLL
+#define LOG4CXX_EXPORT __declspec(dllimport)
+#endif
+#else
+#define LOG4CXX_EXPORT
+#endif /* WIN32 */
 
 #endif
diff --git a/src/main/include/log4cxx/logger.h b/src/main/include/log4cxx/logger.h
index 07a9047..44b6d5e 100644
--- a/src/main/include/log4cxx/logger.h
+++ b/src/main/include/log4cxx/logger.h
@@ -19,23 +19,21 @@
 #define _LOG4CXX_LOGGER_H
 
 #if defined(_MSC_VER) && (_MSC_VER < 1900)
-	#pragma warning ( push )
-	#pragma warning ( disable: 4127 )
+#pragma warning ( push )
+#pragma warning ( disable: 4127 )
 #endif
 #if defined(_MSC_VER)
-	#pragma warning ( push )
-	#pragma warning ( disable: 4231 4251 4275 4786 )
+#pragma warning ( push )
+#pragma warning ( disable: 4231 4251 4275 4786 )
 #endif
 
 #include <log4cxx/helpers/appenderattachableimpl.h>
 #include <log4cxx/level.h>
 #include <log4cxx/helpers/pool.h>
-#include <log4cxx/helpers/mutex.h>
 #include <log4cxx/spi/location/locationinfo.h>
 #include <log4cxx/helpers/resourcebundle.h>
 #include <log4cxx/helpers/messagebuffer.h>
 
-
 namespace log4cxx
 {
 
@@ -63,1673 +61,1673 @@
 operations, except configuration, are done through this class.
 */
 class LOG4CXX_EXPORT Logger :
-	public virtual log4cxx::spi::AppenderAttachable,
-	public virtual helpers::ObjectImpl
+    public virtual log4cxx::spi::AppenderAttachable,
+    public virtual helpers::Object
 {
-	public:
-		DECLARE_ABSTRACT_LOG4CXX_OBJECT(Logger)
-		BEGIN_LOG4CXX_CAST_MAP()
-		LOG4CXX_CAST_ENTRY(Logger)
-		LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
-		END_LOG4CXX_CAST_MAP()
+public:
+    DECLARE_ABSTRACT_LOG4CXX_OBJECT(Logger)
+    BEGIN_LOG4CXX_CAST_MAP()
+    LOG4CXX_CAST_ENTRY(Logger)
+    LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
+    END_LOG4CXX_CAST_MAP()
 
-	private:
-		/**
-		 *   Reference to memory pool.
-		 */
-		helpers::Pool* pool;
+private:
+    /**
+     *   Reference to memory pool.
+     */
+    helpers::Pool* pool;
 
-	protected:
-		/**
-		The name of this logger.
-		*/
-		LogString name;
+protected:
+    /**
+    The name of this logger.
+    */
+    LogString name;
 
-		/**
-		The assigned level of this logger.  The
-		<code>level</code> variable need not be assigned a value in
-		which case it is inherited form the hierarchy.  */
-		LevelPtr level;
+    /**
+    The assigned level of this logger.  The
+    <code>level</code> variable need not be assigned a value in
+    which case it is inherited form the hierarchy.  */
+    LevelPtr level;
 
-		/**
-		The parent of this logger. All loggers have at least one
-		ancestor which is the root logger. */
-		LoggerPtr parent;
+    /**
+    The parent of this logger. All loggers have at least one
+    ancestor which is the root logger. */
+    LoggerPtr parent;
 
-		/** The resourceBundle for localized messages.
+    /** The resourceBundle for localized messages.
 
-		@see setResourceBundle, getResourceBundle
-		*/
-		helpers::ResourceBundlePtr resourceBundle;
+    @see setResourceBundle, getResourceBundle
+    */
+    helpers::ResourceBundlePtr resourceBundle;
 
 
-		// Loggers need to know what Hierarchy they are in
-		log4cxx::spi::LoggerRepository* repository;
+    // Loggers need to know what Hierarchy they are in
+    log4cxx::spi::LoggerRepository* repository;
 
-		helpers::AppenderAttachableImplPtr aai;
+    helpers::AppenderAttachableImplPtr aai;
 
-		/** Additivity is set to true by default, that is children inherit
-		        the appenders of their ancestors by default. If this variable is
-		        set to <code>false</code> then the appenders found in the
-		        ancestors of this logger are not used. However, the children
-		        of this logger will inherit its appenders, unless the children
-		        have their additivity flag set to <code>false</code> too. See
-		        the user manual for more details. */
-		bool additive;
+    /** Additivity is set to true by default, that is children inherit
+            the appenders of their ancestors by default. If this variable is
+            set to <code>false</code> then the appenders found in the
+            ancestors of this logger are not used. However, the children
+            of this logger will inherit its appenders, unless the children
+            have their additivity flag set to <code>false</code> too. See
+            the user manual for more details. */
+	bool additive;
 
-	protected:
-		friend class DefaultLoggerFactory;
+protected:
+    friend class DefaultLoggerFactory;
 
-		/**
-		This constructor created a new <code>logger</code> instance and
-		sets its name.
+    /**
+    This constructor created a new <code>logger</code> instance and
+    sets its name.
 
-		<p>It is intended to be used by sub-classes only. You should not
-		create categories directly.
+    <p>It is intended to be used by sub-classes only. You should not
+    create categories directly.
 
-		@param pool lifetime of pool must be longer than logger.
-		@param name The name of the logger.
-		*/
-		Logger(log4cxx::helpers::Pool& pool, const LogString& name);
+    @param pool lifetime of pool must be longer than logger.
+    @param name The name of the logger.
+    */
+    Logger(log4cxx::helpers::Pool& pool, const LogString& name);
 
-	public:
-		~Logger();
+public:
+    ~Logger();
 
 
-		void addRef() const;
-		void releaseRef() const;
+    /**
+    Add <code>newAppender</code> to the list of appenders of this
+    Logger instance.
 
-		/**
-		Add <code>newAppender</code> to the list of appenders of this
-		Logger instance.
-
-		<p>If <code>newAppender</code> is already in the list of
-		appenders, then it won't be added again.
-		*/
-		virtual void addAppender(const AppenderPtr& newAppender);
+    <p>If <code>newAppender</code> is already in the list of
+    appenders, then it won't be added again.
+    */
+    virtual void addAppender(const AppenderPtr newAppender);
 
 
-		/**
-		Call the appenders in the hierrachy starting at
-		<code>this</code>.  If no appenders could be found, emit a
-		warning.
+    /**
+    Call the appenders in the hierrachy starting at
+    <code>this</code>.  If no appenders could be found, emit a
+    warning.
 
-		<p>This method calls all the appenders inherited from the
-		hierarchy circumventing any evaluation of whether to log or not
-		to log the particular log request.
+    <p>This method calls all the appenders inherited from the
+    hierarchy circumventing any evaluation of whether to log or not
+    to log the particular log request.
 
-		@param event the event to log.
-		@param p memory pool for any allocations needed to process request.
-		*/
-		void callAppenders(const log4cxx::spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) const;
+    @param event the event to log.
+    @param p memory pool for any allocations needed to process request.
+    */
+    void callAppenders(const log4cxx::spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) const;
 
-		/**
-		Close all attached appenders implementing the AppenderAttachable
-		interface.
-		*/
-		void closeNestedAppenders();
+    /**
+    Close all attached appenders implementing the AppenderAttachable
+    interface.
+    */
+    void closeNestedAppenders();
 
-		/**
-		Log a message string with the DEBUG level.
+    /**
+    Log a message string with the DEBUG level.
 
-		<p>This method first checks if this logger is <code>DEBUG</code>
-		enabled by comparing the level of this logger with the
-		DEBUG level. If this logger is
-		<code>DEBUG</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>DEBUG</code>
+    enabled by comparing the level of this logger with the
+    DEBUG level. If this logger is
+    <code>DEBUG</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void debug(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the DEBUG level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void debug(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the DEBUG level.
 
-		<p>This method first checks if this logger is <code>DEBUG</code>
-		enabled by comparing the level of this logger with the
-		DEBUG level. If this logger is
-		<code>DEBUG</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>DEBUG</code>
+    enabled by comparing the level of this logger with the
+    DEBUG level. If this logger is
+    <code>DEBUG</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void debug(const std::string& msg) const;
+    @param msg the message string to log.
+    */
+    void debug(const std::string& msg) const;
 #if LOG4CXX_WCHAR_T_API
-		/**
-		Log a message string with the DEBUG level.
+    /**
+    Log a message string with the DEBUG level.
 
-		<p>This method first checks if this logger is <code>DEBUG</code>
-		enabled by comparing the level of this logger with the
-		DEBUG level. If this logger is
-		<code>DEBUG</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>DEBUG</code>
+    enabled by comparing the level of this logger with the
+    DEBUG level. If this logger is
+    <code>DEBUG</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void debug(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the DEBUG level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void debug(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the DEBUG level.
 
-		<p>This method first checks if this logger is <code>DEBUG</code>
-		enabled by comparing the level of this logger with the
-		DEBUG level. If this logger is
-		<code>DEBUG</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>DEBUG</code>
+    enabled by comparing the level of this logger with the
+    DEBUG level. If this logger is
+    <code>DEBUG</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void debug(const std::wstring& msg) const;
+    @param msg the message string to log.
+    */
+    void debug(const std::wstring& msg) const;
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		Log a message string with the DEBUG level.
+    /**
+    Log a message string with the DEBUG level.
 
-		<p>This method first checks if this logger is <code>DEBUG</code>
-		enabled by comparing the level of this logger with the
-		DEBUG level. If this logger is
-		<code>DEBUG</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>DEBUG</code>
+    enabled by comparing the level of this logger with the
+    DEBUG level. If this logger is
+    <code>DEBUG</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void debug(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the DEBUG level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void debug(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the DEBUG level.
 
-		<p>This method first checks if this logger is <code>DEBUG</code>
-		enabled by comparing the level of this logger with the
-		DEBUG level. If this logger is
-		<code>DEBUG</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>DEBUG</code>
+    enabled by comparing the level of this logger with the
+    DEBUG level. If this logger is
+    <code>DEBUG</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void debug(const std::basic_string<UniChar>& msg) const;
+    @param msg the message string to log.
+    */
+    void debug(const std::basic_string<UniChar>& msg) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		Log a message string with the DEBUG level.
+    /**
+    Log a message string with the DEBUG level.
 
-		<p>This method first checks if this logger is <code>DEBUG</code>
-		enabled by comparing the level of this logger with the
-		DEBUG level. If this logger is
-		<code>DEBUG</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>DEBUG</code>
+    enabled by comparing the level of this logger with the
+    DEBUG level. If this logger is
+    <code>DEBUG</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the DEBUG level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the DEBUG level.
 
-		<p>This method first checks if this logger is <code>DEBUG</code>
-		enabled by comparing the level of this logger with the
-		DEBUG level. If this logger is
-		<code>DEBUG</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>DEBUG</code>
+    enabled by comparing the level of this logger with the
+    DEBUG level. If this logger is
+    <code>DEBUG</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void debug(const CFStringRef& msg) const;
+    @param msg the message string to log.
+    */
+    void debug(const CFStringRef& msg) const;
 #endif
 
-		/**
-		Log a message string with the ERROR level.
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void error(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the ERROR level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void error(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void error(const std::string& msg) const;
+    @param msg the message string to log.
+    */
+    void error(const std::string& msg) const;
 #if LOG4CXX_WCHAR_T_API
-		/**
-		Log a message string with the ERROR level.
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void error(const std::wstring& msg) const;
-		/**
-		Log a message string with the ERROR level.
+    @param msg the message string to log.
+    */
+    void error(const std::wstring& msg) const;
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void error(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void error(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		Log a message string with the ERROR level.
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void error(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the ERROR level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void error(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void error(const std::basic_string<UniChar>& msg) const;
+    @param msg the message string to log.
+    */
+    void error(const std::basic_string<UniChar>& msg) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		Log a message string with the ERROR level.
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the ERROR level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void error(const CFStringRef& msg) const;
+    @param msg the message string to log.
+    */
+    void error(const CFStringRef& msg) const;
 #endif
 
-		/**
-		Log a message string with the FATAL level.
+    /**
+    Log a message string with the FATAL level.
 
-		<p>This method first checks if this logger is <code>FATAL</code>
-		enabled by comparing the level of this logger with the
-		FATAL level. If this logger is
-		<code>FATAL</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>FATAL</code>
+    enabled by comparing the level of this logger with the
+    FATAL level. If this logger is
+    <code>FATAL</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void fatal(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the ERROR level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void fatal(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void fatal(const std::string& msg) const;
+    @param msg the message string to log.
+    */
+    void fatal(const std::string& msg) const;
 #if LOG4CXX_WCHAR_T_API
-		/**
-		Log a message string with the ERROR level.
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void fatal(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the ERROR level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void fatal(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void fatal(const std::wstring& msg) const;
+    @param msg the message string to log.
+    */
+    void fatal(const std::wstring& msg) const;
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		Log a message string with the ERROR level.
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void fatal(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the ERROR level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void fatal(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void fatal(const std::basic_string<UniChar>& msg) const;
+    @param msg the message string to log.
+    */
+    void fatal(const std::basic_string<UniChar>& msg) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		Log a message string with the ERROR level.
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the ERROR level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the ERROR level.
 
-		<p>This method first checks if this logger is <code>ERROR</code>
-		enabled by comparing the level of this logger with the
-		ERROR level. If this logger is
-		<code>ERROR</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>ERROR</code>
+    enabled by comparing the level of this logger with the
+    ERROR level. If this logger is
+    <code>ERROR</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void fatal(const CFStringRef& msg) const;
+    @param msg the message string to log.
+    */
+    void fatal(const CFStringRef& msg) const;
 #endif
 
-		/**
-		This method creates a new logging event and logs the event
-		without further checks.
-		@param level the level to log.
-		@param message message.
-		@param location location of source of logging request.
-		*/
-		void forcedLog(const LevelPtr& level, const std::string& message,
-			const log4cxx::spi::LocationInfo& location) const;
-		/**
-		This method creates a new logging event and logs the event
-		without further checks.
-		@param level the level to log.
-		@param message message.
-		*/
-		void forcedLog(const LevelPtr& level, const std::string& message) const;
+    /**
+    This method creates a new logging event and logs the event
+    without further checks.
+    @param level the level to log.
+    @param message message.
+    @param location location of source of logging request.
+    */
+    void forcedLog(const LevelPtr& level, const std::string& message,
+                   const log4cxx::spi::LocationInfo& location) const;
+    /**
+    This method creates a new logging event and logs the event
+    without further checks.
+    @param level the level to log.
+    @param message message.
+    */
+    void forcedLog(const LevelPtr& level, const std::string& message) const;
 
 #if LOG4CXX_WCHAR_T_API
-		/**
-		This method creates a new logging event and logs the event
-		without further checks.
-		@param level the level to log.
-		@param message message.
-		@param location location of source of logging request.
-		*/
-		void forcedLog(const LevelPtr& level, const std::wstring& message,
-			const log4cxx::spi::LocationInfo& location) const;
-		/**
-		This method creates a new logging event and logs the event
-		without further checks.
-		@param level the level to log.
-		@param message message.
-		*/
-		void forcedLog(const LevelPtr& level, const std::wstring& message) const;
+    /**
+    This method creates a new logging event and logs the event
+    without further checks.
+    @param level the level to log.
+    @param message message.
+    @param location location of source of logging request.
+    */
+    void forcedLog(const LevelPtr& level, const std::wstring& message,
+                   const log4cxx::spi::LocationInfo& location) const;
+    /**
+    This method creates a new logging event and logs the event
+    without further checks.
+    @param level the level to log.
+    @param message message.
+    */
+    void forcedLog(const LevelPtr& level, const std::wstring& message) const;
 #endif
 #if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
-		/**
-		This method creates a new logging event and logs the event
-		without further checks.
-		@param level the level to log.
-		@param message message.
-		@param location location of source of logging request.
-		*/
-		void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message,
-			const log4cxx::spi::LocationInfo& location) const;
-		/**
-		This method creates a new logging event and logs the event
-		without further checks.
-		@param level the level to log.
-		@param message message.
-		*/
-		void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
+    /**
+    This method creates a new logging event and logs the event
+    without further checks.
+    @param level the level to log.
+    @param message message.
+    @param location location of source of logging request.
+    */
+    void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message,
+                   const log4cxx::spi::LocationInfo& location) const;
+    /**
+    This method creates a new logging event and logs the event
+    without further checks.
+    @param level the level to log.
+    @param message message.
+    */
+    void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		This method creates a new logging event and logs the event
-		without further checks.
-		@param level the level to log.
-		@param message message.
-		@param location location of source of logging request.
-		*/
-		void forcedLog(const LevelPtr& level, const CFStringRef& message,
-			const log4cxx::spi::LocationInfo& location) const;
-		/**
-		This method creates a new logging event and logs the event
-		without further checks.
-		@param level the level to log.
-		@param message message.
-		*/
-		void forcedLog(const LevelPtr& level, const CFStringRef& message) const;
+    /**
+    This method creates a new logging event and logs the event
+    without further checks.
+    @param level the level to log.
+    @param message message.
+    @param location location of source of logging request.
+    */
+    void forcedLog(const LevelPtr& level, const CFStringRef& message,
+                   const log4cxx::spi::LocationInfo& location) const;
+    /**
+    This method creates a new logging event and logs the event
+    without further checks.
+    @param level the level to log.
+    @param message message.
+    */
+    void forcedLog(const LevelPtr& level, const CFStringRef& message) const;
 #endif
-		/**
-		This method creates a new logging event and logs the event
-		without further checks.
-		@param level the level to log.
-		@param message the message string to log.
-		@param location location of the logging statement.
-		*/
-		void forcedLogLS(const LevelPtr& level, const LogString& message,
-			const log4cxx::spi::LocationInfo& location) const;
+    /**
+    This method creates a new logging event and logs the event
+    without further checks.
+    @param level the level to log.
+    @param message the message string to log.
+    @param location location of the logging statement.
+    */
+    void forcedLogLS(const LevelPtr& level, const LogString& message,
+                     const log4cxx::spi::LocationInfo& location) const;
 
-		/**
-		Get the additivity flag for this Logger instance.
-		*/
-		bool getAdditivity() const;
+    /**
+    Get the additivity flag for this Logger instance.
+    */
+    bool getAdditivity() const;
 
-		/**
-		Get the appenders contained in this logger as an AppenderList.
-		If no appenders can be found, then an empty AppenderList
-		is returned.
-		@return AppenderList An collection of the appenders in this logger.*/
-		AppenderList getAllAppenders() const;
+    /**
+    Get the appenders contained in this logger as an AppenderList.
+    If no appenders can be found, then an empty AppenderList
+    is returned.
+    @return AppenderList An collection of the appenders in this logger.*/
+    AppenderList getAllAppenders() const;
 
-		/**
-		Look for the appender named as <code>name</code>.
-		<p>Return the appender with that name if in the list. Return
-		<code>NULL</code> otherwise.  */
-		AppenderPtr getAppender(const LogString& name) const;
+    /**
+    Look for the appender named as <code>name</code>.
+    <p>Return the appender with that name if in the list. Return
+    <code>NULL</code> otherwise.  */
+    AppenderPtr getAppender(const LogString& name) const;
 
-		/**
-		Starting from this logger, search the logger hierarchy for a
-		non-null level and return it.
+    /**
+    Starting from this logger, search the logger hierarchy for a
+    non-null level and return it.
 
-		<p>The Logger class is designed so that this method executes as
-		quickly as possible.
+    <p>The Logger class is designed so that this method executes as
+    quickly as possible.
 
-		@throws RuntimeException if all levels are null in the hierarchy
-		*/
-		virtual const LevelPtr& getEffectiveLevel() const;
+    @throws RuntimeException if all levels are null in the hierarchy
+    */
+    virtual const LevelPtr getEffectiveLevel() const;
 
-		/**
-		Return the the LoggerRepository where this
-		<code>Logger</code> is attached.
-		*/
-		log4cxx::spi::LoggerRepositoryPtr getLoggerRepository() const;
+    /**
+    Return the the LoggerRepository where this
+    <code>Logger</code> is attached.
+    */
+    log4cxx::spi::LoggerRepository* getLoggerRepository() const;
 
 
-		/**
-		* Get the logger name.
-		* @return logger name as LogString.
-		*/
-		const LogString& getName() const
-		{
-			return name;
-		}
-		/**
-		* Get logger name in current encoding.
-		* @param name buffer to which name is appended.
-		*/
-		void getName(std::string& name) const;
+    /**
+    * Get the logger name.
+    * @return logger name as LogString.
+    */
+    const LogString& getName() const
+    {
+        return name;
+    }
+    /**
+    * Get logger name in current encoding.
+    * @param name buffer to which name is appended.
+    */
+    void getName(std::string& name) const;
 #if LOG4CXX_WCHAR_T_API
-		/**
-		* Get logger name.
-		* @param name buffer to which name is appended.
-		*/
-		void getName(std::wstring& name) const;
+    /**
+    * Get logger name.
+    * @param name buffer to which name is appended.
+    */
+    void getName(std::wstring& name) const;
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		* Get logger name.
-		* @param name buffer to which name is appended.
-		*/
-		void getName(std::basic_string<UniChar>& name) const;
+    /**
+    * Get logger name.
+    * @param name buffer to which name is appended.
+    */
+    void getName(std::basic_string<UniChar>& name) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		* Get logger name.
-		* @param name buffer to which name is appended.
-		*/
-		void getName(CFStringRef& name) const;
+    /**
+    * Get logger name.
+    * @param name buffer to which name is appended.
+    */
+    void getName(CFStringRef& name) const;
 #endif
 
-		/**
-		Returns the parent of this logger. Note that the parent of a
-		given logger may change during the lifetime of the logger.
+    /**
+    Returns the parent of this logger. Note that the parent of a
+    given logger may change during the lifetime of the logger.
 
-		<p>The root logger will return <code>0</code>.
-		*/
-		LoggerPtr getParent() const;
+    <p>The root logger will return <code>0</code>.
+    */
+    LoggerPtr getParent() const;
 
 
-		/**
-		Returns the assigned Level, if any, for this Logger.
+    /**
+    Returns the assigned Level, if any, for this Logger.
 
-		@return Level - the assigned Level, can be null.
-		*/
-		LevelPtr getLevel() const;
+    @return Level - the assigned Level, can be null.
+    */
+    LevelPtr getLevel() const;
 
-		/**
-		* Retrieve a logger by name in current encoding.
-		* @param name logger name.
-		*/
-		static LoggerPtr getLogger(const std::string& name);
-		/**
-		* Retrieve a logger by name in current encoding.
-		* @param name logger name.
-		*/
-		static LoggerPtr getLogger(const char* const name);
+    /**
+    * Retrieve a logger by name in current encoding.
+    * @param name logger name.
+    */
+    static LoggerPtr getLogger(const std::string& name);
+    /**
+    * Retrieve a logger by name in current encoding.
+    * @param name logger name.
+    */
+    static LoggerPtr getLogger(const char* const name);
 #if LOG4CXX_WCHAR_T_API
-		/**
-		* Retrieve a logger by name.
-		* @param name logger name.
-		*/
-		static LoggerPtr getLogger(const std::wstring& name);
-		/**
-		* Retrieve a logger by name.
-		* @param name logger name.
-		*/
-		static LoggerPtr getLogger(const wchar_t* const name);
+    /**
+    * Retrieve a logger by name.
+    * @param name logger name.
+    */
+    static LoggerPtr getLogger(const std::wstring& name);
+    /**
+    * Retrieve a logger by name.
+    * @param name logger name.
+    */
+    static LoggerPtr getLogger(const wchar_t* const name);
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		* Retrieve a logger by name.
-		* @param name logger name.
-		*/
-		static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
+    /**
+    * Retrieve a logger by name.
+    * @param name logger name.
+    */
+    static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		* Retrieve a logger by name.
-		* @param name logger name.
-		*/
-		static LoggerPtr getLogger(const CFStringRef& name);
+    /**
+    * Retrieve a logger by name.
+    * @param name logger name.
+    */
+    static LoggerPtr getLogger(const CFStringRef& name);
 #endif
-		/**
-		* Retrieve a logger by name in Unicode.
-		* @param name logger name.
-		*/
-		static LoggerPtr getLoggerLS(const LogString& name);
+    /**
+    * Retrieve a logger by name in Unicode.
+    * @param name logger name.
+    */
+    static LoggerPtr getLoggerLS(const LogString& name);
 
-		/**
-		Retrieve the root logger.
-		*/
-		static LoggerPtr getRootLogger();
+    /**
+    Retrieve the root logger.
+    */
+    static LoggerPtr getRootLogger();
 
-		/**
-		Like #getLogger except that the type of logger
-		instantiated depends on the type returned by the
-		LoggerFactory#makeNewLoggerInstance method of the
-		<code>factory</code> parameter.
+    /**
+    Like #getLogger except that the type of logger
+    instantiated depends on the type returned by the
+    LoggerFactory#makeNewLoggerInstance method of the
+    <code>factory</code> parameter.
 
-		<p>This method is intended to be used by sub-classes.
+    <p>This method is intended to be used by sub-classes.
 
-		@param name The name of the logger to retrieve.
+    @param name The name of the logger to retrieve.
 
-		@param factory A LoggerFactory implementation that will
-		actually create a new Instance.
-		*/
-		static LoggerPtr getLoggerLS(const LogString& name,
-			const log4cxx::spi::LoggerFactoryPtr& factory);
-		/**
-		Like #getLogger except that the type of logger
-		instantiated depends on the type returned by the
-		LoggerFactory#makeNewLoggerInstance method of the
-		<code>factory</code> parameter.
+    @param factory A LoggerFactory implementation that will
+    actually create a new Instance.
+    */
+    static LoggerPtr getLoggerLS(const LogString& name,
+                                 const log4cxx::spi::LoggerFactoryPtr& factory);
+    /**
+    Like #getLogger except that the type of logger
+    instantiated depends on the type returned by the
+    LoggerFactory#makeNewLoggerInstance method of the
+    <code>factory</code> parameter.
 
-		<p>This method is intended to be used by sub-classes.
+    <p>This method is intended to be used by sub-classes.
 
-		@param name The name of the logger to retrieve.
+    @param name The name of the logger to retrieve.
 
-		@param factory A LoggerFactory implementation that will
-		actually create a new Instance.
-		*/
-		static LoggerPtr getLogger(const std::string& name,
-			const log4cxx::spi::LoggerFactoryPtr& factory);
+    @param factory A LoggerFactory implementation that will
+    actually create a new Instance.
+    */
+    static LoggerPtr getLogger(const std::string& name,
+                               const log4cxx::spi::LoggerFactoryPtr& factory);
 #if LOG4CXX_WCHAR_T_API
-		/**
-		Like #getLogger except that the type of logger
-		instantiated depends on the type returned by the
-		LoggerFactory#makeNewLoggerInstance method of the
-		<code>factory</code> parameter.
+    /**
+    Like #getLogger except that the type of logger
+    instantiated depends on the type returned by the
+    LoggerFactory#makeNewLoggerInstance method of the
+    <code>factory</code> parameter.
 
-		<p>This method is intended to be used by sub-classes.
+    <p>This method is intended to be used by sub-classes.
 
-		@param name The name of the logger to retrieve.
+    @param name The name of the logger to retrieve.
 
-		@param factory A LoggerFactory implementation that will
-		actually create a new Instance.
-		*/
-		static LoggerPtr getLogger(const std::wstring& name,
-			const log4cxx::spi::LoggerFactoryPtr& factory);
+    @param factory A LoggerFactory implementation that will
+    actually create a new Instance.
+    */
+    static LoggerPtr getLogger(const std::wstring& name,
+                               const log4cxx::spi::LoggerFactoryPtr& factory);
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		Like #getLogger except that the type of logger
-		instantiated depends on the type returned by the
-		LoggerFactory#makeNewLoggerInstance method of the
-		<code>factory</code> parameter.
+    /**
+    Like #getLogger except that the type of logger
+    instantiated depends on the type returned by the
+    LoggerFactory#makeNewLoggerInstance method of the
+    <code>factory</code> parameter.
 
-		<p>This method is intended to be used by sub-classes.
+    <p>This method is intended to be used by sub-classes.
 
-		@param name The name of the logger to retrieve.
+    @param name The name of the logger to retrieve.
 
-		@param factory A LoggerFactory implementation that will
-		actually create a new Instance.
-		*/
-		static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
-			const log4cxx::spi::LoggerFactoryPtr& factory);
+    @param factory A LoggerFactory implementation that will
+    actually create a new Instance.
+    */
+    static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
+                               const log4cxx::spi::LoggerFactoryPtr& factory);
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		Like #getLogger except that the type of logger
-		instantiated depends on the type returned by the
-		LoggerFactory#makeNewLoggerInstance method of the
-		<code>factory</code> parameter.
+    /**
+    Like #getLogger except that the type of logger
+    instantiated depends on the type returned by the
+    LoggerFactory#makeNewLoggerInstance method of the
+    <code>factory</code> parameter.
 
-		<p>This method is intended to be used by sub-classes.
+    <p>This method is intended to be used by sub-classes.
 
-		@param name The name of the logger to retrieve.
+    @param name The name of the logger to retrieve.
 
-		@param factory A LoggerFactory implementation that will
-		actually create a new Instance.
-		*/
-		static LoggerPtr getLogger(const CFStringRef& name,
-			const log4cxx::spi::LoggerFactoryPtr& factory);
+    @param factory A LoggerFactory implementation that will
+    actually create a new Instance.
+    */
+    static LoggerPtr getLogger(const CFStringRef& name,
+                               const log4cxx::spi::LoggerFactoryPtr& factory);
 #endif
 
-		/**
-		Return the <em>inherited</em> ResourceBundle for this logger.
+    /**
+    Return the <em>inherited</em> ResourceBundle for this logger.
 
 
-		This method walks the hierarchy to find the appropriate resource bundle.
-		It will return the resource bundle attached to the closest ancestor of
-		this logger, much like the way priorities are searched. In case there
-		is no bundle in the hierarchy then <code>NULL</code> is returned.
-		*/
-		helpers::ResourceBundlePtr getResourceBundle() const;
+    This method walks the hierarchy to find the appropriate resource bundle.
+    It will return the resource bundle attached to the closest ancestor of
+    this logger, much like the way priorities are searched. In case there
+    is no bundle in the hierarchy then <code>NULL</code> is returned.
+    */
+    helpers::ResourceBundlePtr getResourceBundle() const;
 
-	protected:
-		/**
-		Returns the string resource coresponding to <code>key</code> in this
-		logger's inherited resource bundle.
+protected:
+    /**
+    Returns the string resource coresponding to <code>key</code> in this
+    logger's inherited resource bundle.
 
-		If the resource cannot be found, then an {@link #error error} message
-		will be logged complaining about the missing resource.
+    If the resource cannot be found, then an {@link #error error} message
+    will be logged complaining about the missing resource.
 
-		@see #getResourceBundle.
-		*/
-		LogString getResourceBundleString(const LogString& key) const;
+    @see #getResourceBundle.
+    */
+    LogString getResourceBundleString(const LogString& key) const;
 
-	public:
-		/**
-		Log a message string with the INFO level.
+public:
+    /**
+    Log a message string with the INFO level.
 
-		<p>This method first checks if this logger is <code>INFO</code>
-		enabled by comparing the level of this logger with the
-		INFO level. If this logger is
-		<code>INFO</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>INFO</code>
+    enabled by comparing the level of this logger with the
+    INFO level. If this logger is
+    <code>INFO</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		        */
-		void info(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
-		void info(const std::string& msg) const;
+    @param msg the message string to log.
+    @param location location of source of logging request.
+            */
+    void info(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+    void info(const std::string& msg) const;
 #if LOG4CXX_WCHAR_T_API
-		/**
-		Log a message string with the INFO level.
+    /**
+    Log a message string with the INFO level.
 
-		<p>This method first checks if this logger is <code>INFO</code>
-		enabled by comparing the level of this logger with the
-		INFO level. If this logger is
-		<code>INFO</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>INFO</code>
+    enabled by comparing the level of this logger with the
+    INFO level. If this logger is
+    <code>INFO</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		        */
-		void info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the INFO level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+            */
+    void info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the INFO level.
 
-		<p>This method first checks if this logger is <code>INFO</code>
-		enabled by comparing the level of this logger with the
-		INFO level. If this logger is
-		<code>INFO</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>INFO</code>
+    enabled by comparing the level of this logger with the
+    INFO level. If this logger is
+    <code>INFO</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		        */
-		void info(const std::wstring& msg) const;
+    @param msg the message string to log.
+            */
+    void info(const std::wstring& msg) const;
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		Log a message string with the INFO level.
+    /**
+    Log a message string with the INFO level.
 
-		<p>This method first checks if this logger is <code>INFO</code>
-		enabled by comparing the level of this logger with the
-		INFO level. If this logger is
-		<code>INFO</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>INFO</code>
+    enabled by comparing the level of this logger with the
+    INFO level. If this logger is
+    <code>INFO</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		        */
-		void info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the INFO level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+            */
+    void info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the INFO level.
 
-		<p>This method first checks if this logger is <code>INFO</code>
-		enabled by comparing the level of this logger with the
-		INFO level. If this logger is
-		<code>INFO</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>INFO</code>
+    enabled by comparing the level of this logger with the
+    INFO level. If this logger is
+    <code>INFO</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		        */
-		void info(const std::basic_string<UniChar>& msg) const;
+    @param msg the message string to log.
+            */
+    void info(const std::basic_string<UniChar>& msg) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		Log a message string with the INFO level.
+    /**
+    Log a message string with the INFO level.
 
-		<p>This method first checks if this logger is <code>INFO</code>
-		enabled by comparing the level of this logger with the
-		INFO level. If this logger is
-		<code>INFO</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>INFO</code>
+    enabled by comparing the level of this logger with the
+    INFO level. If this logger is
+    <code>INFO</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		        */
-		void info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the INFO level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+            */
+    void info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the INFO level.
 
-		<p>This method first checks if this logger is <code>INFO</code>
-		enabled by comparing the level of this logger with the
-		INFO level. If this logger is
-		<code>INFO</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>INFO</code>
+    enabled by comparing the level of this logger with the
+    INFO level. If this logger is
+    <code>INFO</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		        */
-		void info(const CFStringRef& msg) const;
+    @param msg the message string to log.
+            */
+    void info(const CFStringRef& msg) const;
 #endif
 
-		/**
-		Is the appender passed as parameter attached to this logger?
-		*/
-		bool isAttached(const AppenderPtr& appender) const;
+    /**
+    Is the appender passed as parameter attached to this logger?
+    */
+    bool isAttached(const AppenderPtr appender) const;
 
-		/**
-		 *  Check whether this logger is enabled for the <code>DEBUG</code>
-		 *  Level.
-		 *
-		 *  <p> This function is intended to lessen the computational cost of
-		 *  disabled log debug statements.
-		 *
-		 *  <p> For some <code>logger</code> Logger object, when you write,
-		 *  <pre>
-		 *      logger->debug("debug message");
-		 *  </pre>
-		 *
-		 *  <p>You incur the cost constructing the message, concatenation in
-		 *  this case, regardless of whether the message is logged or not.
-		 *
-		 *  <p>If you are worried about speed, then you should write
-		 *  <pre>
-		 *    if(logger->isDebugEnabled()) {
-		 *      logger->debug("debug message");
-		 *    }
-		 *  </pre>
-		 *
-		 *  <p>This way you will not incur the cost of parameter
-		 *  construction if debugging is disabled for <code>logger</code>. On
-		 *  the other hand, if the <code>logger</code> is debug enabled, you
-		 *  will incur the cost of evaluating whether the logger is debug
-		 *  enabled twice. Once in <code>isDebugEnabled</code> and once in
-		 *  the <code>debug</code>.  This is an insignificant overhead
-		 *  since evaluating a logger takes about 1%% of the time it
-		 *  takes to actually log.
-		 *
-		 *  @return bool - <code>true</code> if this logger is debug
-		 *  enabled, <code>false</code> otherwise.
-		 *   */
-		bool isDebugEnabled() const;
+    /**
+     *  Check whether this logger is enabled for the <code>DEBUG</code>
+     *  Level.
+     *
+     *  <p> This function is intended to lessen the computational cost of
+     *  disabled log debug statements.
+     *
+     *  <p> For some <code>logger</code> Logger object, when you write,
+     *  <pre>
+     *      logger->debug("debug message");
+     *  </pre>
+     *
+     *  <p>You incur the cost constructing the message, concatenation in
+     *  this case, regardless of whether the message is logged or not.
+     *
+     *  <p>If you are worried about speed, then you should write
+     *  <pre>
+     *    if(logger->isDebugEnabled()) {
+     *      logger->debug("debug message");
+     *    }
+     *  </pre>
+     *
+     *  <p>This way you will not incur the cost of parameter
+     *  construction if debugging is disabled for <code>logger</code>. On
+     *  the other hand, if the <code>logger</code> is debug enabled, you
+     *  will incur the cost of evaluating whether the logger is debug
+     *  enabled twice. Once in <code>isDebugEnabled</code> and once in
+     *  the <code>debug</code>.  This is an insignificant overhead
+     *  since evaluating a logger takes about 1%% of the time it
+     *  takes to actually log.
+     *
+     *  @return bool - <code>true</code> if this logger is debug
+     *  enabled, <code>false</code> otherwise.
+     *   */
+    bool isDebugEnabled() const;
 
-		/**
-		Check whether this logger is enabled for a given
-		Level passed as parameter.
+    /**
+    Check whether this logger is enabled for a given
+    Level passed as parameter.
 
-		See also #isDebugEnabled.
+    See also #isDebugEnabled.
 
-		@return bool True if this logger is enabled for <code>level</code>.
-		*/
-		bool isEnabledFor(const LevelPtr& level) const;
+    @return bool True if this logger is enabled for <code>level</code>.
+    */
+    bool isEnabledFor(const LevelPtr& level) const;
 
 
-		/**
-		Check whether this logger is enabled for the info Level.
-		See also #isDebugEnabled.
+    /**
+    Check whether this logger is enabled for the info Level.
+    See also #isDebugEnabled.
 
-		@return bool - <code>true</code> if this logger is enabled
-		for level info, <code>false</code> otherwise.
-		*/
-		bool isInfoEnabled() const;
+    @return bool - <code>true</code> if this logger is enabled
+    for level info, <code>false</code> otherwise.
+    */
+    bool isInfoEnabled() const;
 
-		/**
-		Check whether this logger is enabled for the warn Level.
-		See also #isDebugEnabled.
+    /**
+    Check whether this logger is enabled for the warn Level.
+    See also #isDebugEnabled.
 
-		@return bool - <code>true</code> if this logger is enabled
-		for level warn, <code>false</code> otherwise.
-		*/
-		bool isWarnEnabled() const;
+    @return bool - <code>true</code> if this logger is enabled
+    for level warn, <code>false</code> otherwise.
+    */
+    bool isWarnEnabled() const;
 
-		/**
-		Check whether this logger is enabled for the error Level.
-		See also #isDebugEnabled.
+    /**
+    Check whether this logger is enabled for the error Level.
+    See also #isDebugEnabled.
 
-		@return bool - <code>true</code> if this logger is enabled
-		for level error, <code>false</code> otherwise.
-		*/
-		bool isErrorEnabled() const;
+    @return bool - <code>true</code> if this logger is enabled
+    for level error, <code>false</code> otherwise.
+    */
+    bool isErrorEnabled() const;
 
-		/**
-		Check whether this logger is enabled for the fatal Level.
-		See also #isDebugEnabled.
+    /**
+    Check whether this logger is enabled for the fatal Level.
+    See also #isDebugEnabled.
 
-		@return bool - <code>true</code> if this logger is enabled
-		for level fatal, <code>false</code> otherwise.
-		*/
-		bool isFatalEnabled() const;
+    @return bool - <code>true</code> if this logger is enabled
+    for level fatal, <code>false</code> otherwise.
+    */
+    bool isFatalEnabled() const;
 
-		/**
-		Check whether this logger is enabled for the trace level.
-		See also #isDebugEnabled.
+    /**
+    Check whether this logger is enabled for the trace level.
+    See also #isDebugEnabled.
 
-		@return bool - <code>true</code> if this logger is enabled
-		for level trace, <code>false</code> otherwise.
-		*/
-		bool isTraceEnabled() const;
+    @return bool - <code>true</code> if this logger is enabled
+    for level trace, <code>false</code> otherwise.
+    */
+    bool isTraceEnabled() const;
 
-		/**
-		Log a localized and parameterized message.
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param values The values for the placeholders <code>{0}</code>,
-		              <code>{1}</code> etc. within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param values The values for the placeholders <code>{0}</code>,
+                  <code>{1}</code> etc. within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const LogString& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::vector<LogString>& values) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const LogString& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::vector<LogString>& values) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::string& key,
-			const log4cxx::spi::LocationInfo& locationInfo) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::string& key,
+                const log4cxx::spi::LocationInfo& locationInfo) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The first value for the placeholders within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The first value for the placeholders within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::string& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::string& val1) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::string& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::string& val1) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The first value for the placeholders within the pattern.
-		@param val2 The second value for the placeholders within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The first value for the placeholders within the pattern.
+    @param val2 The second value for the placeholders within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::string& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::string& val1, const std::string& val2) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::string& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::string& val1, const std::string& val2) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
-		@param val2 The value for the second placeholder within the pattern.
-		@param val3 The value for the third placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
+    @param val2 The value for the second placeholder within the pattern.
+    @param val3 The value for the third placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::string& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::string& val1, const std::string& val2, const std::string& val3) const;
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::string& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::string& val1, const std::string& val2, const std::string& val3) const;
 
 #if LOG4CXX_WCHAR_T_API
-		/**
-		Log a localized and parameterized message.
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::wstring& key,
-			const log4cxx::spi::LocationInfo& locationInfo) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::wstring& key,
+                const log4cxx::spi::LocationInfo& locationInfo) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::wstring& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::wstring& val1) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::wstring& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::wstring& val1) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
-		@param val2 The value for the second placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
+    @param val2 The value for the second placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::wstring& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::wstring& val1, const std::wstring& val2) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::wstring& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::wstring& val1, const std::wstring& val2) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
-		@param val2 The value for the second placeholder within the pattern.
-		@param val3 The value for the third placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
+    @param val2 The value for the second placeholder within the pattern.
+    @param val3 The value for the third placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::wstring& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::wstring& val1, const std::wstring& val2, const std::wstring& val3) const;
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::wstring& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::wstring& val1, const std::wstring& val2, const std::wstring& val3) const;
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		Log a localized and parameterized message.
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
-			const log4cxx::spi::LocationInfo& locationInfo) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
+                const log4cxx::spi::LocationInfo& locationInfo) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::basic_string<UniChar>& val1) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::basic_string<UniChar>& val1) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
-		@param val2 The value for the second placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
+    @param val2 The value for the second placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
-		@param val2 The value for the second placeholder within the pattern.
-		@param val3 The value for the third placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
+    @param val2 The value for the second placeholder within the pattern.
+    @param val3 The value for the third placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2,
-			const std::basic_string<UniChar>& val3) const;
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2,
+                const std::basic_string<UniChar>& val3) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		Log a localized and parameterized message.
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const CFStringRef& key,
-			const log4cxx::spi::LocationInfo& locationInfo) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const CFStringRef& key,
+                const log4cxx::spi::LocationInfo& locationInfo) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const CFStringRef& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const CFStringRef& val1) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const CFStringRef& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const CFStringRef& val1) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
-		@param val2 The value for the second placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
+    @param val2 The value for the second placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const CFStringRef& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const CFStringRef& val1, const CFStringRef& val2) const;
-		/**
-		Log a localized and parameterized message.
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const CFStringRef& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const CFStringRef& val1, const CFStringRef& val2) const;
+    /**
+    Log a localized and parameterized message.
 
-		First, the user supplied
-		<code>key</code> is searched in the resource bundle. Next, the resulting
-		pattern is formatted using helpers::StringHelper::format method with the user
-		supplied string array <code>params</code>.
+    First, the user supplied
+    <code>key</code> is searched in the resource bundle. Next, the resulting
+    pattern is formatted using helpers::StringHelper::format method with the user
+    supplied string array <code>params</code>.
 
-		@param level The level of the logging request.
-		@param key The key to be searched in the ResourceBundle.
-		@param locationInfo The location info of the logging request.
-		@param val1 The value for the first placeholder within the pattern.
-		@param val2 The value for the second placeholder within the pattern.
-		@param val3 The value for the third placeholder within the pattern.
+    @param level The level of the logging request.
+    @param key The key to be searched in the ResourceBundle.
+    @param locationInfo The location info of the logging request.
+    @param val1 The value for the first placeholder within the pattern.
+    @param val2 The value for the second placeholder within the pattern.
+    @param val3 The value for the third placeholder within the pattern.
 
-		@see #setResourceBundle
-		*/
-		void l7dlog(const LevelPtr& level, const CFStringRef& key,
-			const log4cxx::spi::LocationInfo& locationInfo,
-			const CFStringRef& val1, const CFStringRef& val2,
-			const CFStringRef& val3) const;
+    @see #setResourceBundle
+    */
+    void l7dlog(const LevelPtr& level, const CFStringRef& key,
+                const log4cxx::spi::LocationInfo& locationInfo,
+                const CFStringRef& val1, const CFStringRef& val2,
+                const CFStringRef& val3) const;
 #endif
 
-		/**
-		This is the most generic printing method. It is intended to be
-		invoked by <b>wrapper</b> classes.
+    /**
+    This is the most generic printing method. It is intended to be
+    invoked by <b>wrapper</b> classes.
 
-		@param level The level of the logging request.
-		@param message The message of the logging request.
-		@param location The source file of the logging request, may be null. */
-		void log(const LevelPtr& level, const std::string& message,
-			const log4cxx::spi::LocationInfo& location) const;
-		/**
-		This is the most generic printing method. It is intended to be
-		invoked by <b>wrapper</b> classes.
+    @param level The level of the logging request.
+    @param message The message of the logging request.
+    @param location The source file of the logging request, may be null. */
+    void log(const LevelPtr& level, const std::string& message,
+             const log4cxx::spi::LocationInfo& location) const;
+    /**
+    This is the most generic printing method. It is intended to be
+    invoked by <b>wrapper</b> classes.
 
-		@param level The level of the logging request.
-		@param message The message of the logging request.
-		*/
-		void log(const LevelPtr& level, const std::string& message) const;
+    @param level The level of the logging request.
+    @param message The message of the logging request.
+    */
+    void log(const LevelPtr& level, const std::string& message) const;
 #if LOG4CXX_WCHAR_T_API
-		/**
-		This is the most generic printing method. It is intended to be
-		invoked by <b>wrapper</b> classes.
+    /**
+    This is the most generic printing method. It is intended to be
+    invoked by <b>wrapper</b> classes.
 
-		@param level The level of the logging request.
-		@param message The message of the logging request.
-		@param location The source file of the logging request, may be null. */
-		void log(const LevelPtr& level, const std::wstring& message,
-			const log4cxx::spi::LocationInfo& location) const;
-		/**
-		This is the most generic printing method. It is intended to be
-		invoked by <b>wrapper</b> classes.
+    @param level The level of the logging request.
+    @param message The message of the logging request.
+    @param location The source file of the logging request, may be null. */
+    void log(const LevelPtr& level, const std::wstring& message,
+             const log4cxx::spi::LocationInfo& location) const;
+    /**
+    This is the most generic printing method. It is intended to be
+    invoked by <b>wrapper</b> classes.
 
-		@param level The level of the logging request.
-		@param message The message of the logging request.
-		*/
-		void log(const LevelPtr& level, const std::wstring& message) const;
+    @param level The level of the logging request.
+    @param message The message of the logging request.
+    */
+    void log(const LevelPtr& level, const std::wstring& message) const;
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		This is the most generic printing method. It is intended to be
-		invoked by <b>wrapper</b> classes.
+    /**
+    This is the most generic printing method. It is intended to be
+    invoked by <b>wrapper</b> classes.
 
-		@param level The level of the logging request.
-		@param message The message of the logging request.
-		@param location The source file of the logging request, may be null. */
-		void log(const LevelPtr& level, const std::basic_string<UniChar>& message,
-			const log4cxx::spi::LocationInfo& location) const;
-		/**
-		This is the most generic printing method. It is intended to be
-		invoked by <b>wrapper</b> classes.
+    @param level The level of the logging request.
+    @param message The message of the logging request.
+    @param location The source file of the logging request, may be null. */
+    void log(const LevelPtr& level, const std::basic_string<UniChar>& message,
+             const log4cxx::spi::LocationInfo& location) const;
+    /**
+    This is the most generic printing method. It is intended to be
+    invoked by <b>wrapper</b> classes.
 
-		@param level The level of the logging request.
-		@param message The message of the logging request.
-		*/
-		void log(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
+    @param level The level of the logging request.
+    @param message The message of the logging request.
+    */
+    void log(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		This is the most generic printing method. It is intended to be
-		invoked by <b>wrapper</b> classes.
+    /**
+    This is the most generic printing method. It is intended to be
+    invoked by <b>wrapper</b> classes.
 
-		@param level The level of the logging request.
-		@param message The message of the logging request.
-		@param location The source file of the logging request, may be null. */
-		void log(const LevelPtr& level, const CFStringRef& message,
-			const log4cxx::spi::LocationInfo& location) const;
-		/**
-		This is the most generic printing method. It is intended to be
-		invoked by <b>wrapper</b> classes.
+    @param level The level of the logging request.
+    @param message The message of the logging request.
+    @param location The source file of the logging request, may be null. */
+    void log(const LevelPtr& level, const CFStringRef& message,
+             const log4cxx::spi::LocationInfo& location) const;
+    /**
+    This is the most generic printing method. It is intended to be
+    invoked by <b>wrapper</b> classes.
 
-		@param level The level of the logging request.
-		@param message The message of the logging request.
-		*/
-		void log(const LevelPtr& level, const CFStringRef& message) const;
+    @param level The level of the logging request.
+    @param message The message of the logging request.
+    */
+    void log(const LevelPtr& level, const CFStringRef& message) const;
 #endif
-		/**
-		This is the most generic printing method. It is intended to be
-		invoked by <b>wrapper</b> classes.
+    /**
+    This is the most generic printing method. It is intended to be
+    invoked by <b>wrapper</b> classes.
 
-		@param level The level of the logging request.
-		@param message The message of the logging request.
-		@param location The source file of the logging request, may be null. */
-		void logLS(const LevelPtr& level, const LogString& message,
-			const log4cxx::spi::LocationInfo& location) const;
+    @param level The level of the logging request.
+    @param message The message of the logging request.
+    @param location The source file of the logging request, may be null. */
+    void logLS(const LevelPtr& level, const LogString& message,
+               const log4cxx::spi::LocationInfo& location) const;
 
 
 
-		/**
-		Remove all previously added appenders from this logger
-		instance.
-		<p>This is useful when re-reading configuration information.
-		*/
-		void removeAllAppenders();
+    /**
+    Remove all previously added appenders from this logger
+    instance.
+    <p>This is useful when re-reading configuration information.
+    */
+    void removeAllAppenders();
 
-		/**
-		Remove the appender passed as parameter form the list of appenders.
-		*/
-		void removeAppender(const AppenderPtr& appender);
+    /**
+    Remove the appender passed as parameter form the list of appenders.
+    */
+    void removeAppender(const AppenderPtr appender);
 
-		/**
-		Remove the appender with the name passed as parameter form the
-		list of appenders.
-		 */
-		void removeAppender(const LogString& name);
+    /**
+    Remove the appender with the name passed as parameter form the
+    list of appenders.
+     */
+    void removeAppender(const LogString& name);
 
-		/**
-		 Set the additivity flag for this Logger instance.
-		  */
-		void setAdditivity(bool additive);
+    /**
+     Set the additivity flag for this Logger instance.
+      */
+    void setAdditivity(bool additive);
 
-	protected:
-		friend class Hierarchy;
-		/**
-		Only the Hierarchy class can set the hierarchy of a logger.*/
-		void setHierarchy(spi::LoggerRepository* repository);
+protected:
+    friend class Hierarchy;
+    /**
+    Only the Hierarchy class can set the hierarchy of a logger.*/
+    void setHierarchy(spi::LoggerRepository* repository);
 
-	public:
-		/**
-		Set the level of this Logger.
+public:
+    /**
+    Set the level of this Logger.
 
-		<p>As in <pre> &nbsp;&nbsp;&nbsp;logger->setLevel(Level::getDebug()); </pre>
+    <p>As in <pre> &nbsp;&nbsp;&nbsp;logger->setLevel(Level::getDebug()); </pre>
 
-		<p>Null values are admitted.  */
-		virtual void setLevel(const LevelPtr& level);
+    <p>Null values are admitted.  */
+    virtual void setLevel(const LevelPtr level);
 
-		/**
-		Set the resource bundle to be used with localized logging methods.
-		*/
-		inline void setResourceBundle(const helpers::ResourceBundlePtr& bundle)
-		{
-			resourceBundle = bundle;
-		}
+    /**
+    Set the resource bundle to be used with localized logging methods.
+    */
+    inline void setResourceBundle(const helpers::ResourceBundlePtr& bundle)
+    {
+        resourceBundle = bundle;
+    }
 
 #if LOG4CXX_WCHAR_T_API
-		/**
-		Log a message string with the WARN level.
+    /**
+    Log a message string with the WARN level.
 
-		<p>This method first checks if this logger is <code>WARN</code>
-		enabled by comparing the level of this logger with the
-		WARN level. If this logger is
-		<code>WARN</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>WARN</code>
+    enabled by comparing the level of this logger with the
+    WARN level. If this logger is
+    <code>WARN</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void warn(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the WARN level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void warn(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the WARN level.
 
-		<p>This method first checks if this logger is <code>WARN</code>
-		enabled by comparing the level of this logger with the
-		WARN level. If this logger is
-		<code>WARN</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>WARN</code>
+    enabled by comparing the level of this logger with the
+    WARN level. If this logger is
+    <code>WARN</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void warn(const std::wstring& msg) const;
+    @param msg the message string to log.
+    */
+    void warn(const std::wstring& msg) const;
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		Log a message string with the WARN level.
+    /**
+    Log a message string with the WARN level.
 
-		<p>This method first checks if this logger is <code>WARN</code>
-		enabled by comparing the level of this logger with the
-		WARN level. If this logger is
-		<code>WARN</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>WARN</code>
+    enabled by comparing the level of this logger with the
+    WARN level. If this logger is
+    <code>WARN</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void warn(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the WARN level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void warn(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the WARN level.
 
-		<p>This method first checks if this logger is <code>WARN</code>
-		enabled by comparing the level of this logger with the
-		WARN level. If this logger is
-		<code>WARN</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>WARN</code>
+    enabled by comparing the level of this logger with the
+    WARN level. If this logger is
+    <code>WARN</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void warn(const std::basic_string<UniChar>& msg) const;
+    @param msg the message string to log.
+    */
+    void warn(const std::basic_string<UniChar>& msg) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		Log a message string with the WARN level.
+    /**
+    Log a message string with the WARN level.
 
-		<p>This method first checks if this logger is <code>WARN</code>
-		enabled by comparing the level of this logger with the
-		WARN level. If this logger is
-		<code>WARN</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>WARN</code>
+    enabled by comparing the level of this logger with the
+    WARN level. If this logger is
+    <code>WARN</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the WARN level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the WARN level.
 
-		<p>This method first checks if this logger is <code>WARN</code>
-		enabled by comparing the level of this logger with the
-		WARN level. If this logger is
-		<code>WARN</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>WARN</code>
+    enabled by comparing the level of this logger with the
+    WARN level. If this logger is
+    <code>WARN</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void warn(const CFStringRef& msg) const;
+    @param msg the message string to log.
+    */
+    void warn(const CFStringRef& msg) const;
 #endif
-		/**
-		Log a message string with the WARN level.
+    /**
+    Log a message string with the WARN level.
 
-		<p>This method first checks if this logger is <code>WARN</code>
-		enabled by comparing the level of this logger with the
-		WARN level. If this logger is
-		<code>WARN</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>WARN</code>
+    enabled by comparing the level of this logger with the
+    WARN level. If this logger is
+    <code>WARN</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void warn(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the WARN level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void warn(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the WARN level.
 
-		<p>This method first checks if this logger is <code>WARN</code>
-		enabled by comparing the level of this logger with the
-		WARN level. If this logger is
-		<code>WARN</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>WARN</code>
+    enabled by comparing the level of this logger with the
+    WARN level. If this logger is
+    <code>WARN</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void warn(const std::string& msg) const;
+    @param msg the message string to log.
+    */
+    void warn(const std::string& msg) const;
 
 #if LOG4CXX_WCHAR_T_API
-		/**
-		Log a message string with the TRACE level.
+    /**
+    Log a message string with the TRACE level.
 
-		<p>This method first checks if this logger is <code>TRACE</code>
-		enabled by comparing the level of this logger with the
-		TRACE level. If this logger is
-		<code>TRACE</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>TRACE</code>
+    enabled by comparing the level of this logger with the
+    TRACE level. If this logger is
+    <code>TRACE</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the TRACE level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the TRACE level.
 
-		<p>This method first checks if this logger is <code>TRACE</code>
-		enabled by comparing the level of this logger with the
-		TRACE level. If this logger is
-		<code>TRACE</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>TRACE</code>
+    enabled by comparing the level of this logger with the
+    TRACE level. If this logger is
+    <code>TRACE</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void trace(const std::wstring& msg) const;
+    @param msg the message string to log.
+    */
+    void trace(const std::wstring& msg) const;
 #endif
 #if LOG4CXX_UNICHAR_API
-		/**
-		Log a message string with the TRACE level.
+    /**
+    Log a message string with the TRACE level.
 
-		<p>This method first checks if this logger is <code>TRACE</code>
-		enabled by comparing the level of this logger with the
-		TRACE level. If this logger is
-		<code>TRACE</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>TRACE</code>
+    enabled by comparing the level of this logger with the
+    TRACE level. If this logger is
+    <code>TRACE</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void trace(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the TRACE level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void trace(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the TRACE level.
 
-		<p>This method first checks if this logger is <code>TRACE</code>
-		enabled by comparing the level of this logger with the
-		TRACE level. If this logger is
-		<code>TRACE</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>TRACE</code>
+    enabled by comparing the level of this logger with the
+    TRACE level. If this logger is
+    <code>TRACE</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void trace(const std::basic_string<UniChar>& msg) const;
+    @param msg the message string to log.
+    */
+    void trace(const std::basic_string<UniChar>& msg) const;
 #endif
 #if LOG4CXX_CFSTRING_API
-		/**
-		Log a message string with the TRACE level.
+    /**
+    Log a message string with the TRACE level.
 
-		<p>This method first checks if this logger is <code>TRACE</code>
-		enabled by comparing the level of this logger with the
-		TRACE level. If this logger is
-		<code>TRACE</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>TRACE</code>
+    enabled by comparing the level of this logger with the
+    TRACE level. If this logger is
+    <code>TRACE</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the TRACE level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the TRACE level.
 
-		<p>This method first checks if this logger is <code>TRACE</code>
-		enabled by comparing the level of this logger with the
-		TRACE level. If this logger is
-		<code>TRACE</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>TRACE</code>
+    enabled by comparing the level of this logger with the
+    TRACE level. If this logger is
+    <code>TRACE</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void trace(const CFStringRef& msg) const;
+    @param msg the message string to log.
+    */
+    void trace(const CFStringRef& msg) const;
 #endif
-		/**
-		Log a message string with the TRACE level.
+    /**
+    Log a message string with the TRACE level.
 
-		<p>This method first checks if this logger is <code>TRACE</code>
-		enabled by comparing the level of this logger with the
-		TRACE level. If this logger is
-		<code>TRACE</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>TRACE</code>
+    enabled by comparing the level of this logger with the
+    TRACE level. If this logger is
+    <code>TRACE</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		@param location location of source of logging request.
-		*/
-		void trace(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
-		/**
-		Log a message string with the TRACE level.
+    @param msg the message string to log.
+    @param location location of source of logging request.
+    */
+    void trace(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+    /**
+    Log a message string with the TRACE level.
 
-		<p>This method first checks if this logger is <code>TRACE</code>
-		enabled by comparing the level of this logger with the
-		TRACE level. If this logger is
-		<code>TRACE</code> enabled, it proceeds to call all the
-		registered appenders in this logger and also higher in the
-		hierarchy depending on the value of the additivity flag.
+    <p>This method first checks if this logger is <code>TRACE</code>
+    enabled by comparing the level of this logger with the
+    TRACE level. If this logger is
+    <code>TRACE</code> enabled, it proceeds to call all the
+    registered appenders in this logger and also higher in the
+    hierarchy depending on the value of the additivity flag.
 
-		@param msg the message string to log.
-		*/
-		void trace(const std::string& msg) const;
+    @param msg the message string to log.
+    */
+    void trace(const std::string& msg) const;
 
-		inline SHARED_MUTEX& getMutex()
-		{
-			return mutex;
-		}
+    /**
+     * Reconfigure this logger by configuring all of the appenders.
+     *
+     * @param appenders The appenders to set.  Any currently existing appenders are removed.
+     * @param additivity The additivity of this logger
+     */
+    void reconfigure( const std::vector<AppenderPtr>& appenders, bool additivity );
 
-	private:
-		//
-		//  prevent copy and assignment
-		Logger(const Logger&);
-		Logger& operator=(const Logger&);
-		mutable SHARED_MUTEX mutex;
-		friend class log4cxx::helpers::synchronized;
+private:
+    //
+    //  prevent copy and assignment
+    Logger(const Logger&);
+    Logger& operator=(const Logger&);
+	mutable shared_mutex mutex;
+    friend class log4cxx::helpers::synchronized;
 };
 LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
 
@@ -1740,23 +1738,23 @@
 */
 
 #if !defined(LOG4CXX_UNLIKELY)
-	#if __GNUC__ >= 3
-		/**
-		Provides optimization hint to the compiler
-		to optimize for the expression being false.
-		@param expr boolean expression.
-		@returns value of expression.
-		*/
-		#define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
-	#else
-		/**
-		Provides optimization hint to the compiler
-		to optimize for the expression being false.
-		@param expr boolean expression.
-		@returns value of expression.
-		**/
-		#define LOG4CXX_UNLIKELY(expr) expr
-	#endif
+#if __GNUC__ >= 3
+/**
+Provides optimization hint to the compiler
+to optimize for the expression being false.
+@param expr boolean expression.
+@returns value of expression.
+*/
+#define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
+#else
+/**
+Provides optimization hint to the compiler
+to optimize for the expression being false.
+@param expr boolean expression.
+@returns value of expression.
+**/
+#define LOG4CXX_UNLIKELY(expr) expr
+#endif
 #endif
 
 
@@ -1941,7 +1939,7 @@
 /**@}*/
 
 #if defined(_MSC_VER)
-	#pragma warning ( pop )
+#pragma warning ( pop )
 #endif
 
 #include <log4cxx/spi/loggerrepository.h>
diff --git a/src/main/include/log4cxx/logmanager.h b/src/main/include/log4cxx/logmanager.h
index eac2074..40f4614 100644
--- a/src/main/include/log4cxx/logmanager.h
+++ b/src/main/include/log4cxx/logmanager.h
@@ -30,13 +30,13 @@
 namespace log4cxx
 {
 class Logger;
-typedef helpers::ObjectPtrT<Logger> LoggerPtr;
+typedef std::shared_ptr<Logger> LoggerPtr;
 typedef std::vector<LoggerPtr> LoggerList;
 
 namespace spi
 {
 class LoggerFactory;
-typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
+typedef std::shared_ptr<LoggerFactory> LoggerFactoryPtr;
 }
 
 /**
@@ -50,7 +50,8 @@
 {
 	private:
 		static void* guard;
-		static spi::RepositorySelectorPtr& getRepositorySelector();
+        static spi::RepositorySelectorPtr repositorySelector;
+        static spi::RepositorySelectorPtr getRepositorySelector();
 
 	public:
 		/**
@@ -72,7 +73,7 @@
 		static void setRepositorySelector(spi::RepositorySelectorPtr selector,
 			void* guard);
 
-		static spi::LoggerRepositoryPtr& getLoggerRepository();
+        static spi::LoggerRepositoryPtr getLoggerRepository();
 
 		/**
 		Retrieve the appropriate root logger.
diff --git a/src/main/include/log4cxx/net/socketappenderskeleton.h b/src/main/include/log4cxx/net/socketappenderskeleton.h
index 184374f..c777f35 100644
--- a/src/main/include/log4cxx/net/socketappenderskeleton.h
+++ b/src/main/include/log4cxx/net/socketappenderskeleton.h
@@ -20,7 +20,6 @@
 
 #include <log4cxx/appenderskeleton.h>
 #include <log4cxx/helpers/socket.h>
-#include <log4cxx/helpers/thread.h>
 #include <log4cxx/helpers/objectoutputstream.h>
 
 #if defined(_MSC_VER)
@@ -189,8 +188,11 @@
 		     connection is droppped.
 		     */
 
-		helpers::Thread thread;
-		static void* LOG4CXX_THREAD_FUNC monitor(apr_thread_t* thread, void* data);
+		log4cxx::thread thread;
+		log4cxx::condition_variable interrupt;
+		log4cxx::mutex interrupt_mutex;
+		void monitor();
+		bool is_closed();
 		SocketAppenderSkeleton(const SocketAppenderSkeleton&);
 		SocketAppenderSkeleton& operator=(const SocketAppenderSkeleton&);
 
diff --git a/src/main/include/log4cxx/net/sockethubappender.h b/src/main/include/log4cxx/net/sockethubappender.h
index 69bc10c..a98eaa6 100644
--- a/src/main/include/log4cxx/net/sockethubappender.h
+++ b/src/main/include/log4cxx/net/sockethubappender.h
@@ -26,7 +26,7 @@
 
 #include <log4cxx/appenderskeleton.h>
 #include <vector>
-#include <log4cxx/helpers/thread.h>
+#include <thread>
 #include <log4cxx/helpers/objectoutputstream.h>
 
 
@@ -35,7 +35,7 @@
 namespace helpers
 {
 class ObjectOutputStream;
-typedef ObjectPtrT<ObjectOutputStream> ObjectOutputStreamPtr;
+typedef std::shared_ptr<ObjectOutputStream> ObjectOutputStreamPtr;
 }
 namespace net
 {
@@ -193,8 +193,8 @@
 	private:
 		void startServer();
 
-		helpers::Thread thread;
-		static void* LOG4CXX_THREAD_FUNC monitor(apr_thread_t* thread, void* data);
+		log4cxx::thread thread;
+		void monitor();
 
 }; // class SocketHubAppender
 LOG4CXX_PTR_DEF(SocketHubAppender);
diff --git a/src/main/include/log4cxx/net/telnetappender.h b/src/main/include/log4cxx/net/telnetappender.h
index 8f91ee9..e9b888a 100644
--- a/src/main/include/log4cxx/net/telnetappender.h
+++ b/src/main/include/log4cxx/net/telnetappender.h
@@ -28,7 +28,7 @@
 #include <log4cxx/appenderskeleton.h>
 #include <log4cxx/helpers/socket.h>
 #include <log4cxx/helpers/serversocket.h>
-#include <log4cxx/helpers/thread.h>
+#include <thread>
 #include <vector>
 #include <log4cxx/helpers/charsetencoder.h>
 
@@ -147,9 +147,9 @@
 		LogString encoding;
 		log4cxx::helpers::CharsetEncoderPtr encoder;
 		helpers::ServerSocket* serverSocket;
-		helpers::Thread sh;
+		log4cxx::thread sh;
 		size_t activeConnections;
-		static void* LOG4CXX_THREAD_FUNC acceptConnections(apr_thread_t* thread, void* data);
+		void acceptConnections();
 }; // class TelnetAppender
 
 LOG4CXX_PTR_DEF(TelnetAppender);
diff --git a/src/main/include/log4cxx/pattern/formattinginfo.h b/src/main/include/log4cxx/pattern/formattinginfo.h
index 6de60b5..d78b985 100644
--- a/src/main/include/log4cxx/pattern/formattinginfo.h
+++ b/src/main/include/log4cxx/pattern/formattinginfo.h
@@ -19,7 +19,7 @@
 #define _LOG4CXX_HELPER_FORMATTING_INFO_H
 
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/logstring.h>
 
 namespace log4cxx
@@ -29,7 +29,7 @@
 
 
 class FormattingInfo;
-typedef helpers::ObjectPtrT<FormattingInfo> FormattingInfoPtr;
+typedef std::shared_ptr<FormattingInfo> FormattingInfoPtr;
 
 
 /**
@@ -40,7 +40,7 @@
  *
  *
  */
-class LOG4CXX_EXPORT FormattingInfo : public virtual log4cxx::helpers::ObjectImpl
+class LOG4CXX_EXPORT FormattingInfo : public virtual log4cxx::helpers::Object
 {
 
 		/**
diff --git a/src/main/include/log4cxx/pattern/nameabbreviator.h b/src/main/include/log4cxx/pattern/nameabbreviator.h
index 86e4396..be65356 100644
--- a/src/main/include/log4cxx/pattern/nameabbreviator.h
+++ b/src/main/include/log4cxx/pattern/nameabbreviator.h
@@ -19,8 +19,7 @@
 #define _LOG4CXX_PATTERN_NAME_ABBREVIATOR
 
 #include <log4cxx/logstring.h>
-#include <log4cxx/helpers/objectptr.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 
 namespace log4cxx
 {
@@ -36,7 +35,7 @@
  *
  *
  */
-class LOG4CXX_EXPORT NameAbbreviator : public log4cxx::helpers::ObjectImpl
+class LOG4CXX_EXPORT NameAbbreviator : public log4cxx::helpers::Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(NameAbbreviator)
diff --git a/src/main/include/log4cxx/pattern/patternconverter.h b/src/main/include/log4cxx/pattern/patternconverter.h
index 5e13a00..bebca41 100644
--- a/src/main/include/log4cxx/pattern/patternconverter.h
+++ b/src/main/include/log4cxx/pattern/patternconverter.h
@@ -19,7 +19,7 @@
 #define _LOG4CXX_PATTERN_PATTERN_CONVERTER_H
 
 
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/logstring.h>
 #include <vector>
 
@@ -47,7 +47,7 @@
    converting an object in a converter specific manner.
 
  */
-class LOG4CXX_EXPORT PatternConverter : public virtual log4cxx::helpers::ObjectImpl
+class LOG4CXX_EXPORT PatternConverter : public virtual log4cxx::helpers::Object
 {
 
 		/**
diff --git a/src/main/include/log4cxx/private/log4cxx_private.h.in b/src/main/include/log4cxx/private/log4cxx_private.h.in
index 53e59ef..4726816 100644
--- a/src/main/include/log4cxx/private/log4cxx_private.h.in
+++ b/src/main/include/log4cxx/private/log4cxx_private.h.in
@@ -53,5 +53,4 @@
 #define LOG4CXX_WIN32_THREAD_FMTSPEC "0x%.8x"
 #define LOG4CXX_APR_THREAD_FMTSPEC "0x%pt"
 
-
 #endif
diff --git a/src/main/include/log4cxx/propertyconfigurator.h b/src/main/include/log4cxx/propertyconfigurator.h
index d4611fe..c9703bd 100644
--- a/src/main/include/log4cxx/propertyconfigurator.h
+++ b/src/main/include/log4cxx/propertyconfigurator.h
@@ -19,13 +19,12 @@
 #define _LOG4CXX_PROPERTY_CONFIGURATOR_H
 
 #if defined(_MSC_VER)
-	#pragma warning (push)
-	#pragma warning ( disable: 4231 4251 4275 4786 )
+#pragma warning (push)
+#pragma warning ( disable: 4231 4251 4275 4786 )
 #endif
 
 
-#include <log4cxx/helpers/objectptr.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/logstring.h>
 #include <log4cxx/spi/configurator.h>
 #include <map>
@@ -35,10 +34,10 @@
 namespace log4cxx
 {
 class Logger;
-typedef helpers::ObjectPtrT<Logger> LoggerPtr;
+typedef std::shared_ptr<Logger> LoggerPtr;
 
 class Appender;
-typedef helpers::ObjectPtrT<Appender> AppenderPtr;
+typedef std::shared_ptr<Appender> AppenderPtr;
 
 namespace helpers
 {
@@ -91,307 +90,304 @@
 <code>/home/xyz</code>.
 */
 class LOG4CXX_EXPORT PropertyConfigurator :
-	virtual public spi::Configurator,
-	virtual public helpers::ObjectImpl
+    virtual public spi::Configurator,
+    virtual public helpers::Object
 {
-	protected:
+protected:
 
-		/**
-		Used internally to keep track of configured appenders.
-		*/
-		std::map<LogString, AppenderPtr>* registry;
+    /**
+    Used internally to keep track of configured appenders.
+    */
+    std::map<LogString, AppenderPtr>* registry;
 
-		/**
-		Used to create new instances of logger
-		*/
-		helpers::ObjectPtrT<spi::LoggerFactory> loggerFactory;
+    /**
+    Used to create new instances of logger
+    */
+    std::shared_ptr<spi::LoggerFactory> loggerFactory;
 
-	public:
-		DECLARE_LOG4CXX_OBJECT(PropertyConfigurator)
-		BEGIN_LOG4CXX_CAST_MAP()
-		LOG4CXX_CAST_ENTRY(spi::Configurator)
-		END_LOG4CXX_CAST_MAP()
+public:
+    DECLARE_LOG4CXX_OBJECT(PropertyConfigurator)
+    BEGIN_LOG4CXX_CAST_MAP()
+    LOG4CXX_CAST_ENTRY(spi::Configurator)
+    END_LOG4CXX_CAST_MAP()
 
-		PropertyConfigurator();
-		virtual ~PropertyConfigurator();
-		void addRef() const;
-		void releaseRef() const;
+    PropertyConfigurator();
+    virtual ~PropertyConfigurator();
+    /**
+    Read configuration from a file. <b>The existing configuration is
+    not cleared nor reset.</b> If you require a different behavior,
+    then call {@link LogManager#resetConfiguration
+    resetConfiguration} method before calling
+    <code>doConfigure</code>.
 
-		/**
-		Read configuration from a file. <b>The existing configuration is
-		not cleared nor reset.</b> If you require a different behavior,
-		then call {@link LogManager#resetConfiguration
-		resetConfiguration} method before calling
-		<code>doConfigure</code>.
+    <p>The configuration file consists of statements in the format
+    <code>key=value</code>. The syntax of different configuration
+    elements are discussed below.
 
-		<p>The configuration file consists of statements in the format
-		<code>key=value</code>. The syntax of different configuration
-		elements are discussed below.
+    <h3>Repository-wide threshold</h3>
 
-		<h3>Repository-wide threshold</h3>
+    <p>The repository-wide threshold filters logging requests by level
+    regardless of logger. The syntax is:
 
-		<p>The repository-wide threshold filters logging requests by level
-		regardless of logger. The syntax is:
+    <pre>
+    log4j.threshold=[level]
+    </pre>
 
-		<pre>
-		log4j.threshold=[level]
-		</pre>
-
-		<p>The level value can consist of the string values OFF, FATAL,
-		ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
-		custom level value can be specified in the form
-		level#classname. By default the repository-wide threshold is set
-		to the lowest possible value, namely the level <code>ALL</code>.
-		</p>
+    <p>The level value can consist of the string values OFF, FATAL,
+    ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
+    custom level value can be specified in the form
+    level#classname. By default the repository-wide threshold is set
+    to the lowest possible value, namely the level <code>ALL</code>.
+    </p>
 
 
-		<h3>Appender configuration</h3>
+    <h3>Appender configuration</h3>
 
-		<p>Appender configuration syntax is:
-		<pre>
-		# For appender named <i>appenderName</i>, set its class.
-		# Note: The appender name can contain dots.
-		log4j.appender.appenderName=fully.qualified.name.of.appender.class
+    <p>Appender configuration syntax is:
+    <pre>
+    # For appender named <i>appenderName</i>, set its class.
+    # Note: The appender name can contain dots.
+    log4j.appender.appenderName=fully.qualified.name.of.appender.class
 
-		# Set appender specific options.
-		log4j.appender.appenderName.option1=value1
-		...
-		log4j.appender.appenderName.optionN=valueN
-		</pre>
+    # Set appender specific options.
+    log4j.appender.appenderName.option1=value1
+    ...
+    log4j.appender.appenderName.optionN=valueN
+    </pre>
 
-		For each named appender you can configure its {@link Layout Layout}. The
-		syntax for configuring an appender's layout is:
-		<pre>
-		log4j.appender.appenderName.layout=fully.qualified.name.of.layout.class
-		log4j.appender.appenderName.layout.option1=value1
-		....
-		log4j.appender.appenderName.layout.optionN=valueN
-		</pre>
+    For each named appender you can configure its {@link Layout Layout}. The
+    syntax for configuring an appender's layout is:
+    <pre>
+    log4j.appender.appenderName.layout=fully.qualified.name.of.layout.class
+    log4j.appender.appenderName.layout.option1=value1
+    ....
+    log4j.appender.appenderName.layout.optionN=valueN
+    </pre>
 
-		<h3>Configuring loggers</h3>
+    <h3>Configuring loggers</h3>
 
-		<p>The syntax for configuring the root logger is:
-		<pre>
-		log4j.rootLogger=[level], appenderName, appenderName, ...
-		</pre>
+    <p>The syntax for configuring the root logger is:
+    <pre>
+    log4j.rootLogger=[level], appenderName, appenderName, ...
+    </pre>
 
-		<p>This syntax means that an optional <em>level</em> can be
-		supplied followed by appender names separated by commas.
+    <p>This syntax means that an optional <em>level</em> can be
+    supplied followed by appender names separated by commas.
 
-		<p>The level value can consist of the string values OFF, FATAL,
-		ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
-		custom level value can be specified in the form
-		<code>level#classname</code>.
+    <p>The level value can consist of the string values OFF, FATAL,
+    ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
+    custom level value can be specified in the form
+    <code>level#classname</code>.
 
-		<p>If a level value is specified, then the root level is set
-		to the corresponding level.  If no level value is specified,
-		then the root level remains untouched.
+    <p>If a level value is specified, then the root level is set
+    to the corresponding level.  If no level value is specified,
+    then the root level remains untouched.
 
-		<p>The root logger can be assigned multiple appenders.
+    <p>The root logger can be assigned multiple appenders.
 
-		<p>Each <i>appenderName</i> (separated by commas) will be added to
-		the root logger. The named appender is defined using the
-		appender syntax defined above.
+    <p>Each <i>appenderName</i> (separated by commas) will be added to
+    the root logger. The named appender is defined using the
+    appender syntax defined above.
 
-		<p>For non-root categories the syntax is almost the same:
-		<pre>
-		log4j.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName,
-		...
-		</pre>
+    <p>For non-root categories the syntax is almost the same:
+    <pre>
+    log4j.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName,
+    ...
+    </pre>
 
-		<p>The meaning of the optional level value is discussed above
-		in relation to the root logger. In addition however, the value
-		INHERITED can be specified meaning that the named logger should
-		inherit its level from the logger hierarchy.
+    <p>The meaning of the optional level value is discussed above
+    in relation to the root logger. In addition however, the value
+    INHERITED can be specified meaning that the named logger should
+    inherit its level from the logger hierarchy.
 
-		<p>If no level value is supplied, then the level of the
-		named logger remains untouched.
+    <p>If no level value is supplied, then the level of the
+    named logger remains untouched.
 
-		<p>By default categories inherit their level from the
-		hierarchy. However, if you set the level of a logger and later
-		decide that that logger should inherit its level, then you should
-		specify INHERITED as the value for the level value. NULL is a
-		synonym for INHERITED.
+    <p>By default categories inherit their level from the
+    hierarchy. However, if you set the level of a logger and later
+    decide that that logger should inherit its level, then you should
+    specify INHERITED as the value for the level value. NULL is a
+    synonym for INHERITED.
 
-		<p>Similar to the root logger syntax, each <i>appenderName</i>
-		(separated by commas) will be attached to the named logger.
+    <p>Similar to the root logger syntax, each <i>appenderName</i>
+    (separated by commas) will be attached to the named logger.
 
-		<p>See the <a href="Introduction.html#additivity">appender
-		additivity rule</a> in the user manual for the meaning of the
-		<code>additivity</code> flag.
+    <p>See the <a href="Introduction.html#additivity">appender
+    additivity rule</a> in the user manual for the meaning of the
+    <code>additivity</code> flag.
 
-		<h3>Logger Factories</h3>
+    <h3>Logger Factories</h3>
 
-		The usage of custom logger factories is discouraged and no longer
-		documented.
+    The usage of custom logger factories is discouraged and no longer
+    documented.
 
-		<h3>Example</h3>
+    <h3>Example</h3>
 
-		<p>An example configuration is given below. Other configuration
-		file examples are given in the <code>examples</code> folder.
+    <p>An example configuration is given below. Other configuration
+    file examples are given in the <code>examples</code> folder.
 
-		<pre>
+    <pre>
 
-		# Set options for appender named "A1".
-		# Appender "A1" will be a SyslogAppender
-		log4j.appender.A1=SyslogAppender
+    # Set options for appender named "A1".
+    # Appender "A1" will be a SyslogAppender
+    log4j.appender.A1=SyslogAppender
 
-		# The syslog daemon resides on www.abc.net
-		log4j.appender.A1.SyslogHost=www.abc.net
+    # The syslog daemon resides on www.abc.net
+    log4j.appender.A1.SyslogHost=www.abc.net
 
-		# A1's layout is a PatternLayout, using the conversion pattern
-		# <b>%r %-5p %c{2} %M.%L %x - %m\n</b>. Thus, the log output will
-		# include # the relative time since the start of the application in
-		# milliseconds, followed by the level of the log request,
-		# followed by the two rightmost components of the logger name,
-		# followed by the callers method name, followed by the line number,
-		# the nested disgnostic context and finally the message itself.
-		# Refer to the documentation of PatternLayout for further information
-		# on the syntax of the ConversionPattern key.
-		log4j.appender.A1.layout=PatternLayout
-		log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c{2} %M.%L %x - %m\n
+    # A1's layout is a PatternLayout, using the conversion pattern
+    # <b>%r %-5p %c{2} %M.%L %x - %m\n</b>. Thus, the log output will
+    # include # the relative time since the start of the application in
+    # milliseconds, followed by the level of the log request,
+    # followed by the two rightmost components of the logger name,
+    # followed by the callers method name, followed by the line number,
+    # the nested disgnostic context and finally the message itself.
+    # Refer to the documentation of PatternLayout for further information
+    # on the syntax of the ConversionPattern key.
+    log4j.appender.A1.layout=PatternLayout
+    log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c{2} %M.%L %x - %m\n
 
-		# Set options for appender named "A2"
-		# A2 should be a RollingFileAppender, with maximum file size of 10 MB
-		# using at most one backup file. A2's layout is TTCC, using the
-		# ISO8061 date format with context printing enabled.
-		log4j.appender.A2=RollingFileAppender
-		log4j.appender.A2.MaxFileSize=10MB
-		log4j.appender.A2.MaxBackupIndex=1
-		log4j.appender.A2.layout=TTCCLayout
-		log4j.appender.A2.layout.ContextPrinting=enabled
-		log4j.appender.A2.layout.DateFormat=ISO8601
+    # Set options for appender named "A2"
+    # A2 should be a RollingFileAppender, with maximum file size of 10 MB
+    # using at most one backup file. A2's layout is TTCC, using the
+    # ISO8061 date format with context printing enabled.
+    log4j.appender.A2=RollingFileAppender
+    log4j.appender.A2.MaxFileSize=10MB
+    log4j.appender.A2.MaxBackupIndex=1
+    log4j.appender.A2.layout=TTCCLayout
+    log4j.appender.A2.layout.ContextPrinting=enabled
+    log4j.appender.A2.layout.DateFormat=ISO8601
 
-		# Root logger set to DEBUG using the A2 appender defined above.
-		log4j.rootLogger=DEBUG, A2
+    # Root logger set to DEBUG using the A2 appender defined above.
+    log4j.rootLogger=DEBUG, A2
 
-		# Logger definitions:
-		# The SECURITY logger inherits is level from root. However, it's output
-		# will go to A1 appender defined above. It's additivity is non-cumulative.
-		log4j.logger.SECURITY=INHERIT, A1
-		log4j.additivity.SECURITY=false
+    # Logger definitions:
+    # The SECURITY logger inherits is level from root. However, it's output
+    # will go to A1 appender defined above. It's additivity is non-cumulative.
+    log4j.logger.SECURITY=INHERIT, A1
+    log4j.additivity.SECURITY=false
 
-		# Only warnings or above will be logged for the logger "SECURITY.access".
-		# Output will go to A1.
-		log4j.logger.SECURITY.access=WARN
+    # Only warnings or above will be logged for the logger "SECURITY.access".
+    # Output will go to A1.
+    log4j.logger.SECURITY.access=WARN
 
 
-		# The logger "class.of.the.day" inherits its level from the
-		# logger hierarchy.  Output will go to the appender's of the root
-		# logger, A2 in this case.
-		log4j.logger.class.of.the.day=INHERIT
-		</pre>
+    # The logger "class.of.the.day" inherits its level from the
+    # logger hierarchy.  Output will go to the appender's of the root
+    # logger, A2 in this case.
+    log4j.logger.class.of.the.day=INHERIT
+    </pre>
 
-		<p>Refer to the <b>setOption</b> method in each Appender and
-		Layout for class specific options.
+    <p>Refer to the <b>setOption</b> method in each Appender and
+    Layout for class specific options.
 
-		<p>Use the <code>#</code> or <code>!</code> characters at the
-		beginning of a line for comments.
+    <p>Use the <code>#</code> or <code>!</code> characters at the
+    beginning of a line for comments.
 
-		<p>
-		@param configFileName The name of the configuration file where the
-		configuration information is stored.
-		@param hierarchy The hierarchy to operation upon.
-		*/
-		void doConfigure(const File& configFileName,
-			spi::LoggerRepositoryPtr& hierarchy);
+    <p>
+    @param configFileName The name of the configuration file where the
+    configuration information is stored.
+    @param hierarchy The hierarchy to operation upon.
+    */
+    void doConfigure(const File& configFileName,
+                     spi::LoggerRepositoryPtr hierarchy);
 
-		/**
-		Read configuration options from file <code>configFilename</code>.
-		*/
-		static void configure(const File& configFilename);
+    /**
+    Read configuration options from file <code>configFilename</code>.
+    */
+    static void configure(const File& configFilename);
 
-		/**
-		Like {@link #configureAndWatch(const File& configFilename, long delay)}
-		except that the
-		default delay as defined by helpers::FileWatchdog#DEFAULT_DELAY
-		is used.
-		@param configFilename A file in key=value format.
-		*/
-		static void configureAndWatch(const File& configFilename);
+    /**
+    Like {@link #configureAndWatch(const File& configFilename, long delay)}
+    except that the
+    default delay as defined by helpers::FileWatchdog#DEFAULT_DELAY
+    is used.
+    @param configFilename A file in key=value format.
+    */
+    static void configureAndWatch(const File& configFilename);
 
-		/**
-		Read the configuration file <code>configFilename</code> if it
-		exists. Moreover, a thread will be created that will periodically
-		check if <code>configFilename</code> has been created or
-		modified. The period is determined by the <code>delay</code>
-		argument. If a change or file creation is detected, then
-		<code>configFilename</code> is read to configure log4j.
+    /**
+    Read the configuration file <code>configFilename</code> if it
+    exists. Moreover, a thread will be created that will periodically
+    check if <code>configFilename</code> has been created or
+    modified. The period is determined by the <code>delay</code>
+    argument. If a change or file creation is detected, then
+    <code>configFilename</code> is read to configure log4j.
 
-		@param configFilename A file in key=value format.
-		@param delay The delay in milliseconds to wait between each check.
-		*/
-		static void configureAndWatch(const File& configFilename,
-			long delay);
+    @param configFilename A file in key=value format.
+    @param delay The delay in milliseconds to wait between each check.
+    */
+    static void configureAndWatch(const File& configFilename,
+                                  long delay);
 
-		/**
-		Read configuration options from <code>properties</code>.
-		See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
-		for the expected format.
-		*/
-		static void configure(helpers::Properties& properties);
+    /**
+    Read configuration options from <code>properties</code>.
+    See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
+    for the expected format.
+    */
+    static void configure(helpers::Properties& properties);
 
-		/**
-		Read configuration options from <code>properties</code>.
-		See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
-		for the expected format.
-		*/
-		void doConfigure(helpers::Properties& properties,
-			spi::LoggerRepositoryPtr& hierarchy);
+    /**
+    Read configuration options from <code>properties</code>.
+    See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
+    for the expected format.
+    */
+    void doConfigure(helpers::Properties& properties,
+                     spi::LoggerRepositoryPtr hierarchy);
 
-		// --------------------------------------------------------------------------
-		// Internal stuff
-		// --------------------------------------------------------------------------
-	protected:
-		/**
-		Check the provided <code>Properties</code> object for a
-		#loggerFactory
-		entry specified by LOGGER_FACTORY_KEY.  If such an entry
-		exists, an attempt is made to create an instance using the default
-		constructor.  This instance is used for subsequent Logger creations
-		within this configurator.
-		@see #parseCatsAndRenderers
-		*/
-		void configureLoggerFactory(helpers::Properties& props);
+    // --------------------------------------------------------------------------
+    // Internal stuff
+    // --------------------------------------------------------------------------
+protected:
+    /**
+    Check the provided <code>Properties</code> object for a
+    #loggerFactory
+    entry specified by LOGGER_FACTORY_KEY.  If such an entry
+    exists, an attempt is made to create an instance using the default
+    constructor.  This instance is used for subsequent Logger creations
+    within this configurator.
+    @see #parseCatsAndRenderers
+    */
+    void configureLoggerFactory(helpers::Properties& props);
 
-		void configureRootLogger(helpers::Properties& props,
-			spi::LoggerRepositoryPtr& hierarchy);
+    void configureRootLogger(helpers::Properties& props,
+                             spi::LoggerRepositoryPtr& hierarchy);
 
-		/**
-		Parse non-root elements, such non-root categories and renderers.
-		*/
-		void parseCatsAndRenderers(helpers::Properties& props,
-			spi::LoggerRepositoryPtr& hierarchy);
+    /**
+    Parse non-root elements, such non-root categories and renderers.
+    */
+    void parseCatsAndRenderers(helpers::Properties& props,
+                               spi::LoggerRepositoryPtr& hierarchy);
 
-		/**
-		Parse the additivity option for a non-root logger.
-		*/
-		void parseAdditivityForLogger(helpers::Properties& props,
-			LoggerPtr& cat, const LogString& loggerName);
+    /**
+    Parse the additivity option for a non-root logger.
+    */
+    bool parseAdditivityForLogger(helpers::Properties& props,
+                                  LoggerPtr& cat, const LogString& loggerName);
 
-		/**
-		This method must work for the root logger as well.
-		*/
-		void parseLogger(
-			helpers::Properties& props, LoggerPtr& logger,
-			const LogString& optionKey, const LogString& loggerName,
-			const LogString& value);
+    /**
+    This method must work for the root logger as well.
+    */
+    void parseLogger(
+        helpers::Properties& props, LoggerPtr& logger,
+        const LogString& optionKey, const LogString& loggerName,
+        const LogString& value, bool additivity);
 
-		AppenderPtr parseAppender(
-			helpers::Properties& props, const LogString& appenderName);
+    AppenderPtr parseAppender(
+        helpers::Properties& props, const LogString& appenderName);
 
-		void registryPut(const AppenderPtr& appender);
-		AppenderPtr registryGet(const LogString& name);
+    void registryPut(const AppenderPtr& appender);
+    AppenderPtr registryGet(const LogString& name);
 
-	private:
-		PropertyConfigurator(const PropertyConfigurator&);
-		PropertyConfigurator& operator=(const PropertyConfigurator&);
-		static PropertyWatchdog* pdog;
+private:
+    PropertyConfigurator(const PropertyConfigurator&);
+    PropertyConfigurator& operator=(const PropertyConfigurator&);
+    static PropertyWatchdog* pdog;
 }; // class PropertyConfigurator
 }  // namespace log4cxx
 
 #if defined(_MSC_VER)
-	#pragma warning (pop)
+#pragma warning (pop)
 #endif
 
 
diff --git a/src/main/include/log4cxx/provisionnode.h b/src/main/include/log4cxx/provisionnode.h
index cc7dff2..54244d5 100644
--- a/src/main/include/log4cxx/provisionnode.h
+++ b/src/main/include/log4cxx/provisionnode.h
@@ -19,13 +19,13 @@
 #define _LOG4CXX_PROVISION_NODE_H
 
 #include <vector>
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/logger.h>
 
 namespace log4cxx
 {
 class Logger;
-typedef helpers::ObjectPtrT<Logger> LoggerPtr;
+typedef std::shared_ptr<Logger> LoggerPtr;
 
 
 typedef std::vector<LoggerPtr> ProvisionNode;
diff --git a/src/main/include/log4cxx/rolling/action.h b/src/main/include/log4cxx/rolling/action.h
index 7c4f4c7..8a29ee9 100644
--- a/src/main/include/log4cxx/rolling/action.h
+++ b/src/main/include/log4cxx/rolling/action.h
@@ -19,8 +19,7 @@
 #define _LOG4CXX_ROLLING_ACTION_H
 
 #include <log4cxx/portability.h>
-#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/mutex.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/helpers/pool.h>
 
 namespace log4cxx
@@ -32,7 +31,7 @@
 /**
  *  A file system action performed as part of a rollover event.
  */
-class Action : public virtual log4cxx::helpers::ObjectImpl
+class Action : public virtual log4cxx::helpers::Object
 {
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(Action)
 		BEGIN_LOG4CXX_CAST_MAP()
@@ -49,7 +48,7 @@
 		bool interrupted;
 
 		log4cxx::helpers::Pool pool;
-		log4cxx::helpers::Mutex mutex;
+		log4cxx::mutex mutex;
 
 
 	protected:
diff --git a/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h b/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h
index e84f8ef..1663fdf 100644
--- a/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h
+++ b/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h
@@ -97,6 +97,8 @@
 		*/
 		virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
 
+		bool rolloverInternal(log4cxx::helpers::Pool& p);
+
 	protected:
 
 		RollingPolicyPtr getRollingPolicy() const;
diff --git a/src/main/include/log4cxx/rolling/rollingpolicybase.h b/src/main/include/log4cxx/rolling/rollingpolicybase.h
index 56753b1..045c1be 100644
--- a/src/main/include/log4cxx/rolling/rollingpolicybase.h
+++ b/src/main/include/log4cxx/rolling/rollingpolicybase.h
@@ -48,7 +48,7 @@
  */
 class LOG4CXX_EXPORT RollingPolicyBase :
 	public virtual RollingPolicy,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	protected:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(RollingPolicyBase)
@@ -77,9 +77,7 @@
 
 	public:
 		RollingPolicyBase();
-		virtual ~RollingPolicyBase();
-		void addRef() const;
-		void releaseRef() const;
+        virtual ~RollingPolicyBase();
 		virtual void activateOptions(log4cxx::helpers::Pool& p) = 0;
 		virtual log4cxx::pattern::PatternMap getFormatSpecifiers() const = 0;
 
diff --git a/src/main/include/log4cxx/rolling/rolloverdescription.h b/src/main/include/log4cxx/rolling/rolloverdescription.h
index a1a4d96..30894ab 100644
--- a/src/main/include/log4cxx/rolling/rolloverdescription.h
+++ b/src/main/include/log4cxx/rolling/rolloverdescription.h
@@ -27,7 +27,7 @@
 {
 
 
-class RolloverDescription : public log4cxx::helpers::ObjectImpl
+class RolloverDescription : public log4cxx::helpers::Object
 {
 		DECLARE_LOG4CXX_OBJECT(RolloverDescription)
 		BEGIN_LOG4CXX_CAST_MAP()
diff --git a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
index 46c4e3b..bb4a7e9 100755
--- a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
+++ b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
@@ -215,9 +215,7 @@
 		int suffixLength;
 
 	public:
-		TimeBasedRollingPolicy();
-		void addRef() const;
-		void releaseRef() const;
+        TimeBasedRollingPolicy();
 		void activateOptions(log4cxx::helpers::Pool& );
 
 #ifdef LOG4CXX_MULTI_PROCESS
diff --git a/src/main/include/log4cxx/rolling/triggeringpolicy.h b/src/main/include/log4cxx/rolling/triggeringpolicy.h
index d8a4169..098259c 100644
--- a/src/main/include/log4cxx/rolling/triggeringpolicy.h
+++ b/src/main/include/log4cxx/rolling/triggeringpolicy.h
@@ -21,7 +21,7 @@
 
 
 #include <log4cxx/spi/optionhandler.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/spi/loggingevent.h>
 #include <log4cxx/appender.h>
 
@@ -43,7 +43,7 @@
 
 class LOG4CXX_EXPORT TriggeringPolicy :
 	public virtual spi::OptionHandler,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(TriggeringPolicy)
 		BEGIN_LOG4CXX_CAST_MAP()
@@ -51,9 +51,7 @@
 		LOG4CXX_CAST_ENTRY(spi::OptionHandler)
 		END_LOG4CXX_CAST_MAP()
 	public:
-		virtual ~TriggeringPolicy();
-		void addRef() const;
-		void releaseRef() const;
+        virtual ~TriggeringPolicy();
 
 		/**
 		 * Determines if a rollover may be appropriate at this time.  If
diff --git a/src/main/include/log4cxx/spi/appenderattachable.h b/src/main/include/log4cxx/spi/appenderattachable.h
index 3f88af5..e855e37 100644
--- a/src/main/include/log4cxx/spi/appenderattachable.h
+++ b/src/main/include/log4cxx/spi/appenderattachable.h
@@ -25,7 +25,6 @@
 
 #include <log4cxx/logstring.h>
 #include <vector>
-#include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/helpers/object.h>
 #include <log4cxx/appender.h>
 
@@ -45,7 +44,7 @@
 		/**
 		 * Add an appender.
 		 */
-		virtual void addAppender(const AppenderPtr& newAppender) = 0;
+        virtual void addAppender(const AppenderPtr newAppender) = 0;
 
 		/**
 		 * Get all previously added appenders as an AppenderList.
@@ -61,7 +60,7 @@
 		 * Returns <code>true</code> if the specified appender is in list of
 		 * attached appenders, <code>false</code> otherwise.
 		 */
-		virtual bool isAttached(const AppenderPtr& appender) const = 0;
+        virtual bool isAttached(const AppenderPtr appender) const = 0;
 
 		/**
 		 * Remove all previously added appenders.
@@ -71,7 +70,7 @@
 		/**
 		 * Remove the appender passed as parameter from the list of appenders.
 		 */
-		virtual void removeAppender(const AppenderPtr& appender) = 0;
+        virtual void removeAppender(const AppenderPtr appender) = 0;
 
 		/**
 		 * Remove the appender with the name passed as parameter from the
diff --git a/src/main/include/log4cxx/spi/configurator.h b/src/main/include/log4cxx/spi/configurator.h
index c7a8706..172999d 100644
--- a/src/main/include/log4cxx/spi/configurator.h
+++ b/src/main/include/log4cxx/spi/configurator.h
@@ -45,7 +45,7 @@
 		@param repository The hierarchy to operation upon.
 		*/
 		virtual void doConfigure(const File& configFileName,
-			spi::LoggerRepositoryPtr& repository) = 0;
+            spi::LoggerRepositoryPtr repository) = 0;
 
 
 	private:
diff --git a/src/main/include/log4cxx/spi/defaultrepositoryselector.h b/src/main/include/log4cxx/spi/defaultrepositoryselector.h
index 267f77e..2759335 100644
--- a/src/main/include/log4cxx/spi/defaultrepositoryselector.h
+++ b/src/main/include/log4cxx/spi/defaultrepositoryselector.h
@@ -19,7 +19,7 @@
 #define _LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H
 
 #include <log4cxx/spi/repositoryselector.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/spi/loggerrepository.h>
 
 namespace log4cxx
@@ -28,7 +28,7 @@
 {
 class LOG4CXX_EXPORT DefaultRepositorySelector :
 	public virtual RepositorySelector,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultRepositorySelector)
@@ -36,10 +36,8 @@
 		LOG4CXX_CAST_ENTRY(RepositorySelector)
 		END_LOG4CXX_CAST_MAP()
 
-		DefaultRepositorySelector(const LoggerRepositoryPtr& repository1);
-		void addRef() const;
-		void releaseRef() const;
-		virtual LoggerRepositoryPtr& getLoggerRepository();
+        DefaultRepositorySelector(const LoggerRepositoryPtr repository1);
+        virtual LoggerRepositoryPtr getLoggerRepository();
 
 	private:
 		LoggerRepositoryPtr repository;
diff --git a/src/main/include/log4cxx/spi/filter.h b/src/main/include/log4cxx/spi/filter.h
index 2f5fd89..94dfd24 100644
--- a/src/main/include/log4cxx/spi/filter.h
+++ b/src/main/include/log4cxx/spi/filter.h
@@ -18,8 +18,7 @@
 #ifndef _LOG4CXX_SPI_FILTER_H
 #define _LOG4CXX_SPI_FILTER_H
 
-#include <log4cxx/helpers/objectptr.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/spi/optionhandler.h>
 #include <log4cxx/spi/loggingevent.h>
 
@@ -67,7 +66,7 @@
 xml::DOMConfigurator DOMConfigurator}.
 */
 class LOG4CXX_EXPORT Filter : public virtual OptionHandler,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 		/**
 		Points to the next filter in the filter chain.
@@ -76,9 +75,6 @@
 	public:
 		Filter();
 
-		void addRef() const;
-		void releaseRef() const;
-
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(Filter)
 		BEGIN_LOG4CXX_CAST_MAP()
 		LOG4CXX_CAST_ENTRY(Filter)
diff --git a/src/main/include/log4cxx/spi/hierarchyeventlistener.h b/src/main/include/log4cxx/spi/hierarchyeventlistener.h
index d5e32bb..4648c3b 100644
--- a/src/main/include/log4cxx/spi/hierarchyeventlistener.h
+++ b/src/main/include/log4cxx/spi/hierarchyeventlistener.h
@@ -25,7 +25,6 @@
 
 
 #include <log4cxx/helpers/object.h>
-#include <log4cxx/helpers/objectptr.h>
 #include <vector>
 
 namespace log4cxx
@@ -45,12 +44,12 @@
 		virtual ~HierarchyEventListener() {}
 
 		virtual void addAppenderEvent(
-			const log4cxx::helpers::ObjectPtrT<Logger>& logger,
-			const log4cxx::helpers::ObjectPtrT<Appender>& appender) = 0;
+            const Logger* logger,
+            const Appender* appender) = 0;
 
 		virtual void removeAppenderEvent(
-			const log4cxx::helpers::ObjectPtrT<Logger>& logger,
-			const log4cxx::helpers::ObjectPtrT<Appender>& appender) = 0;
+            const Logger* logger,
+            const Appender* appender) = 0;
 };
 LOG4CXX_PTR_DEF(HierarchyEventListener);
 LOG4CXX_LIST_DEF(HierarchyEventListenerList, HierarchyEventListenerPtr);
diff --git a/src/main/include/log4cxx/spi/loggerrepository.h b/src/main/include/log4cxx/spi/loggerrepository.h
index 794c72d..bfe5dbd 100644
--- a/src/main/include/log4cxx/spi/loggerrepository.h
+++ b/src/main/include/log4cxx/spi/loggerrepository.h
@@ -74,7 +74,7 @@
 		parameter instead of a <code>Level</code>. */
 		virtual void setThreshold(const LogString& val) = 0;
 
-		virtual void emitNoAppenderWarning(const LoggerPtr& logger) = 0;
+        virtual void emitNoAppenderWarning(const Logger* logger) = 0;
 
 		/**
 		Get the repository-wide threshold. See {@link
@@ -95,8 +95,8 @@
 
 		virtual LoggerList getCurrentLoggers() const = 0;
 
-		virtual void fireAddAppenderEvent(const LoggerPtr& logger,
-			const AppenderPtr& appender) = 0;
+        virtual void fireAddAppenderEvent(const Logger* logger,
+            const Appender* appender) = 0;
 
 		virtual void resetConfiguration() = 0;
 
diff --git a/src/main/include/log4cxx/spi/loggingevent.h b/src/main/include/log4cxx/spi/loggingevent.h
index 20bdfa9..74569c5 100644
--- a/src/main/include/log4cxx/spi/loggingevent.h
+++ b/src/main/include/log4cxx/spi/loggingevent.h
@@ -23,9 +23,6 @@
 	#pragma warning ( disable: 4231 4251 4275 4786 )
 #endif
 
-
-
-#include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/logstring.h>
 #include <time.h>
 #include <log4cxx/logger.h>
@@ -54,7 +51,7 @@
 <p>This class is of concern to those wishing to extend log4cxx.
 */
 class LOG4CXX_EXPORT LoggingEvent :
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	public:
 		DECLARE_LOG4CXX_OBJECT(LoggingEvent)
diff --git a/src/main/include/log4cxx/spi/optionhandler.h b/src/main/include/log4cxx/spi/optionhandler.h
index 58fdf7b..18b74bf 100644
--- a/src/main/include/log4cxx/spi/optionhandler.h
+++ b/src/main/include/log4cxx/spi/optionhandler.h
@@ -20,14 +20,13 @@
 
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/object.h>
-#include <log4cxx/helpers/objectptr.h>
 
 namespace log4cxx
 {
 namespace spi
 {
 class OptionHandler;
-typedef helpers::ObjectPtrT<OptionHandler> OptionHandlerPtr;
+typedef std::shared_ptr<OptionHandler> OptionHandlerPtr;
 
 /**
 A string based interface to configure package components.
diff --git a/src/main/include/log4cxx/spi/repositoryselector.h b/src/main/include/log4cxx/spi/repositoryselector.h
index fe9542d..af141b7 100644
--- a/src/main/include/log4cxx/spi/repositoryselector.h
+++ b/src/main/include/log4cxx/spi/repositoryselector.h
@@ -18,7 +18,6 @@
 #ifndef _LOG4CXX_SPI_REPOSITORY_SELECTOR_H
 #define _LOG4CXX_SPI_REPOSITORY_SELECTOR_H
 
-#include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/helpers/object.h>
 
 namespace log4cxx
@@ -26,7 +25,7 @@
 namespace spi
 {
 class LoggerRepository;
-typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
+typedef std::shared_ptr<LoggerRepository> LoggerRepositoryPtr;
 
 /**
 The <code>LogManager</code> uses one (and only one)
@@ -45,7 +44,7 @@
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(RepositorySelector)
 		virtual ~RepositorySelector() {}
-		virtual LoggerRepositoryPtr& getLoggerRepository() = 0;
+        virtual LoggerRepositoryPtr getLoggerRepository() = 0;
 };
 LOG4CXX_PTR_DEF(RepositorySelector);
 }  //namespace spi
diff --git a/src/main/include/log4cxx/spi/rootlogger.h b/src/main/include/log4cxx/spi/rootlogger.h
index f2f3e8c..671dfa9 100644
--- a/src/main/include/log4cxx/spi/rootlogger.h
+++ b/src/main/include/log4cxx/spi/rootlogger.h
@@ -40,19 +40,21 @@
 		The root logger names itself as "root". However, the root
 		logger cannot be retrieved by name.
 		*/
-		RootLogger(log4cxx::helpers::Pool& pool, const LevelPtr& level);
+        RootLogger(log4cxx::helpers::Pool& pool, const LevelPtr level);
+
+        ~RootLogger(){}
 
 		/**
 		Return the assigned level value without walking the logger
 		hierarchy.
 		*/
-		virtual const LevelPtr& getEffectiveLevel() const;
+        virtual const LevelPtr getEffectiveLevel() const;
 
 		/**
 		            Setting a null value to the level of the root logger may have catastrophic
 		            results. We prevent this here.
 		            */
-		void setLevel(const LevelPtr& level);
+        void setLevel(const LevelPtr level);
 };
 }  // namespace spi
 } // namespace log4cxx
diff --git a/src/main/include/log4cxx/varia/fallbackerrorhandler.h b/src/main/include/log4cxx/varia/fallbackerrorhandler.h
index 728398e..218d109 100644
--- a/src/main/include/log4cxx/varia/fallbackerrorhandler.h
+++ b/src/main/include/log4cxx/varia/fallbackerrorhandler.h
@@ -19,7 +19,7 @@
 #define _LOG4CXX_VARIA_FALLBACK_ERROR_HANDLER_H
 
 #include <log4cxx/spi/errorhandler.h>
-#include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/appender.h>
 #include <log4cxx/logger.h>
 #include <vector>
@@ -39,7 +39,7 @@
 */
 class LOG4CXX_EXPORT FallbackErrorHandler :
 	public virtual spi::ErrorHandler,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	private:
 		AppenderPtr backup;
@@ -53,10 +53,7 @@
 		LOG4CXX_CAST_ENTRY_CHAIN(spi::ErrorHandler)
 		END_LOG4CXX_CAST_MAP()
 
-		FallbackErrorHandler();
-		void addRef() const;
-		void releaseRef() const;
-
+        FallbackErrorHandler();
 
 		/**
 		<em>Adds</em> the logger passed as parameter to the list of
diff --git a/src/main/include/log4cxx/writerappender.h b/src/main/include/log4cxx/writerappender.h
index 677c4de..9907ddf 100644
--- a/src/main/include/log4cxx/writerappender.h
+++ b/src/main/include/log4cxx/writerappender.h
@@ -19,8 +19,8 @@
 #define _LOG4CXX_WRITER_APPENDER_H
 
 #if defined(_MSC_VER)
-	#pragma warning ( push )
-	#pragma warning ( disable: 4231 4251 4275 4786 )
+#pragma warning ( push )
+#pragma warning ( disable: 4231 4251 4275 4786 )
 #endif
 
 #include <log4cxx/appenderskeleton.h>
@@ -39,181 +39,186 @@
 */
 class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton
 {
-	private:
-		/**
-		Immediate flush means that the underlying writer or output stream
-		will be flushed at the end of each append operation. Immediate
-		flush is slower but ensures that each append request is actually
-		written. If <code>immediateFlush</code> is set to
-		<code>false</code>, then there is a good chance that the last few
-		logs events are not actually written to persistent media if and
-		when the application crashes.
+private:
+    /**
+    Immediate flush means that the underlying writer or output stream
+    will be flushed at the end of each append operation. Immediate
+    flush is slower but ensures that each append request is actually
+    written. If <code>immediateFlush</code> is set to
+    <code>false</code>, then there is a good chance that the last few
+    logs events are not actually written to persistent media if and
+    when the application crashes.
 
-		<p>The <code>immediateFlush</code> variable is set to
-		<code>true</code> by default.
+    <p>The <code>immediateFlush</code> variable is set to
+    <code>true</code> by default.
 
-		*/
-		bool immediateFlush;
+    */
+	std::atomic<bool> immediateFlush;
 
-		/**
-		The encoding to use when opening an input stream.
-		<p>The <code>encoding</code> variable is set to <code>""</code> by
-		default which results in the utilization of the system's default
-		encoding.  */
-		LogString encoding;
+    /**
+    The encoding to use when opening an input stream.
+    <p>The <code>encoding</code> variable is set to <code>""</code> by
+    default which results in the utilization of the system's default
+    encoding.  */
+    LogString encoding;
 
-		/**
-		*  This is the {@link Writer Writer} where we will write to.
-		*/
-		log4cxx::helpers::WriterPtr writer;
+    /**
+    *  This is the {@link Writer Writer} where we will write to.
+    */
+    log4cxx::helpers::WriterPtr writer;
 
 
-	public:
-		DECLARE_ABSTRACT_LOG4CXX_OBJECT(WriterAppender)
-		BEGIN_LOG4CXX_CAST_MAP()
-		LOG4CXX_CAST_ENTRY(WriterAppender)
-		LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
-		END_LOG4CXX_CAST_MAP()
+public:
+    DECLARE_ABSTRACT_LOG4CXX_OBJECT(WriterAppender)
+    BEGIN_LOG4CXX_CAST_MAP()
+    LOG4CXX_CAST_ENTRY(WriterAppender)
+    LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+    END_LOG4CXX_CAST_MAP()
 
-		/**
-		This default constructor does nothing.*/
-		WriterAppender();
-	protected:
-		WriterAppender(const LayoutPtr& layout,
-			log4cxx::helpers::WriterPtr& writer);
-		WriterAppender(const LayoutPtr& layout);
+    /**
+    This default constructor does nothing.*/
+    WriterAppender();
+protected:
+    WriterAppender(const LayoutPtr& layout,
+                   log4cxx::helpers::WriterPtr& writer);
+    WriterAppender(const LayoutPtr& layout);
 
-	public:
-		~WriterAppender();
+public:
+    ~WriterAppender();
 
-		/**
-		Derived appenders should override this method if option structure
-		requires it.
-		*/
-		virtual void activateOptions(log4cxx::helpers::Pool& pool);
+    /**
+    Derived appenders should override this method if option structure
+    requires it.
+    */
+    virtual void activateOptions(log4cxx::helpers::Pool& pool);
 
-		/**
-		If the <b>ImmediateFlush</b> option is set to
-		<code>true</code>, the appender will flush at the end of each
-		write. This is the default behavior. If the option is set to
-		<code>false</code>, then the underlying stream can defer writing
-		to physical medium to a later time.
+    /**
+    If the <b>ImmediateFlush</b> option is set to
+    <code>true</code>, the appender will flush at the end of each
+    write. This is the default behavior. If the option is set to
+    <code>false</code>, then the underlying stream can defer writing
+    to physical medium to a later time.
 
-		<p>Avoiding the flush operation at the end of each append results in
-		a performance gain of 10 to 20 percent. However, there is safety
-		tradeoff involved in skipping flushing. Indeed, when flushing is
-		skipped, then it is likely that the last few log events will not
-		be recorded on disk when the application exits. This is a high
-		price to pay even for a 20% performance gain.
-		*/
-		void setImmediateFlush(bool value);
-		/**
-		Returns value of the <b>ImmediateFlush</b> option.
-		*/
-		bool getImmediateFlush() const
-		{
-			return immediateFlush;
-		}
+    <p>Avoiding the flush operation at the end of each append results in
+    a performance gain of 10 to 20 percent. However, there is safety
+    tradeoff involved in skipping flushing. Indeed, when flushing is
+    skipped, then it is likely that the last few log events will not
+    be recorded on disk when the application exits. This is a high
+    price to pay even for a 20% performance gain.
+    */
+    void setImmediateFlush(bool value);
+    /**
+    Returns value of the <b>ImmediateFlush</b> option.
+    */
+    bool getImmediateFlush() const
+    {
+        return immediateFlush;
+    }
 
-		/**
-		This method is called by the AppenderSkeleton#doAppend
-		method.
+    /**
+    This method is called by the AppenderSkeleton#doAppend
+    method.
 
-		<p>If the output stream exists and is writable then write a log
-		statement to the output stream. Otherwise, write a single warning
-		message to <code>stderr</code>.
+    <p>If the output stream exists and is writable then write a log
+    statement to the output stream. Otherwise, write a single warning
+    message to <code>stderr</code>.
 
-		<p>The format of the output will depend on this appender's
-		layout.
+    <p>The format of the output will depend on this appender's
+    layout.
 
-		*/
-		virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+    */
+    virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
 
 
-	protected:
-		/**
-		This method determines if there is a sense in attempting to append.
+protected:
+    /**
+    This method determines if there is a sense in attempting to append.
 
-		<p>It checks whether there is a set output target and also if
-		there is a set layout. If these checks fail, then the boolean
-		value <code>false</code> is returned. */
-		virtual bool checkEntryConditions() const;
+    <p>It checks whether there is a set output target and also if
+    there is a set layout. If these checks fail, then the boolean
+    value <code>false</code> is returned. */
+    virtual bool checkEntryConditions() const;
 
 
-	public:
-		/**
-		Close this appender instance. The underlying stream or writer is
-		also closed.
+public:
+    /**
+    Close this appender instance. The underlying stream or writer is
+    also closed.
 
-		<p>Closed appenders cannot be reused.
-		*/
-		virtual void close();
+    <p>Closed appenders cannot be reused.
+    */
+    virtual void close();
 
-	protected:
-		/**
-		 * Close the underlying {@link log4cxx::helpers::Writer}.
-		 * */
-		void closeWriter();
+protected:
+    /**
+     * Close the underlying {@link log4cxx::helpers::Writer}.
+     * */
+    void closeWriter();
 
-		/**
-		    Returns an OutputStreamWriter when passed an OutputStream.  The
-		    encoding used will depend on the value of the
-		    <code>encoding</code> property.  If the encoding value is
-		    specified incorrectly the writer will be opened using the default
-		    system encoding (an error message will be printed to the loglog.  */
-		virtual log4cxx::helpers::WriterPtr createWriter(
-			log4cxx::helpers::OutputStreamPtr& os);
+    /**
+        Returns an OutputStreamWriter when passed an OutputStream.  The
+        encoding used will depend on the value of the
+        <code>encoding</code> property.  If the encoding value is
+        specified incorrectly the writer will be opened using the default
+        system encoding (an error message will be printed to the loglog.  */
+    virtual log4cxx::helpers::WriterPtr createWriter(
+        log4cxx::helpers::OutputStreamPtr& os);
 
-	public:
-		LogString getEncoding() const;
-		void setEncoding(const LogString& value);
-		void setOption(const LogString& option,
-			const LogString& value);
+public:
+    LogString getEncoding() const;
+    void setEncoding(const LogString& value);
+    void setOption(const LogString& option,
+                   const LogString& value);
 
-		/**
-		  <p>Sets the Writer where the log output will go. The
-		  specified Writer must be opened by the user and be
-		  writable.
+    /**
+      <p>Sets the Writer where the log output will go. The
+      specified Writer must be opened by the user and be
+      writable.
 
-		  <p>The <code>java.io.Writer</code> will be closed when the
-		  appender instance is closed.
+      <p>The <code>java.io.Writer</code> will be closed when the
+      appender instance is closed.
 
 
-		  <p><b>WARNING:</b> Logging to an unopened Writer will fail.
-		  <p>
-		  @param writer An already opened Writer.  */
-		void setWriter(const log4cxx::helpers::WriterPtr& writer);
+      <p><b>WARNING:</b> Logging to an unopened Writer will fail.
+      <p>
+      @param writer An already opened Writer.  */
+    void setWriter(const log4cxx::helpers::WriterPtr& writer);
 #ifdef LOG4CXX_MULTI_PROCESS
-		const log4cxx::helpers::WriterPtr getWriter()
-		{
-			return writer;
-		};
+    const log4cxx::helpers::WriterPtr getWriter()
+    {
+        return writer;
+    };
 #endif
 
-		virtual bool requiresLayout() const;
+    virtual bool requiresLayout() const;
 
-	protected:
-		/**
-		 Actual writing occurs here.
-		*/
-		virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+protected:
+    /**
+     Actual writing occurs here.
+    */
+    virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
 
 
-		/**
-		Write a footer as produced by the embedded layout's
-		Layout#appendFooter method.  */
-		virtual void writeFooter(log4cxx::helpers::Pool& p);
+    /**
+    Write a footer as produced by the embedded layout's
+    Layout#appendFooter method.  */
+    virtual void writeFooter(log4cxx::helpers::Pool& p);
 
-		/**
-		Write a header as produced by the embedded layout's
-		Layout#appendHeader method.  */
-		virtual void writeHeader(log4cxx::helpers::Pool& p);
+    /**
+    Write a header as produced by the embedded layout's
+    Layout#appendHeader method.  */
+    virtual void writeHeader(log4cxx::helpers::Pool& p);
 
-	private:
-		//
-		//  prevent copy and assignment
-		WriterAppender(const WriterAppender&);
-		WriterAppender& operator=(const WriterAppender&);
+    /**
+     * Set the writer.  Mutex must already be held.
+     */
+    void setWriterInternal(const log4cxx::helpers::WriterPtr& writer);
+
+private:
+    //
+    //  prevent copy and assignment
+    WriterAppender(const WriterAppender&);
+    WriterAppender& operator=(const WriterAppender&);
 };
 
 LOG4CXX_PTR_DEF(WriterAppender);
@@ -221,7 +226,7 @@
 }  //namespace log4cxx
 
 #if defined(_MSC_VER)
-	#pragma warning ( pop )
+#pragma warning ( pop )
 #endif
 
 #endif //_LOG4CXX_WRITER_APPENDER_H
diff --git a/src/main/include/log4cxx/xml/domconfigurator.h b/src/main/include/log4cxx/xml/domconfigurator.h
index e6ed348..5b8756b 100644
--- a/src/main/include/log4cxx/xml/domconfigurator.h
+++ b/src/main/include/log4cxx/xml/domconfigurator.h
@@ -19,8 +19,8 @@
 #define _LOG4CXX_XML_DOM_CONFIGURATOR_H
 
 #if defined(_MSC_VER)
-	#pragma warning (push)
-	#pragma warning ( disable: 4231 4251 4275 4786 )
+#pragma warning (push)
+#pragma warning ( disable: 4231 4251 4275 4786 )
 #endif
 
 
@@ -40,8 +40,8 @@
 #include <log4cxx/config/propertysetter.h>
 
 extern "C" {
-	struct apr_xml_doc;
-	struct apr_xml_elem;
+    struct apr_xml_doc;
+    struct apr_xml_elem;
 }
 
 namespace log4cxx
@@ -67,251 +67,251 @@
 <p>There are sample XML files included in the package.
 */
 class LOG4CXX_EXPORT DOMConfigurator :
-	virtual public spi::Configurator,
-	virtual public helpers::ObjectImpl
+    virtual public spi::Configurator,
+    virtual public helpers::Object
 {
-	protected:
-		typedef std::map<LogString, AppenderPtr> AppenderMap;
-		/**
-		Used internally to parse appenders by IDREF name.
-		*/
-		AppenderPtr findAppenderByName(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* elem,
-			apr_xml_doc* doc,
-			const LogString& appenderName,
-			AppenderMap& appenders);
+protected:
+    typedef std::map<LogString, AppenderPtr> AppenderMap;
+    /**
+    Used internally to parse appenders by IDREF name.
+    */
+    AppenderPtr findAppenderByName(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* elem,
+        apr_xml_doc* doc,
+        const LogString& appenderName,
+        AppenderMap& appenders);
 
-		/**
-		Used internally to parse appenders by IDREF element.
-		*/
-		AppenderPtr findAppenderByReference(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* appenderRef,
-			apr_xml_doc* doc,
-			AppenderMap& appenders);
+    /**
+    Used internally to parse appenders by IDREF element.
+    */
+    AppenderPtr findAppenderByReference(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* appenderRef,
+        apr_xml_doc* doc,
+        AppenderMap& appenders);
 
-		/**
-		Used internally to parse an appender element.
-		*/
-		AppenderPtr parseAppender(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* appenderElement,
-			apr_xml_doc* doc,
-			AppenderMap& appenders);
+    /**
+    Used internally to parse an appender element.
+    */
+    AppenderPtr parseAppender(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* appenderElement,
+        apr_xml_doc* doc,
+        AppenderMap& appenders);
 
-		/**
-		Used internally to parse an {@link spi::ErrorHandler ErrorHandler } element.
-		*/
-		void parseErrorHandler(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* element,
-			AppenderPtr& appender,
-			apr_xml_doc* doc,
-			AppenderMap& appenders);
+    /**
+    Used internally to parse an {@link spi::ErrorHandler ErrorHandler } element.
+    */
+    void parseErrorHandler(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* element,
+        AppenderPtr& appender,
+        apr_xml_doc* doc,
+        AppenderMap& appenders);
 
-		/**
-		 Used internally to parse a filter element.
-		*/
-		void parseFilters(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* element,
-			std::vector<log4cxx::spi::FilterPtr>& filters);
+    /**
+     Used internally to parse a filter element.
+    */
+    void parseFilters(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* element,
+        std::vector<log4cxx::spi::FilterPtr>& filters);
 
-		/**
-		Used internally to parse a logger element.
-		*/
-		void parseLogger(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* loggerElement,
-			apr_xml_doc* doc,
-			AppenderMap& appenders);
+    /**
+    Used internally to parse a logger element.
+    */
+    void parseLogger(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* loggerElement,
+        apr_xml_doc* doc,
+        AppenderMap& appenders);
 
-		/**
-		 Used internally to parse the logger factory element.
-		*/
-		void parseLoggerFactory(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* factoryElement);
+    /**
+     Used internally to parse the logger factory element.
+    */
+    void parseLoggerFactory(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* factoryElement);
 
-		/**
-		 Used internally to parse the logger factory element.
-		*/
-		log4cxx::helpers::ObjectPtr parseTriggeringPolicy(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* factoryElement);
+    /**
+     Used internally to parse the logger factory element.
+    */
+    log4cxx::helpers::ObjectPtr parseTriggeringPolicy(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* factoryElement);
 
-		/**
-		 Used internally to parse the logger factory element.
-		*/
-		log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* factoryElement);
+    /**
+     Used internally to parse the logger factory element.
+    */
+    log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* factoryElement);
 
-		/**
-		 Used internally to parse the root logger element.
-		*/
-		void parseRoot(log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
+    /**
+     Used internally to parse the root logger element.
+    */
+    void parseRoot(log4cxx::helpers::Pool& p,
+                   log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+                   apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
 
-		/**
-		 Used internally to parse the children of a logger element.
-		*/
-		void parseChildrenOfLoggerElement(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* catElement,
-			LoggerPtr logger, bool isRoot,
-			apr_xml_doc* doc,
-			AppenderMap& appenders);
+    /**
+     Used internally to parse the children of a logger element.
+    */
+    void parseChildrenOfLoggerElement(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* catElement,
+        LoggerPtr logger, bool isRoot,
+        apr_xml_doc* doc,
+		AppenderMap& appenders );
 
-		/**
-		 Used internally to parse a layout element.
-		*/
-		LayoutPtr parseLayout(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* layout_element);
+    /**
+     Used internally to parse a layout element.
+    */
+    LayoutPtr parseLayout(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* layout_element);
 
-		/**
-		 Used internally to parse a level  element.
-		*/
-		void parseLevel(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* element,
-			LoggerPtr logger, bool isRoot);
+    /**
+     Used internally to parse a level  element.
+    */
+    void parseLevel(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* element,
+        LoggerPtr logger, bool isRoot);
 
-		void setParameter(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* elem,
-			log4cxx::config::PropertySetter& propSetter);
+    void setParameter(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* elem,
+        log4cxx::config::PropertySetter& propSetter);
 
-		/**
-		 Used internally to configure the log4cxx framework from
-		 an in-memory representation of an XML document.
-		*/
-		void parse(
-			log4cxx::helpers::Pool& p,
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem* element,
-			apr_xml_doc* doc,
-			AppenderMap& appenders);
+    /**
+     Used internally to configure the log4cxx framework from
+     an in-memory representation of an XML document.
+    */
+    void parse(
+        log4cxx::helpers::Pool& p,
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem* element,
+        apr_xml_doc* doc,
+        AppenderMap& appenders);
 
-	public:
-		DOMConfigurator();
+public:
+    DOMConfigurator();
 
-		DECLARE_LOG4CXX_OBJECT(DOMConfigurator)
-		BEGIN_LOG4CXX_CAST_MAP()
-		LOG4CXX_CAST_ENTRY(spi::Configurator)
-		END_LOG4CXX_CAST_MAP()
+    DECLARE_LOG4CXX_OBJECT(DOMConfigurator)
+    BEGIN_LOG4CXX_CAST_MAP()
+    LOG4CXX_CAST_ENTRY(spi::Configurator)
+    END_LOG4CXX_CAST_MAP()
 
-		DOMConfigurator(log4cxx::helpers::Pool& p);
+    DOMConfigurator(log4cxx::helpers::Pool& p);
 
-		void addRef() const;
-		void releaseRef() const;
+    void addRef() const;
+    void releaseRef() const;
 
-		/**
-		A static version of #doConfigure.
-		*/
-		static void configure(const std::string& filename);
+    /**
+    A static version of #doConfigure.
+    */
+    static void configure(const std::string& filename);
 #if LOG4CXX_WCHAR_T_API
-		static void configure(const std::wstring& filename);
+    static void configure(const std::wstring& filename);
 #endif
 #if LOG4CXX_UNICHAR_API
-		static void configure(const std::basic_string<UniChar>& filename);
+    static void configure(const std::basic_string<UniChar>& filename);
 #endif
 #if LOG4CXX_CFSTRING_API
-		static void configure(const CFStringRef& filename);
+    static void configure(const CFStringRef& filename);
 #endif
-		/**
-		Like #configureAndWatch(const std::string& configFilename, long delay)
-		except that the default delay as defined by
-		log4cxx::helpers::FileWatchdog#DEFAULT_DELAY is used.
-		@param configFilename A log4j configuration file in XML format.
-		*/
-		static void configureAndWatch(const std::string& configFilename);
+    /**
+    Like #configureAndWatch(const std::string& configFilename, long delay)
+    except that the default delay as defined by
+    log4cxx::helpers::FileWatchdog#DEFAULT_DELAY is used.
+    @param configFilename A log4j configuration file in XML format.
+    */
+    static void configureAndWatch(const std::string& configFilename);
 #if LOG4CXX_WCHAR_T_API
-		static void configureAndWatch(const std::wstring& configFilename);
+    static void configureAndWatch(const std::wstring& configFilename);
 #endif
 #if LOG4CXX_UNICHAR_API
-		static void configureAndWatch(const std::basic_string<UniChar>& configFilename);
+    static void configureAndWatch(const std::basic_string<UniChar>& configFilename);
 #endif
 #if LOG4CXX_CFSTRING_API
-		static void configureAndWatch(const CFStringRef& configFilename);
+    static void configureAndWatch(const CFStringRef& configFilename);
 #endif
-		/**
-		Read the configuration file <code>configFilename</code> if it
-		exists. Moreover, a thread will be created that will periodically
-		check if <code>configFilename</code> has been created or
-		modified. The period is determined by the <code>delay</code>
-		argument. If a change or file creation is detected, then
-		<code>configFilename</code> is read to configure log4cxx.
+    /**
+    Read the configuration file <code>configFilename</code> if it
+    exists. Moreover, a thread will be created that will periodically
+    check if <code>configFilename</code> has been created or
+    modified. The period is determined by the <code>delay</code>
+    argument. If a change or file creation is detected, then
+    <code>configFilename</code> is read to configure log4cxx.
 
-		@param configFilename A log4j configuration file in XML format.
-		@param delay The delay in milliseconds to wait between each check.
-		*/
-		static void configureAndWatch(const std::string& configFilename,
-			long delay);
+    @param configFilename A log4j configuration file in XML format.
+    @param delay The delay in milliseconds to wait between each check.
+    */
+    static void configureAndWatch(const std::string& configFilename,
+                                  long delay);
 #if LOG4CXX_WCHAR_T_API
-		static void configureAndWatch(const std::wstring& configFilename,
-			long delay);
+    static void configureAndWatch(const std::wstring& configFilename,
+                                  long delay);
 #endif
 #if LOG4CXX_UNICHAR_API
-		static void configureAndWatch(const std::basic_string<UniChar>& configFilename,
-			long delay);
+    static void configureAndWatch(const std::basic_string<UniChar>& configFilename,
+                                  long delay);
 #endif
 #if LOG4CXX_CFSTRING_API
-		static void configureAndWatch(const CFStringRef& configFilename,
-			long delay);
+    static void configureAndWatch(const CFStringRef& configFilename,
+                                  long delay);
 #endif
 
-		/**
-		Interpret the XML file pointed by <code>filename</code> and set up
-		log4cxx accordingly.
-		<p>The configuration is done relative to the hierarchy parameter.
-		@param filename The file to parse.
-		@param repository The hierarchy to operation upon.
-		*/
-		void doConfigure(const File& filename,
-			spi::LoggerRepositoryPtr& repository);
+    /**
+    Interpret the XML file pointed by <code>filename</code> and set up
+    log4cxx accordingly.
+    <p>The configuration is done relative to the hierarchy parameter.
+    @param filename The file to parse.
+    @param repository The hierarchy to operation upon.
+    */
+    void doConfigure(const File& filename,
+                     spi::LoggerRepositoryPtr repository);
 
-	protected:
-		static LogString getAttribute(
-			log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
-			apr_xml_elem*,
-			const std::string& attrName);
+protected:
+    static LogString getAttribute(
+        log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+        apr_xml_elem*,
+        const std::string& attrName);
 
-		LogString subst(const LogString& value);
+    LogString subst(const LogString& value);
 
-	protected:
-		helpers::Properties props;
-		spi::LoggerRepositoryPtr repository;
-		spi::LoggerFactoryPtr loggerFactory;
+protected:
+    helpers::Properties props;
+    spi::LoggerRepositoryPtr repository;
+    spi::LoggerFactoryPtr loggerFactory;
 
-	private:
-		//   prevent assignment or copy statements
-		DOMConfigurator(const DOMConfigurator&);
-		DOMConfigurator& operator=(const DOMConfigurator&);
-		static XMLWatchdog* xdog;
+private:
+    //   prevent assignment or copy statements
+    DOMConfigurator(const DOMConfigurator&);
+    DOMConfigurator& operator=(const DOMConfigurator&);
+    static XMLWatchdog* xdog;
 };
 LOG4CXX_PTR_DEF(DOMConfigurator);
 }  // namespace xml
 } // namespace log4cxx
 
 #if defined(_MSC_VER)
-	#pragma warning (pop)
+#pragma warning (pop)
 #endif
 
 #endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H
diff --git a/src/main/resources/log4cxx.rc b/src/main/resources/log4cxx.rc
index 3faf8b0..212a877 100644
--- a/src/main/resources/log4cxx.rc
+++ b/src/main/resources/log4cxx.rc
@@ -1,126 +1,126 @@
-//

-// Licensed to the Apache Software Foundation (ASF) under one

-// or more contributor license agreements.  See the NOTICE file

-// distributed with this work for additional information

-// regarding copyright ownership.  The ASF licenses this file

-// to you under the Apache License, Version 2.0 (the

-// "License"); you may not use this file except in compliance

-// with the License.  You may obtain a copy of the License at

-//

-// http://www.apache.org/licenses/LICENSE-2.0

-//

-// Unless required by applicable law or agreed to in writing,

-// software distributed under the License is distributed on an

-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

-// KIND, either express or implied.  See the License for the

-// specific language governing permissions and limitations

-// under the License.

-//

-//

-//   Message file include

-//

-LANGUAGE 0x9,0x1

-1 11 MSG00001.bin

-// Microsoft Visual C++ generated resource script.

-//

-#include "windows.h"

-

-#define APSTUDIO_READONLY_SYMBOLS

-/////////////////////////////////////////////////////////////////////////////

-//

-// Generated from the TEXTINCLUDE 2 resource.

-//

-//#include "afxres.h"

-

-/////////////////////////////////////////////////////////////////////////////

-#undef APSTUDIO_READONLY_SYMBOLS

-

-/////////////////////////////////////////////////////////////////////////////

-// English (U.S.) resources

-

-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)

-#ifdef _WIN32

-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

-#pragma code_page(1252)

-#endif //_WIN32

-

-#ifdef APSTUDIO_INVOKED

-/////////////////////////////////////////////////////////////////////////////

-//

-// TEXTINCLUDE

-//

-

-1 TEXTINCLUDE

-BEGIN

-    "resource.h\0"

-END

-

-2 TEXTINCLUDE

-BEGIN

-    "#include ""afxres.h""\r\n"

-    "\0"

-END

-

-3 TEXTINCLUDE

-BEGIN

-    "\r\n"

-    "\0"

-END

-

-#endif    // APSTUDIO_INVOKED

-

-

-/////////////////////////////////////////////////////////////////////////////

-//

-// Version

-//

-#include <log4cxx/version_info.h>

-

-VS_VERSION_INFO VERSIONINFO

- FILEVERSION INFO_FILE_VERSION_LIST

- PRODUCTVERSION INFO_PRODUCT_VERSION_LIST

- FILEFLAGSMASK 0x17L

-#ifdef _DEBUG

- FILEFLAGS 0x1L

-#else

- FILEFLAGS 0x0L

-#endif

- FILEOS 0x4L

- FILETYPE 0x2L

- FILESUBTYPE 0x0L

-BEGIN

-    BLOCK "StringFileInfo"

-    BEGIN

-        BLOCK "040904b0"

-        BEGIN

-            VALUE "CompanyName", "Apache Software Foundation"

-            VALUE "FileDescription", "Apache log4cxx"

-            VALUE "FileVersion", INFO_FILE_VERSION_STRING

-            VALUE "InternalName", "log4cxx"

-            VALUE "LegalCopyright",  "Licensed to the Apache Software Foundation (ASF) under one or more\ncontributor license agreements.  See the NOTICE file distributed with\nthis work for additional information regarding copyright ownership.\nThe ASF licenses this file to You under the Apache License, Version 2.0\n(the ""License""); you may not use this file except in compliance with\nthe License.  You may obtain a copy of the License at\n\n     http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an ""AS IS"" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."

-            VALUE "OriginalFilename", "log4cxx.dll"

-            VALUE "ProductName", "Apache log4cxx"

-            VALUE "ProductVersion", INFO_PRODUCT_VERSION_STRING

-        END

-    END

-    BLOCK "VarFileInfo"

-    BEGIN

-        VALUE "Translation", 0x409, 1200

-    END

-END

-

-#endif    // English (U.S.) resources

-/////////////////////////////////////////////////////////////////////////////

-

-

-

-#ifndef APSTUDIO_INVOKED

-/////////////////////////////////////////////////////////////////////////////

-//

-// Generated from the TEXTINCLUDE 3 resource.

-//

-

-

-/////////////////////////////////////////////////////////////////////////////

-#endif    // not APSTUDIO_INVOKED

-

+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+//
+//   Message file include
+//
+LANGUAGE 0x9,0x1
+1 11 MSG00001.bin
+// Microsoft Visual C++ generated resource script.
+//
+#include "windows.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+#include <log4cxx/version_info.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION INFO_FILE_VERSION_LIST
+ PRODUCTVERSION INFO_PRODUCT_VERSION_LIST
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName", "Apache Software Foundation"
+            VALUE "FileDescription", "Apache log4cxx"
+            VALUE "FileVersion", INFO_FILE_VERSION_STRING
+            VALUE "InternalName", "log4cxx"
+            VALUE "LegalCopyright",  "Licensed to the Apache Software Foundation (ASF) under one or more\ncontributor license agreements.  See the NOTICE file distributed with\nthis work for additional information regarding copyright ownership.\nThe ASF licenses this file to You under the Apache License, Version 2.0\n(the ""License""); you may not use this file except in compliance with\nthe License.  You may obtain a copy of the License at\n\n     http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an ""AS IS"" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+            VALUE "OriginalFilename", "log4cxx.dll"
+            VALUE "ProductName", "Apache log4cxx"
+            VALUE "ProductVersion", INFO_PRODUCT_VERSION_STRING
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt
index 386af20..ccffcbc 100644
--- a/src/test/cpp/CMakeLists.txt
+++ b/src/test/cpp/CMakeLists.txt
@@ -88,7 +88,7 @@
 foreach(testName IN LISTS ALL_LOG4CXX_TESTS)
     target_compile_definitions(${testName} PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} )
     target_include_directories(${testName} PRIVATE ${CMAKE_CURRENT_LIST_DIR} $<TARGET_PROPERTY:log4cxx,INCLUDE_DIRECTORIES>)
-    target_link_libraries(${testName} PRIVATE testingFramework testingUtilities log4cxx ${APR_LIBRARIES} ${APR_SYSTEM_LIBS})
+    target_link_libraries(${testName} PRIVATE testingFramework testingUtilities log4cxx ${APR_LIBRARIES} ${APR_SYSTEM_LIBS} Threads::Threads)
     add_test(NAME ${testName}
         COMMAND ${testName} -v
         WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../resources
diff --git a/src/test/cpp/appenderskeletontestcase.cpp b/src/test/cpp/appenderskeletontestcase.cpp
index 631d633..72069df 100644
--- a/src/test/cpp/appenderskeletontestcase.cpp
+++ b/src/test/cpp/appenderskeletontestcase.cpp
@@ -17,7 +17,7 @@
 
 #include "appenderskeletontestcase.h"
 #include "logunit.h"
-#include <log4cxx/helpers/objectptr.h>
+#include <log4cxx/helpers/object.h>
 #include <log4cxx/appenderskeleton.h>
 
 
@@ -27,14 +27,14 @@
 
 void AppenderSkeletonTestCase::testDefaultThreshold()
 {
-	ObjectPtrT<AppenderSkeleton> appender(createAppenderSkeleton());
+    std::shared_ptr<AppenderSkeleton> appender(createAppenderSkeleton());
 	LevelPtr threshold(appender->getThreshold());
 	LOGUNIT_ASSERT_EQUAL(Level::getAll()->toInt(), threshold->toInt());
 }
 
 void AppenderSkeletonTestCase::testSetOptionThreshold()
 {
-	ObjectPtrT<AppenderSkeleton> appender(createAppenderSkeleton());
+    std::shared_ptr<AppenderSkeleton> appender(createAppenderSkeleton());
 	appender->setOption(LOG4CXX_STR("threshold"), LOG4CXX_STR("debug"));
 	LevelPtr threshold(appender->getThreshold());
 	LOGUNIT_ASSERT_EQUAL(Level::getDebug()->toInt(), threshold->toInt());
diff --git a/src/test/cpp/asyncappendertestcase.cpp b/src/test/cpp/asyncappendertestcase.cpp
index 0e6795a..7130e56 100644
--- a/src/test/cpp/asyncappendertestcase.cpp
+++ b/src/test/cpp/asyncappendertestcase.cpp
@@ -27,7 +27,6 @@
 #include <apr_strings.h>
 #include "testchar.h"
 #include <log4cxx/helpers/stringhelper.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/spi/location/locationinfo.h>
 #include <log4cxx/xml/domconfigurator.h>
 #include <log4cxx/file.h>
@@ -68,12 +67,12 @@
 class BlockableVectorAppender : public VectorAppender
 {
 	private:
-		Mutex blocker;
+		log4cxx::mutex blocker;
 	public:
 		/**
 		 * Create new instance.
 		 */
-		BlockableVectorAppender() : blocker(pool)
+        BlockableVectorAppender()
 		{
 		}
 
@@ -82,7 +81,7 @@
 		 */
 		void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p)
 		{
-			synchronized sync(blocker);
+			log4cxx::unique_lock<log4cxx::mutex> lock( blocker );
 			VectorAppender::append(event, p);
 
 			//
@@ -98,14 +97,14 @@
 			}
 		}
 
-		Mutex& getBlocker()
+		log4cxx::mutex& getBlocker()
 		{
 			return blocker;
 		}
 
 };
 
-typedef helpers::ObjectPtrT<BlockableVectorAppender> BlockableVectorAppenderPtr;
+LOG4CXX_PTR_DEF(BlockableVectorAppender);
 
 #if APR_HAS_THREADS
 /**
@@ -117,17 +116,17 @@
 		//
 		// tests inherited from AppenderSkeletonTestCase
 		//
-		LOGUNIT_TEST(testDefaultThreshold);
-		LOGUNIT_TEST(testSetOptionThreshold);
+        LOGUNIT_TEST(testDefaultThreshold);
+        LOGUNIT_TEST(testSetOptionThreshold);
 
-		LOGUNIT_TEST(closeTest);
-		LOGUNIT_TEST(test2);
-		LOGUNIT_TEST(test3);
+        LOGUNIT_TEST(closeTest);
+        LOGUNIT_TEST(test2);
+        LOGUNIT_TEST(test3);
 		//
 		// TODO: test fails on Linux.
 		//LOGUNIT_TEST(testBadAppender);
-		LOGUNIT_TEST(testLocationInfoTrue);
-		LOGUNIT_TEST(testConfiguration);
+        LOGUNIT_TEST(testLocationInfoTrue);
+        LOGUNIT_TEST(testConfiguration);
 		LOGUNIT_TEST_SUITE_END();
 
 
@@ -152,9 +151,9 @@
 		void closeTest()
 		{
 			LoggerPtr root = Logger::getRootLogger();
-			LayoutPtr layout = new SimpleLayout();
-			VectorAppenderPtr vectorAppender = new VectorAppender();
-			AsyncAppenderPtr asyncAppender = new AsyncAppender();
+            LayoutPtr layout = LayoutPtr(new SimpleLayout());
+            VectorAppenderPtr vectorAppender = VectorAppenderPtr(new VectorAppender());
+            AsyncAppenderPtr asyncAppender = AsyncAppenderPtr(new AsyncAppender());
 			asyncAppender->setName(LOG4CXX_STR("async-CloseTest"));
 			asyncAppender->addAppender(vectorAppender);
 			root->addAppender(asyncAppender);
@@ -172,9 +171,9 @@
 		void test2()
 		{
 			LoggerPtr root = Logger::getRootLogger();
-			LayoutPtr layout = new SimpleLayout();
-			VectorAppenderPtr vectorAppender = new VectorAppender();
-			AsyncAppenderPtr asyncAppender = new AsyncAppender();
+            LayoutPtr layout = SimpleLayoutPtr(new SimpleLayout());
+            VectorAppenderPtr vectorAppender = VectorAppenderPtr(new VectorAppender());
+            AsyncAppenderPtr asyncAppender = AsyncAppenderPtr(new AsyncAppender());
 			asyncAppender->setName(LOG4CXX_STR("async-test2"));
 			asyncAppender->addAppender(vectorAppender);
 			root->addAppender(asyncAppender);
@@ -194,8 +193,8 @@
 		{
 			size_t LEN = 200;
 			LoggerPtr root = Logger::getRootLogger();
-			VectorAppenderPtr vectorAppender = new VectorAppender();
-			AsyncAppenderPtr asyncAppender = new AsyncAppender();
+            VectorAppenderPtr vectorAppender = VectorAppenderPtr(new VectorAppender());
+            AsyncAppenderPtr asyncAppender = AsyncAppenderPtr(new AsyncAppender());
 			asyncAppender->setName(LOG4CXX_STR("async-test3"));
 			asyncAppender->addAppender(vectorAppender);
 			root->addAppender(asyncAppender);
@@ -218,16 +217,16 @@
 		 */
 		void testBadAppender()
 		{
-			AppenderPtr nullPointerAppender = new NullPointerAppender();
-			AsyncAppenderPtr asyncAppender = new AsyncAppender();
+            AppenderPtr nullPointerAppender = AppenderPtr(new NullPointerAppender());
+            AsyncAppenderPtr asyncAppender = AsyncAppenderPtr(new AsyncAppender());
 			asyncAppender->addAppender(nullPointerAppender);
 			asyncAppender->setBufferSize(5);
 			Pool p;
 			asyncAppender->activateOptions(p);
 			LoggerPtr root = Logger::getRootLogger();
 			root->addAppender(asyncAppender);
-			LOG4CXX_INFO(root, "Message");
-			Thread::sleep(10);
+            LOG4CXX_INFO(root, "Message");
+            std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
 
 			try
 			{
@@ -244,8 +243,8 @@
 		 */
 		void testLocationInfoTrue()
 		{
-			BlockableVectorAppenderPtr blockableAppender = new BlockableVectorAppender();
-			AsyncAppenderPtr async = new AsyncAppender();
+            BlockableVectorAppenderPtr blockableAppender = BlockableVectorAppenderPtr(new BlockableVectorAppender());
+            AsyncAppenderPtr async = AsyncAppenderPtr(new AsyncAppender());
 			async->addAppender(blockableAppender);
 			async->setBufferSize(5);
 			async->setLocationInfo(true);
@@ -255,12 +254,12 @@
 			LoggerPtr rootLogger = Logger::getRootLogger();
 			rootLogger->addAppender(async);
 			{
-				synchronized sync(blockableAppender->getBlocker());
+				log4cxx::unique_lock<log4cxx::mutex> sync(blockableAppender->getBlocker());
 
 				for (int i = 0; i < 140; i++)
 				{
 					LOG4CXX_INFO(rootLogger, "Hello, World");
-					Thread::sleep(1);
+                    std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );
 				}
 
 				LOG4CXX_ERROR(rootLogger, "That's all folks.");
@@ -279,7 +278,7 @@
 		void testConfiguration()
 		{
 			log4cxx::xml::DOMConfigurator::configure("input/xml/asyncAppender1.xml");
-			AsyncAppenderPtr asyncAppender(Logger::getRootLogger()->getAppender(LOG4CXX_STR("ASYNC")));
+            AsyncAppenderPtr asyncAppender = log4cxx::cast<AsyncAppender>(Logger::getRootLogger()->getAppender(LOG4CXX_STR("ASYNC")));
 			LOGUNIT_ASSERT(!(asyncAppender == 0));
 			LOGUNIT_ASSERT_EQUAL(100, asyncAppender->getBufferSize());
 			LOGUNIT_ASSERT_EQUAL(false, asyncAppender->getBlocking());
diff --git a/src/test/cpp/customlogger/xlogger.cpp b/src/test/cpp/customlogger/xlogger.cpp
index 84722b8..c09ad6c 100644
--- a/src/test/cpp/customlogger/xlogger.cpp
+++ b/src/test/cpp/customlogger/xlogger.cpp
@@ -28,7 +28,7 @@
 IMPLEMENT_LOG4CXX_OBJECT(XLogger)
 IMPLEMENT_LOG4CXX_OBJECT(XFactory)
 
-XFactoryPtr XLogger::factory = new XFactory();
+XFactoryPtr XLogger::factory = XFactoryPtr(new XFactory());
 
 void XLogger::lethal(const LogString& message, const LocationInfo& locationInfo)
 {
@@ -99,5 +99,5 @@
 LoggerPtr XFactory::makeNewLoggerInstance(log4cxx::helpers::Pool& pool,
 	const LogString& name) const
 {
-	return new XLogger(pool, name);
+    return LoggerPtr(new XLogger(pool, name));
 }
diff --git a/src/test/cpp/customlogger/xlogger.h b/src/test/cpp/customlogger/xlogger.h
index 896e0bc..84ad36f 100644
--- a/src/test/cpp/customlogger/xlogger.h
+++ b/src/test/cpp/customlogger/xlogger.h
@@ -33,7 +33,7 @@
 // LoggerFactory.
 class XFactory :
 	public virtual spi::LoggerFactory,
-	public virtual helpers::ObjectImpl
+    public virtual helpers::Object
 {
 	public:
 		DECLARE_ABSTRACT_LOG4CXX_OBJECT(XFactory)
@@ -48,7 +48,7 @@
 			const LogString& name) const;
 };
 
-typedef helpers::ObjectPtrT<XFactory> XFactoryPtr;
+typedef std::shared_ptr<XFactory> XFactoryPtr;
 
 /**
 A simple example showing Logger sub-classing. It shows the
@@ -116,6 +116,6 @@
 		void trace(const LogString& message);
 };
 
-typedef helpers::ObjectPtrT<XLogger> XLoggerPtr;
+typedef std::shared_ptr<XLogger> XLoggerPtr;
 }
 
diff --git a/src/test/cpp/customlogger/xloggertestcase.cpp b/src/test/cpp/customlogger/xloggertestcase.cpp
index 500820d..3c0f216 100644
--- a/src/test/cpp/customlogger/xloggertestcase.cpp
+++ b/src/test/cpp/customlogger/xloggertestcase.cpp
@@ -41,7 +41,7 @@
 	LOGUNIT_TEST(test2);
 	LOGUNIT_TEST_SUITE_END();
 
-	XLoggerPtr logger;
+    LoggerPtr logger;
 
 public:
 	void setUp()
diff --git a/src/test/cpp/fileappendertest.cpp b/src/test/cpp/fileappendertest.cpp
index 30b99bf..c122dad 100644
--- a/src/test/cpp/fileappendertest.cpp
+++ b/src/test/cpp/fileappendertest.cpp
@@ -51,7 +51,7 @@
 
 		FileAppenderPtr wa(new FileAppender());
 		wa->setFile(LOG4CXX_STR("output/newdir/temp.log"));
-		wa->setLayout(new PatternLayout(LOG4CXX_STR("%m%n")));
+        wa->setLayout(PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m%n"))));
 		wa->activateOptions(p);
 
 		LOGUNIT_ASSERT(File(LOG4CXX_STR("output/newdir/temp.log")).exists(p));
@@ -62,7 +62,7 @@
 	 */
 	void testgetSetThreshold()
 	{
-		FileAppenderPtr appender = new FileAppender();
+        FileAppenderPtr appender = FileAppenderPtr(new FileAppender());
 		LevelPtr debug = Level::getDebug();
 		//
 		//  different from log4j where threshold is null.
@@ -77,7 +77,7 @@
 	 */
 	void testIsAsSevereAsThreshold()
 	{
-		FileAppenderPtr appender = new FileAppender();
+        FileAppenderPtr appender = FileAppenderPtr(new FileAppender());
 		LevelPtr debug = Level::getDebug();
 		LOGUNIT_ASSERT(appender->isAsSevereAsThreshold(debug));
 	}
diff --git a/src/test/cpp/fileappendertestcase.cpp b/src/test/cpp/fileappendertestcase.cpp
index 1e469db..61910e6 100644
--- a/src/test/cpp/fileappendertestcase.cpp
+++ b/src/test/cpp/fileappendertestcase.cpp
@@ -16,7 +16,6 @@
  */
 
 #include "fileappendertestcase.h"
-#include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/fileappender.h>
 #include "insertwide.h"
 
diff --git a/src/test/cpp/filetestcase.cpp b/src/test/cpp/filetestcase.cpp
index 70009a9..243e826 100644
--- a/src/test/cpp/filetestcase.cpp
+++ b/src/test/cpp/filetestcase.cpp
@@ -85,8 +85,8 @@
 
 		try
 		{
-			InputStreamPtr defInput = new FileInputStream(defFile);
-			InputStreamReaderPtr inputReader = new InputStreamReader(defInput);
+            InputStreamPtr defInput = FileInputStreamPtr(new FileInputStream(defFile));
+            InputStreamReaderPtr inputReader = InputStreamReaderPtr(new InputStreamReader(defInput));
 			LogString contents(inputReader->read(pool));
 			LOGUNIT_ASSERT(false);
 		}
@@ -152,8 +152,8 @@
 	{
 		File propFile("input/patternLayout1.properties");
 		Pool pool;
-		InputStreamPtr propStream = new FileInputStream(propFile);
-		InputStreamReaderPtr propReader = new InputStreamReader(propStream);
+        InputStreamPtr propStream = FileInputStreamPtr(new FileInputStream(propFile));
+        InputStreamReaderPtr propReader = InputStreamReaderPtr(new InputStreamReader(propStream));
 		LogString props(propReader->read(pool));
 		LogString line1(LOG4CXX_STR("# Licensed to the Apache Software Foundation (ASF) under one or more"));
 		LOGUNIT_ASSERT_EQUAL(line1, props.substr(0, line1.length()));
@@ -169,18 +169,18 @@
 
 	void fileWrite1()
 	{
-		OutputStreamPtr fos =
-			new FileOutputStream(LOG4CXX_STR("output/fileWrite1.txt"));
-		OutputStreamWriterPtr osw = new OutputStreamWriter(fos);
+        OutputStreamPtr fos = FileOutputStreamPtr(
+            new FileOutputStream(LOG4CXX_STR("output/fileWrite1.txt")));
+        OutputStreamWriterPtr osw = OutputStreamWriterPtr(new OutputStreamWriter(fos));
 
 		Pool pool;
 		LogString greeting(LOG4CXX_STR("Hello, World"));
 		greeting.append(LOG4CXX_EOL);
 		osw->write(greeting, pool);
 
-		InputStreamPtr is =
-			new FileInputStream(LOG4CXX_STR("output/fileWrite1.txt"));
-		InputStreamReaderPtr isr = new InputStreamReader(is);
+        InputStreamPtr is = FileInputStreamPtr(
+            new FileInputStream(LOG4CXX_STR("output/fileWrite1.txt")));
+        InputStreamReaderPtr isr = InputStreamReaderPtr(new InputStreamReader(is));
 		LogString reply = isr->read(pool);
 
 		LOGUNIT_ASSERT_EQUAL(greeting, reply);
diff --git a/src/test/cpp/helpers/CMakeLists.txt b/src/test/cpp/helpers/CMakeLists.txt
index 78aa1b1..c40681c 100644
--- a/src/test/cpp/helpers/CMakeLists.txt
+++ b/src/test/cpp/helpers/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(HELPER_TESTS 
     absolutetimedateformattestcase
     cacheddateformattestcase
+    casttestcase
     charsetdecodertestcase
     charsetencodertestcase
     cyclicbuffertestcase
@@ -15,7 +16,6 @@
     stringhelpertestcase
     stringtokenizertestcase
     syslogwritertest
-    threadtestcase
     timezonetestcase
     transcodertestcase
 )
diff --git a/src/test/cpp/helpers/cacheddateformattestcase.cpp b/src/test/cpp/helpers/cacheddateformattestcase.cpp
index d29ff51..7c0d32c 100644
--- a/src/test/cpp/helpers/cacheddateformattestcase.cpp
+++ b/src/test/cpp/helpers/cacheddateformattestcase.cpp
@@ -310,9 +310,9 @@
 	{
 		std::locale localeUS(LOCALE_US);
 
-		DateFormatPtr baseFormat = new SimpleDateFormat(
-			LOG4CXX_STR("yyyy-MMMM-dd HH:mm:ss,SS Z"), &localeUS);
-		DateFormatPtr cachedFormat = new CachedDateFormat(baseFormat, 1000000);
+        DateFormatPtr baseFormat = DateFormatPtr(new SimpleDateFormat(
+            LOG4CXX_STR("yyyy-MMMM-dd HH:mm:ss,SS Z"), &localeUS));
+        DateFormatPtr cachedFormat = DateFormatPtr(new CachedDateFormat(baseFormat, 1000000));
 		TimeZonePtr cet = TimeZone::getTimeZone(LOG4CXX_STR("GMT+1"));
 		cachedFormat->setTimeZone(cet);
 
@@ -370,9 +370,9 @@
 #else
 		std::locale* localeUS = NULL;
 #endif
-		DateFormatPtr baseFormat = new SimpleDateFormat(
-			LOG4CXX_STR("MMMM SSS EEEEEE"), localeUS);
-		DateFormatPtr cachedFormat = new CachedDateFormat(baseFormat, 1000000);
+        DateFormatPtr baseFormat = DateFormatPtr(new SimpleDateFormat(
+            LOG4CXX_STR("MMMM SSS EEEEEE"), localeUS));
+        DateFormatPtr cachedFormat = DateFormatPtr(new CachedDateFormat(baseFormat, 1000000));
 		TimeZonePtr cet = TimeZone::getTimeZone(LOG4CXX_STR("GMT+1"));
 		cachedFormat->setTimeZone(cet);
 
@@ -432,8 +432,8 @@
 		//   Earlier versions could be tricked by "SS0" patterns.
 		//
 		LogString badPattern(LOG4CXX_STR("ss,SS0"));
-		DateFormatPtr simpleFormat = new SimpleDateFormat(badPattern);
-		DateFormatPtr gmtFormat = new CachedDateFormat(simpleFormat, 1000000);
+        DateFormatPtr simpleFormat = DateFormatPtr(new SimpleDateFormat(badPattern));
+        DateFormatPtr gmtFormat = DateFormatPtr(new CachedDateFormat(simpleFormat, 1000000));
 		gmtFormat->setTimeZone(TimeZone::getGMT());
 
 		//
@@ -464,7 +464,7 @@
 	 */
 	void test12()
 	{
-		DateFormatPtr df    = new SimpleDateFormat(LOG4CXX_STR("yyyy-MM-dd HH:mm:ss,SSS"));
+        DateFormatPtr df    = DateFormatPtr(new SimpleDateFormat(LOG4CXX_STR("yyyy-MM-dd HH:mm:ss,SSS")));
 		apr_time_t    ticks = 11142L * MICROSECONDS_PER_DAY;
 		Pool p;
 		LogString formatted;
@@ -505,7 +505,7 @@
 	 */
 	void test13()
 	{
-		DateFormatPtr df = new SimpleDateFormat(LOG4CXX_STR("yyyy-MM-dd"));
+        DateFormatPtr df = DateFormatPtr(new SimpleDateFormat(LOG4CXX_STR("yyyy-MM-dd")));
 		apr_time_t ticks = 11142L * MICROSECONDS_PER_DAY;
 
 		Pool p;
@@ -523,7 +523,7 @@
 	 */
 	void test14()
 	{
-		DateFormatPtr df = new SimpleDateFormat(LOG4CXX_STR("HH:mm:ss,SSS"));
+        DateFormatPtr df = DateFormatPtr(new SimpleDateFormat(LOG4CXX_STR("HH:mm:ss,SSS")));
 		apr_time_t ticks = 11142L * MICROSECONDS_PER_DAY;
 
 		Pool p;
@@ -540,7 +540,7 @@
 	 */
 	void test15()
 	{
-		DateFormatPtr df = new SimpleDateFormat(LOG4CXX_STR("HH:mm:ss,S"));
+        DateFormatPtr df = DateFormatPtr(new SimpleDateFormat(LOG4CXX_STR("HH:mm:ss,S")));
 		apr_time_t ticks = 11142L * MICROSECONDS_PER_DAY;
 
 		Pool p;
@@ -557,7 +557,7 @@
 	 */
 	void test16()
 	{
-		DateFormatPtr df = new SimpleDateFormat(LOG4CXX_STR("HH:mm:ss,SS"));
+        DateFormatPtr df = DateFormatPtr(new SimpleDateFormat(LOG4CXX_STR("HH:mm:ss,SS")));
 		apr_time_t ticks = 11142L * MICROSECONDS_PER_DAY;
 
 		Pool p;
@@ -576,9 +576,9 @@
 	{
 		apr_time_t jul2 = 12602L * MICROSECONDS_PER_DAY;
 		LogString badPattern(LOG4CXX_STR("HH:mm:ss,SSS HH:mm:ss,SSS"));
-		DateFormatPtr simpleFormat = new SimpleDateFormat(badPattern);
+        DateFormatPtr simpleFormat = DateFormatPtr(new SimpleDateFormat(badPattern));
 		simpleFormat->setTimeZone(TimeZone::getGMT());
-		DateFormatPtr cachedFormat = new CachedDateFormat(simpleFormat, 1000000);
+        DateFormatPtr cachedFormat = DateFormatPtr(new CachedDateFormat(simpleFormat, 1000000));
 
 		Pool p;
 		LogString s;
diff --git a/src/test/cpp/helpers/casttestcase.cpp b/src/test/cpp/helpers/casttestcase.cpp
new file mode 100644
index 0000000..7f15974
--- /dev/null
+++ b/src/test/cpp/helpers/casttestcase.cpp
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../logunit.h"
+#include <log4cxx/helpers/bytearrayoutputstream.h>
+#include <log4cxx/helpers/fileoutputstream.h>
+#include <iostream>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+
+#define LOG4CXX_TEST 1
+#include <log4cxx/private/log4cxx_private.h>
+
+/**
+ */
+LOGUNIT_CLASS(CastTestCase)
+{
+    LOGUNIT_TEST_SUITE( CastTestCase );
+    LOGUNIT_TEST(testGoodCast);
+    LOGUNIT_TEST(testBadCast);
+
+    LOGUNIT_TEST_SUITE_END();
+
+public:
+
+    /**
+     *
+     */
+    void testGoodCast()
+    {
+        OutputStreamPtr out = OutputStreamPtr(new ByteArrayOutputStream());
+
+        ByteArrayOutputStreamPtr byteOut = log4cxx::cast<ByteArrayOutputStream>(out);
+
+        LOGUNIT_ASSERT(byteOut);
+    }
+
+    void testBadCast()
+    {
+        OutputStreamPtr out = OutputStreamPtr(new ByteArrayOutputStream());
+
+        FileOutputStreamPtr fos = log4cxx::cast<FileOutputStream>(out);
+
+        LOGUNIT_ASSERT(!fos);
+    }
+
+};
+
+LOGUNIT_TEST_SUITE_REGISTRATION(CastTestCase);
diff --git a/src/test/cpp/helpers/charsetencodertestcase.cpp b/src/test/cpp/helpers/charsetencodertestcase.cpp
index 5677820..214d210 100644
--- a/src/test/cpp/helpers/charsetencodertestcase.cpp
+++ b/src/test/cpp/helpers/charsetencodertestcase.cpp
@@ -19,13 +19,9 @@
 #include "../logunit.h"
 #include "../insertwide.h"
 #include <log4cxx/helpers/bytebuffer.h>
-#include <log4cxx/helpers/thread.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/condition.h>
-#include <log4cxx/helpers/synchronized.h>
 #include <apr.h>
 #include <apr_atomic.h>
-
+#include <condition_variable>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -186,20 +182,20 @@
 	{
 		public:
 			ThreadPackage(CharsetEncoderPtr& enc, int repetitions) :
-				p(), lock(p), condition(p), passCount(0), failCount(0), enc(enc), repetitions(repetitions)
+                p(), passCount(0), failCount(0), enc(enc), repetitions(repetitions)
 			{
 			}
 
 			void await()
 			{
-				synchronized sync(lock);
-				condition.await(lock);
+				log4cxx::unique_lock<log4cxx::mutex> sync(lock);
+                condition.wait(sync);
 			}
 
 			void signalAll()
 			{
-				synchronized sync(lock);
-				condition.signalAll();
+				log4cxx::unique_lock<log4cxx::mutex> sync(lock);
+                condition.notify_all();
 			}
 
 			void fail()
@@ -232,102 +228,99 @@
 				return enc;
 			}
 
+            void run()
+            {
+        #if LOG4CXX_LOGCHAR_IS_UTF8
+                const logchar greet[] = { 'H', 'e', 'l', 'l', 'o', ' ',
+                        (char) 0xC2, (char) 0xA2,  //  cent sign
+                        (char) 0xC2, (char) 0xA9,  //  copyright
+                        (char) 0xc3, (char) 0xb4,  //  latin small letter o with circumflex
+                        0
+                    };
+        #endif
+        #if LOG4CXX_LOGCHAR_IS_WCHAR || LOG4CXX_LOGCHAR_IS_UNICHAR
+                //   arbitrary, hopefully meaningless, characters from
+                //     Latin, Arabic, Armenian, Bengali, CJK and Cyrillic
+                const logchar greet[] = { L'H', L'e', L'l', L'l', L'o', L' ',
+                        0x00A2, 0x00A9, 0x00F4, 0
+                    };
+        #endif
+
+                const char expected[] =  { 'H', 'e', 'l', 'l', 'o', ' ',
+                        (char) 0x00A2, (char) 0x00A9, (char) 0x00F4
+                    };
+
+                LogString greeting(greet);
+
+                await();
+
+                for (int i = 0; i < getRepetitions(); i++)
+                {
+                    bool pass = true;
+                    char buf[BUFSIZE];
+                    ByteBuffer out(buf, BUFSIZE);
+                    LogString::const_iterator iter = greeting.begin();
+                    log4cxx_status_t stat = getEncoder()->encode(greeting, iter, out);
+                    pass = (false == CharsetEncoder::isError(stat));
+
+                    if (pass)
+                    {
+                        stat = getEncoder()->encode(greeting, iter, out);
+                        pass = (false == CharsetEncoder::isError(stat));
+
+                        if (pass)
+                        {
+                            out.flip();
+                            pass = (sizeof(expected) == out.limit());
+
+                            for (size_t i = 0; i < out.limit() && pass; i++)
+                            {
+                                pass = (expected[i] == out.data()[i]);
+                            }
+
+                            pass = pass && (iter == greeting.end());
+                        }
+                    }
+
+                    if (pass)
+                    {
+                        ThreadPackage::pass();
+                    }
+                    else
+                    {
+                        fail();
+                    }
+                }
+            }
+
 		private:
 			ThreadPackage(const ThreadPackage&);
 			ThreadPackage& operator=(ThreadPackage&);
 			Pool p;
-			Mutex lock;
-			Condition condition;
+			mutex lock;
+			condition_variable condition;
 			volatile apr_uint32_t passCount;
 			volatile apr_uint32_t failCount;
 			CharsetEncoderPtr enc;
 			int repetitions;
 	};
 
-	static void* LOG4CXX_THREAD_FUNC thread1Action(apr_thread_t* /* thread */, void* data)
-	{
-		ThreadPackage* package = (ThreadPackage*) data;
-#if LOG4CXX_LOGCHAR_IS_UTF8
-		const logchar greet[] = { 'H', 'e', 'l', 'l', 'o', ' ',
-				(char) 0xC2, (char) 0xA2,  //  cent sign
-				(char) 0xC2, (char) 0xA9,  //  copyright
-				(char) 0xc3, (char) 0xb4,  //  latin small letter o with circumflex
-				0
-			};
-#endif
-#if LOG4CXX_LOGCHAR_IS_WCHAR || LOG4CXX_LOGCHAR_IS_UNICHAR
-		//   arbitrary, hopefully meaningless, characters from
-		//     Latin, Arabic, Armenian, Bengali, CJK and Cyrillic
-		const logchar greet[] = { L'H', L'e', L'l', L'l', L'o', L' ',
-				0x00A2, 0x00A9, 0x00F4, 0
-			};
-#endif
-
-		const char expected[] =  { 'H', 'e', 'l', 'l', 'o', ' ',
-				(char) 0x00A2, (char) 0x00A9, (char) 0x00F4
-			};
-
-		LogString greeting(greet);
-
-		package->await();
-
-		for (int i = 0; i < package->getRepetitions(); i++)
-		{
-			bool pass = true;
-			char buf[BUFSIZE];
-			ByteBuffer out(buf, BUFSIZE);
-			LogString::const_iterator iter = greeting.begin();
-			log4cxx_status_t stat = package->getEncoder()->encode(greeting, iter, out);
-			pass = (false == CharsetEncoder::isError(stat));
-
-			if (pass)
-			{
-				stat = package->getEncoder()->encode(greeting, iter, out);
-				pass = (false == CharsetEncoder::isError(stat));
-
-				if (pass)
-				{
-					out.flip();
-					pass = (sizeof(expected) == out.limit());
-
-					for (size_t i = 0; i < out.limit() && pass; i++)
-					{
-						pass = (expected[i] == out.data()[i]);
-					}
-
-					pass = pass && (iter == greeting.end());
-				}
-			}
-
-			if (pass)
-			{
-				package->pass();
-			}
-			else
-			{
-				package->fail();
-			}
-		}
-
-		return 0;
-	}
-
 	void thread1()
 	{
 		enum { THREAD_COUNT = 10, THREAD_REPS = 10000 };
-		Thread threads[THREAD_COUNT];
+		log4cxx::thread threads[THREAD_COUNT];
 		CharsetEncoderPtr enc(CharsetEncoder::getEncoder(LOG4CXX_STR("ISO-8859-1")));
 		ThreadPackage* package = new ThreadPackage(enc, THREAD_REPS);
 		{
 			for (int i = 0; i < THREAD_COUNT; i++)
 			{
-				threads[i].run(thread1Action, package);
+				threads[i] = log4cxx::thread(&ThreadPackage::run, package);
 			}
 		}
 		//
 		//   give time for all threads to be launched so
-		//      we don't signal before everybody is waiting.
-		Thread::sleep(100);
+        //      we don't signal before everybody is waiting.
+        std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
 		package->signalAll();
 
 		for (int i = 0; i < THREAD_COUNT; i++)
diff --git a/src/test/cpp/helpers/cyclicbuffertestcase.cpp b/src/test/cpp/helpers/cyclicbuffertestcase.cpp
index c644d55..d2c8325 100644
--- a/src/test/cpp/helpers/cyclicbuffertestcase.cpp
+++ b/src/test/cpp/helpers/cyclicbuffertestcase.cpp
@@ -49,8 +49,8 @@
 
 		for (int i = 0; i < MAX; i++)
 		{
-			event = new LoggingEvent(LOG4CXX_STR("x"), Level::getDebug(), LOG4CXX_STR("e"),
-				log4cxx::spi::LocationInfo::getLocationUnavailable());
+            event = LoggingEventPtr(new LoggingEvent(LOG4CXX_STR("x"), Level::getDebug(), LOG4CXX_STR("e"),
+                log4cxx::spi::LocationInfo::getLocationUnavailable()));
 			e.push_back(event);
 		}
 	}
diff --git a/src/test/cpp/helpers/propertiestestcase.cpp b/src/test/cpp/helpers/propertiestestcase.cpp
index b97fff3..9e4dce2 100644
--- a/src/test/cpp/helpers/propertiestestcase.cpp
+++ b/src/test/cpp/helpers/propertiestestcase.cpp
@@ -49,8 +49,8 @@
 	{
 		//
 		//    read patternLayout1.properties
-		FileInputStreamPtr propFile =
-			new FileInputStream(LOG4CXX_STR("input/patternLayout1.properties"));
+        FileInputStreamPtr propFile = FileInputStreamPtr(
+            new FileInputStream(LOG4CXX_STR("input/patternLayout1.properties")));
 		Properties properties;
 		properties.load(propFile);
 		LogString pattern(properties.getProperty(LOG4CXX_STR("log4j.appender.testAppender.layout.ConversionPattern")));
diff --git a/src/test/cpp/helpers/threadtestcase.cpp b/src/test/cpp/helpers/threadtestcase.cpp
deleted file mode 100644
index 21fc671..0000000
--- a/src/test/cpp/helpers/threadtestcase.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <log4cxx/helpers/thread.h>
-#include "../insertwide.h"
-#include "../logunit.h"
-#include <apr_time.h>
-#include <log4cxx/helpers/exception.h>
-
-using namespace log4cxx;
-using namespace log4cxx::helpers;
-
-
-/**
-   Unit test for Thread.
-
-   */
-LOGUNIT_CLASS(ThreadTestCase)
-{
-	LOGUNIT_TEST_SUITE(ThreadTestCase);
-	LOGUNIT_TEST(testInterrupt);
-	LOGUNIT_TEST_SUITE_END();
-
-public:
-	/**
-	 * Start a thread that will wait for a minute, then interrupt it.
-	 */
-	void testInterrupt()
-	{
-		Thread thread1;
-		bool interrupted = false;
-		thread1.run(sleep, &interrupted);
-		apr_sleep(100000);
-		apr_time_t start = apr_time_now();
-		thread1.interrupt();
-		thread1.join();
-		LOGUNIT_ASSERT_EQUAL(true, interrupted);
-		apr_time_t elapsed = apr_time_now() - start;
-		LOGUNIT_ASSERT(elapsed < 1000000);
-	}
-
-private:
-	static void* LOG4CXX_THREAD_FUNC sleep(apr_thread_t* thread, void* data)
-	{
-		try
-		{
-			Thread::sleep(60000);
-		}
-		catch (InterruptedException& ex)
-		{
-			*(reinterpret_cast<bool*>(data)) = true;
-		}
-
-		return NULL;
-	}
-
-};
-
-LOGUNIT_TEST_SUITE_REGISTRATION(ThreadTestCase);
-
diff --git a/src/test/cpp/jsonlayouttest.cpp b/src/test/cpp/jsonlayouttest.cpp
index a40db66..708bef9 100644
--- a/src/test/cpp/jsonlayouttest.cpp
+++ b/src/test/cpp/jsonlayouttest.cpp
@@ -166,10 +166,10 @@
 	 */
 	void testAppendSerializedMDC()
 	{
-		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
+        LoggingEventPtr event1 = LoggingEventPtr(new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
-			LOG4CXX_LOCATION);
+            LOG4CXX_LOCATION));
 
 		MDC::put("key1", "value1");
 		MDC::put("key2", "value2");
@@ -187,10 +187,10 @@
 	 */
 	void testAppendSerializedMDCWithPrettyPrint()
 	{
-		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
+        LoggingEventPtr event1 = LoggingEventPtr(new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
-			LOG4CXX_LOCATION);
+            LOG4CXX_LOCATION));
 
 		MDC::put("key1", "value1");
 		MDC::put("key2", "value2");
@@ -224,10 +224,10 @@
 	 */
 	void testAppendSerializedNDC()
 	{
-		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
+        LoggingEventPtr event1 = LoggingEventPtr(new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
-			LOG4CXX_LOCATION);
+            LOG4CXX_LOCATION));
 
 		NDC::push("one");
 		NDC::push("two");
@@ -245,10 +245,10 @@
 	 */
 	void testAppendSerializedNDCWithPrettyPrint()
 	{
-		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
+        LoggingEventPtr event1 = LoggingEventPtr(new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
-			LOG4CXX_LOCATION);
+            LOG4CXX_LOCATION));
 
 		NDC::push("one");
 		NDC::push("two");
@@ -282,10 +282,10 @@
 	{
 		Pool p;
 
-		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
+        LoggingEventPtr event1 = LoggingEventPtr(new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
-			spi::LocationInfo("FooFile", "BarFunc", 42));
+            spi::LocationInfo("FooFile", "BarFunc", 42)));
 
 		LogString output1;
 		LogString expected1;
@@ -308,10 +308,10 @@
 	{
 		Pool p;
 
-		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
+        LoggingEventPtr event1 = LoggingEventPtr(new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
-			spi::LocationInfo("FooFile", "BarFunc", 42));
+            spi::LocationInfo("FooFile", "BarFunc", 42)));
 
 		LogString output1;
 		LogString expected1;
@@ -348,10 +348,10 @@
 	{
 		Pool p;
 
-		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
+        LoggingEventPtr event1 = LoggingEventPtr(new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
-			spi::LocationInfo("FooFile", "BarFunc", 42));
+            spi::LocationInfo("FooFile", "BarFunc", 42)));
 
 		LogString timestamp;
 		helpers::ISO8601DateFormat dateFormat;
@@ -396,10 +396,10 @@
 	{
 		Pool p;
 
-		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
+        LoggingEventPtr event1 = LoggingEventPtr(new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
-			spi::LocationInfo("FooFile", "BarFunc", 42));
+            spi::LocationInfo("FooFile", "BarFunc", 42)));
 
 		LogString timestamp;
 		helpers::ISO8601DateFormat dateFormat;
diff --git a/src/test/cpp/loggertestcase.cpp b/src/test/cpp/loggertestcase.cpp
index e36886d..fabf990 100644
--- a/src/test/cpp/loggertestcase.cpp
+++ b/src/test/cpp/loggertestcase.cpp
@@ -36,7 +36,7 @@
 using namespace log4cxx::helpers;
 
 class CountingAppender;
-typedef helpers::ObjectPtrT<CountingAppender> CountingAppenderPtr;
+typedef std::shared_ptr<CountingAppender> CountingAppenderPtr;
 
 class CountingAppender : public AppenderSkeleton
 {
@@ -97,7 +97,7 @@
 	void testAppender1()
 	{
 		logger = Logger::getLogger(LOG4CXX_TEST_STR("test"));
-		a1 = new FileAppender();
+        a1 = FileAppenderPtr(new FileAppender());
 		a1->setName(LOG4CXX_STR("testAppender1"));
 		logger->addAppender(a1);
 
@@ -112,9 +112,9 @@
 	*/
 	void testAppender2()
 	{
-		a1 = new FileAppender();
+        a1 = FileAppenderPtr(new FileAppender());
 		a1->setName(LOG4CXX_STR("testAppender2.1"));
-		a2 = new FileAppender();
+        a2 = FileAppenderPtr(new FileAppender());
 		a2->setName(LOG4CXX_STR("testAppender2.2"));
 
 		logger = Logger::getLogger(LOG4CXX_TEST_STR("test"));
@@ -135,7 +135,7 @@
 	{
 		LoggerPtr a = Logger::getLogger(LOG4CXX_TEST_STR("a"));
 		LoggerPtr ab = Logger::getLogger(LOG4CXX_TEST_STR("a.b"));
-		CountingAppenderPtr ca = new CountingAppender();
+        CountingAppenderPtr ca = CountingAppenderPtr(new CountingAppender());
 		a->addAppender(ca);
 
 		LOGUNIT_ASSERT_EQUAL(ca->counter, 0);
@@ -159,8 +159,8 @@
 		LoggerPtr abc = Logger::getLogger(LOG4CXX_TEST_STR("a.b.c"));
 		LoggerPtr x = Logger::getLogger(LOG4CXX_TEST_STR("x"));
 
-		CountingAppenderPtr ca1 = new CountingAppender();
-		CountingAppenderPtr ca2 = new CountingAppender();
+        CountingAppenderPtr ca1 = CountingAppenderPtr(new CountingAppender());
+        CountingAppenderPtr ca2 = CountingAppenderPtr(new CountingAppender());
 
 		a->addAppender(ca1);
 		abc->addAppender(ca2);
@@ -192,9 +192,9 @@
 		LoggerPtr abc = Logger::getLogger(LOG4CXX_TEST_STR("a.b.c"));
 		LoggerPtr x = Logger::getLogger(LOG4CXX_TEST_STR("x"));
 
-		CountingAppenderPtr caRoot = new CountingAppender();
-		CountingAppenderPtr caA = new CountingAppender();
-		CountingAppenderPtr caABC = new CountingAppender();
+        CountingAppenderPtr caRoot = CountingAppenderPtr(new CountingAppender());
+        CountingAppenderPtr caA = CountingAppenderPtr(new CountingAppender());
+        CountingAppenderPtr caABC = CountingAppenderPtr(new CountingAppender());
 
 		root->addAppender(caRoot);
 		a->addAppender(caA);
@@ -224,7 +224,7 @@
 
 	void testDisable1()
 	{
-		CountingAppenderPtr caRoot = new CountingAppender();
+        CountingAppenderPtr caRoot = CountingAppenderPtr(new CountingAppender());
 		LoggerPtr root = Logger::getRootLogger();
 		root->addAppender(caRoot);
 
@@ -391,7 +391,7 @@
 
 	void testHierarchy1()
 	{
-		LoggerRepositoryPtr h = new Hierarchy();
+        LoggerRepositoryPtr h = LoggerRepositoryPtr(new Hierarchy());
 		LoggerPtr root(h->getRootLogger());
 		root->setLevel(Level::getError());
 		LoggerPtr a0 = h->getLogger(LOG4CXX_STR("a"));
@@ -409,7 +409,7 @@
 		//   prior to fix, these line would compile.
 		//
 		(*logger).info("Hello, World.");
-		((Logger*) logger)->info("Hello, World.");
+        ((Logger*) logger.get())->info("Hello, World.");
 		//
 		//   this one would not.
 		//
@@ -423,7 +423,7 @@
 	 */
 	void testTrace()
 	{
-		VectorAppenderPtr appender = new VectorAppender();
+        VectorAppenderPtr appender = VectorAppenderPtr(new VectorAppender());
 		LoggerPtr root = Logger::getRootLogger();
 		root->addAppender(appender);
 		root->setLevel(Level::getInfo());
@@ -448,7 +448,7 @@
 	 */
 	void testIsTraceEnabled()
 	{
-		VectorAppenderPtr appender = new VectorAppender();
+        VectorAppenderPtr appender = VectorAppenderPtr(new VectorAppender());
 		LoggerPtr root = Logger::getRootLogger();
 		root->addAppender(appender);
 		root->setLevel(Level::getInfo());
diff --git a/src/test/cpp/minimumtestcase.cpp b/src/test/cpp/minimumtestcase.cpp
index 0064804..0c7d314 100644
--- a/src/test/cpp/minimumtestcase.cpp
+++ b/src/test/cpp/minimumtestcase.cpp
@@ -71,8 +71,8 @@
 
 	void simple()
 	{
-		LayoutPtr layout = new SimpleLayout();
-		AppenderPtr appender = new FileAppender(layout, LOG4CXX_STR("output/simple"), false);
+        LayoutPtr layout = LayoutPtr(new SimpleLayout());
+        AppenderPtr appender = FileAppenderPtr(new FileAppender(layout, LOG4CXX_STR("output/simple"), false));
 		root->addAppender(appender);
 		common();
 
@@ -81,9 +81,9 @@
 
 	void ttcc()
 	{
-		LayoutPtr layout =
-			new TTCCLayout(LOG4CXX_STR("DATE"));
-		AppenderPtr appender = new FileAppender(layout, LOG4CXX_STR("output/ttcc"), false);
+        LayoutPtr layout = TTCCLayoutPtr(
+            new TTCCLayout(LOG4CXX_STR("DATE")));
+        AppenderPtr appender = FileAppenderPtr(new FileAppender(layout, LOG4CXX_STR("output/ttcc"), false));
 		root->addAppender(appender);
 		common();
 
diff --git a/src/test/cpp/net/sockethubappendertestcase.cpp b/src/test/cpp/net/sockethubappendertestcase.cpp
index 816193d..03afc4f 100644
--- a/src/test/cpp/net/sockethubappendertestcase.cpp
+++ b/src/test/cpp/net/sockethubappendertestcase.cpp
@@ -17,7 +17,6 @@
 
 #include <log4cxx/net/sockethubappender.h>
 #include "../appenderskeletontestcase.h"
-#include <log4cxx/helpers/thread.h>
 #include <apr.h>
 
 using namespace log4cxx;
@@ -61,8 +60,8 @@
 		{
 			SocketHubAppenderPtr hubAppender(new SocketHubAppender());
 			Pool p;
-			hubAppender->activateOptions(p);
-			Thread::sleep(1000);
+            hubAppender->activateOptions(p);
+            std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
 			hubAppender->close();
 		}
 
diff --git a/src/test/cpp/net/socketservertestcase.cpp b/src/test/cpp/net/socketservertestcase.cpp
index fb31bd0..e7882c7 100644
--- a/src/test/cpp/net/socketservertestcase.cpp
+++ b/src/test/cpp/net/socketservertestcase.cpp
@@ -141,8 +141,8 @@
 	*/
 	void test1()
 	{
-		SocketAppenderPtr socketAppender1 =
-			new SocketAppender(LOG4CXX_STR("localhost"), PORT);
+        SocketAppenderPtr socketAppender1 = SocketAppenderPtr(
+            new SocketAppender(LOG4CXX_STR("localhost"), PORT));
 		root->addAppender(socketAppender1);
 		common("test1", LOG4CXX_STR("T1"), LOG4CXX_STR("key1"), LOG4CXX_STR("MDC-TEST1"));
 		delay(1);
@@ -171,8 +171,8 @@
 
 	void test2()
 	{
-		SocketAppenderPtr socketAppender1 =
-			new SocketAppender(LOG4CXX_STR("localhost"), PORT);
+        SocketAppenderPtr socketAppender1 = SocketAppenderPtr(
+            new SocketAppender(LOG4CXX_STR("localhost"), PORT));
 		root->addAppender(socketAppender1);
 		common("test2", LOG4CXX_STR("T2"), LOG4CXX_STR("key2"), LOG4CXX_STR("MDC-TEST2"));
 		delay(1);
@@ -206,8 +206,8 @@
 
 	void test3()
 	{
-		SocketAppenderPtr socketAppender1 =
-			new SocketAppender(LOG4CXX_STR("localhost"), PORT);
+        SocketAppenderPtr socketAppender1 = SocketAppenderPtr(
+            new SocketAppender(LOG4CXX_STR("localhost"), PORT));
 		root->addAppender(socketAppender1);
 		common("test3", LOG4CXX_STR("T3"), LOG4CXX_STR("key3"), LOG4CXX_STR("MDC-TEST3"));
 		delay(1);
@@ -241,8 +241,8 @@
 
 	void test4()
 	{
-		SocketAppenderPtr socketAppender1 =
-			new SocketAppender(LOG4CXX_STR("localhost"), PORT);
+        SocketAppenderPtr socketAppender1 = SocketAppenderPtr(
+            new SocketAppender(LOG4CXX_STR("localhost"), PORT));
 		root->addAppender(socketAppender1);
 		NDC::push(LOG4CXX_TEST_STR("some"));
 		common("test4", LOG4CXX_STR("T4"), LOG4CXX_STR("key4"), LOG4CXX_STR("MDC-TEST4"));
@@ -273,9 +273,9 @@
 
 	void test5()
 	{
-		SocketAppenderPtr socketAppender1 =
-			new SocketAppender(LOG4CXX_STR("localhost"), PORT);
-		AsyncAppenderPtr asyncAppender = new AsyncAppender();
+        SocketAppenderPtr socketAppender1 = SocketAppenderPtr(
+            new SocketAppender(LOG4CXX_STR("localhost"), PORT));
+        AsyncAppenderPtr asyncAppender = AsyncAppenderPtr(new AsyncAppender());
 
 		root->addAppender(socketAppender1);
 		root->addAppender(asyncAppender);
@@ -309,9 +309,9 @@
 
 	void test6()
 	{
-		SocketAppenderPtr socketAppender1 =
-			new SocketAppender(LOG4CXX_STR("localhost"), PORT);
-		AsyncAppenderPtr asyncAppender = new AsyncAppender();
+        SocketAppenderPtr socketAppender1 = SocketAppenderPtr(
+            new SocketAppender(LOG4CXX_STR("localhost"), PORT));
+        AsyncAppenderPtr asyncAppender = AsyncAppenderPtr(new AsyncAppender());
 
 		root->addAppender(socketAppender1);
 		root->addAppender(asyncAppender);
@@ -347,9 +347,9 @@
 
 	void test7()
 	{
-		SocketAppenderPtr socketAppender1 =
-			new SocketAppender(LOG4CXX_STR("localhost"), PORT);
-		AsyncAppenderPtr asyncAppender = new AsyncAppender();
+        SocketAppenderPtr socketAppender1 = SocketAppenderPtr(
+            new SocketAppender(LOG4CXX_STR("localhost"), PORT));
+        AsyncAppenderPtr asyncAppender = AsyncAppenderPtr(new AsyncAppender());
 
 		root->addAppender(socketAppender1);
 		root->addAppender(asyncAppender);
@@ -385,8 +385,8 @@
 
 	void test8()
 	{
-		SocketAppenderPtr socketAppender1 =
-			new SocketAppender(LOG4CXX_STR("localhost"), PORT);
+        SocketAppenderPtr socketAppender1 = SocketAppenderPtr(
+            new SocketAppender(LOG4CXX_STR("localhost"), PORT));
 
 		root->addAppender(socketAppender1);
 
diff --git a/src/test/cpp/net/telnetappendertestcase.cpp b/src/test/cpp/net/telnetappendertestcase.cpp
index 8cde17f..f4eb81b 100644
--- a/src/test/cpp/net/telnetappendertestcase.cpp
+++ b/src/test/cpp/net/telnetappendertestcase.cpp
@@ -55,7 +55,7 @@
 		void testActivateClose()
 		{
 			TelnetAppenderPtr appender(new TelnetAppender());
-			appender->setLayout(new TTCCLayout());
+            appender->setLayout(LayoutPtr(new TTCCLayout()));
 			appender->setPort(TEST_PORT);
 			Pool p;
 			appender->activateOptions(p);
@@ -65,18 +65,18 @@
 		void testActivateSleepClose()
 		{
 			TelnetAppenderPtr appender(new TelnetAppender());
-			appender->setLayout(new TTCCLayout());
+            appender->setLayout(LayoutPtr(new TTCCLayout()));
 			appender->setPort(TEST_PORT);
 			Pool p;
-			appender->activateOptions(p);
-			Thread::sleep(1000);
+            appender->activateOptions(p);
+            std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
 			appender->close();
 		}
 
 		void testActivateWriteClose()
 		{
 			TelnetAppenderPtr appender(new TelnetAppender());
-			appender->setLayout(new TTCCLayout());
+            appender->setLayout(LayoutPtr(new TTCCLayout()));
 			appender->setPort(TEST_PORT);
 			Pool p;
 			appender->activateOptions(p);
diff --git a/src/test/cpp/pattern/num343patternconverter.cpp b/src/test/cpp/pattern/num343patternconverter.cpp
index f330930..cd604be 100644
--- a/src/test/cpp/pattern/num343patternconverter.cpp
+++ b/src/test/cpp/pattern/num343patternconverter.cpp
@@ -36,7 +36,7 @@
 PatternConverterPtr Num343PatternConverter::newInstance(
 	const std::vector<LogString>&)
 {
-	return new Num343PatternConverter();
+    return PatternConverterPtr(new Num343PatternConverter());
 }
 
 
diff --git a/src/test/cpp/pattern/patternparsertestcase.cpp b/src/test/cpp/pattern/patternparsertestcase.cpp
index f49e2a2..ffd2b5f 100644
--- a/src/test/cpp/pattern/patternparsertestcase.cpp
+++ b/src/test/cpp/pattern/patternparsertestcase.cpp
@@ -78,8 +78,8 @@
 public:
 	void setUp()
 	{
-		event = new LoggingEvent(
-			LOG4CXX_STR("org.foobar"), Level::getInfo(), LOG4CXX_STR("msg 1"), LOG4CXX_LOCATION);
+        event = LoggingEventPtr(new LoggingEvent(
+            LOG4CXX_STR("org.foobar"), Level::getInfo(), LOG4CXX_STR("msg 1"), LOG4CXX_LOCATION));
 	}
 
 	void tearDown()
diff --git a/src/test/cpp/patternlayouttest.cpp b/src/test/cpp/patternlayouttest.cpp
index b6c8510..0eccf14 100644
--- a/src/test/cpp/patternlayouttest.cpp
+++ b/src/test/cpp/patternlayouttest.cpp
@@ -441,8 +441,8 @@
 		LogString mdcMsgPattern5 = LOG4CXX_STR("%m : %X{key1},%X{key2},%X{key3}%n");
 
 		// set up appender
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m%n"));
-		AppenderPtr appender = new FileAppender(layout, OUTPUT_FILE, false);
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m%n")));
+        AppenderPtr appender = FileAppenderPtr(new FileAppender(layout, OUTPUT_FILE, false));
 
 		// set appender on root and set level to debug
 		root->addAppender(appender);
diff --git a/src/test/cpp/propertyconfiguratortest.cpp b/src/test/cpp/propertyconfiguratortest.cpp
index 15e2f55..74f8203 100644
--- a/src/test/cpp/propertyconfiguratortest.cpp
+++ b/src/test/cpp/propertyconfiguratortest.cpp
@@ -76,7 +76,7 @@
 		props.put(LOG4CXX_STR("log4j.appender.VECTOR1.threshold"), LOG4CXX_STR("WARN"));
 		PropertyConfigurator::configure(props);
 		LoggerPtr root(Logger::getRootLogger());
-		VectorAppenderPtr appender(root->getAppender(LOG4CXX_STR("VECTOR1")));
+        VectorAppenderPtr appender = log4cxx::cast<VectorAppender>(root->getAppender(LOG4CXX_STR("VECTOR1")));
 		LOGUNIT_ASSERT_EQUAL((int) Level::WARN_INT, appender->getThreshold()->toInt());
 		LOG4CXX_INFO(root, "Info message");
 		LOG4CXX_WARN(root, "Warn message");
diff --git a/src/test/cpp/rolling/manualrollingtest.cpp b/src/test/cpp/rolling/manualrollingtest.cpp
index 188d4f3..0d6223c 100644
--- a/src/test/cpp/rolling/manualrollingtest.cpp
+++ b/src/test/cpp/rolling/manualrollingtest.cpp
@@ -110,13 +110,13 @@
 	 */
 	void test1()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setName(LOG4CXX_STR("ROLLING"));
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 
-		FixedWindowRollingPolicyPtr swrp = new FixedWindowRollingPolicy();
+        FixedWindowRollingPolicyPtr swrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
 		swrp->setMinIndex(0);
 
 		swrp->setFileNamePattern(LOG4CXX_STR("output/manual-test1.%i"));
@@ -146,8 +146,8 @@
 	 */
 	void test2()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setName(LOG4CXX_STR("ROLLING"));
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
@@ -176,12 +176,12 @@
 	 */
 	void test3()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 
-		FixedWindowRollingPolicyPtr  fwrp = new FixedWindowRollingPolicy();
+        FixedWindowRollingPolicyPtr  fwrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
 
 		fwrp->setMinIndex(0);
 		rfa->setFile(LOG4CXX_STR("output/manual-test3.log"));
@@ -208,14 +208,14 @@
 	 */
 	void test4()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setName(LOG4CXX_STR("ROLLING"));
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 		rfa->setFile(LOG4CXX_STR("output/manual-test4.log"));
 
-		FixedWindowRollingPolicyPtr swrp = new FixedWindowRollingPolicy();
+        FixedWindowRollingPolicyPtr swrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
 
 		swrp->setMinIndex(0);
 
@@ -244,14 +244,14 @@
 	 */
 	void test5()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setName(LOG4CXX_STR("ROLLING"));
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 		rfa->setFile(LOG4CXX_STR("output/manual-test5.log"));
 
-		FixedWindowRollingPolicyPtr swrp = new FixedWindowRollingPolicy();
+        FixedWindowRollingPolicyPtr swrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
 
 		swrp->setMinIndex(0);
 
diff --git a/src/test/cpp/rolling/sizebasedrollingtest.cpp b/src/test/cpp/rolling/sizebasedrollingtest.cpp
index ccee138..790fa5f 100644
--- a/src/test/cpp/rolling/sizebasedrollingtest.cpp
+++ b/src/test/cpp/rolling/sizebasedrollingtest.cpp
@@ -106,14 +106,14 @@
 	 */
 	void test1()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setName(LOG4CXX_STR("ROLLING"));
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 
-		FixedWindowRollingPolicyPtr swrp = new FixedWindowRollingPolicy();
-		SizeBasedTriggeringPolicyPtr sbtp = new SizeBasedTriggeringPolicy();
+        FixedWindowRollingPolicyPtr swrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
+        SizeBasedTriggeringPolicyPtr sbtp = SizeBasedTriggeringPolicyPtr(new SizeBasedTriggeringPolicy());
 
 		sbtp->setMaxFileSize(100);
 		swrp->setMinIndex(0);
@@ -146,15 +146,15 @@
 	 */
 	void test2()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setName(LOG4CXX_STR("ROLLING"));
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 		rfa->setFile(LOG4CXX_STR("output/sizeBased-test2.log"));
 
-		FixedWindowRollingPolicyPtr swrp = new FixedWindowRollingPolicy();
-		SizeBasedTriggeringPolicyPtr sbtp = new SizeBasedTriggeringPolicy();
+        FixedWindowRollingPolicyPtr swrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
+        SizeBasedTriggeringPolicyPtr sbtp = SizeBasedTriggeringPolicyPtr(new SizeBasedTriggeringPolicy());
 
 		sbtp->setMaxFileSize(100);
 		swrp->setMinIndex(0);
@@ -187,13 +187,13 @@
 	 */
 	void test3()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 
-		FixedWindowRollingPolicyPtr  fwrp = new FixedWindowRollingPolicy();
-		SizeBasedTriggeringPolicyPtr sbtp = new SizeBasedTriggeringPolicy();
+        FixedWindowRollingPolicyPtr  fwrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
+        SizeBasedTriggeringPolicyPtr sbtp = SizeBasedTriggeringPolicyPtr(new SizeBasedTriggeringPolicy());
 
 		sbtp->setMaxFileSize(100);
 		fwrp->setMinIndex(0);
@@ -222,15 +222,15 @@
 	 */
 	void test4()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setName(LOG4CXX_STR("ROLLING"));
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 		rfa->setFile(LOG4CXX_STR("output/sizeBased-test4.log"));
 
-		FixedWindowRollingPolicyPtr swrp = new FixedWindowRollingPolicy();
-		SizeBasedTriggeringPolicyPtr sbtp = new SizeBasedTriggeringPolicy();
+        FixedWindowRollingPolicyPtr swrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
+        SizeBasedTriggeringPolicyPtr sbtp = SizeBasedTriggeringPolicyPtr(new SizeBasedTriggeringPolicy());
 
 		sbtp->setMaxFileSize(100);
 		swrp->setMinIndex(0);
@@ -261,15 +261,15 @@
 	 */
 	void test5()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setName(LOG4CXX_STR("ROLLING"));
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 		rfa->setFile(LOG4CXX_STR("output/sizeBased-test5.log"));
 
-		FixedWindowRollingPolicyPtr swrp = new FixedWindowRollingPolicy();
-		SizeBasedTriggeringPolicyPtr sbtp = new SizeBasedTriggeringPolicy();
+        FixedWindowRollingPolicyPtr swrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
+        SizeBasedTriggeringPolicyPtr sbtp = SizeBasedTriggeringPolicyPtr(new SizeBasedTriggeringPolicy());
 
 		sbtp->setMaxFileSize(100);
 		swrp->setMinIndex(0);
@@ -335,13 +335,13 @@
 	 */
 	void test6()
 	{
-		PatternLayoutPtr layout = new PatternLayout(LOG4CXX_STR("%m\n"));
-		RollingFileAppenderPtr rfa = new RollingFileAppender();
+        PatternLayoutPtr layout = PatternLayoutPtr(new PatternLayout(LOG4CXX_STR("%m\n")));
+        RollingFileAppenderPtr rfa = RollingFileAppenderPtr(new RollingFileAppender());
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 
-		FixedWindowRollingPolicyPtr  fwrp = new FixedWindowRollingPolicy();
-		SizeBasedTriggeringPolicyPtr sbtp = new SizeBasedTriggeringPolicy();
+        FixedWindowRollingPolicyPtr  fwrp = FixedWindowRollingPolicyPtr(new FixedWindowRollingPolicy());
+        SizeBasedTriggeringPolicyPtr sbtp = SizeBasedTriggeringPolicyPtr(new SizeBasedTriggeringPolicy());
 
 		sbtp->setMaxFileSize(100);
 		fwrp->setMinIndex(0);
diff --git a/src/test/cpp/rolling/timebasedrollingtest.cpp b/src/test/cpp/rolling/timebasedrollingtest.cpp
index d3ab1c9..298d1fb 100644
--- a/src/test/cpp/rolling/timebasedrollingtest.cpp
+++ b/src/test/cpp/rolling/timebasedrollingtest.cpp
@@ -385,9 +385,9 @@
 	{
 		LoggerPtr root(Logger::getRootLogger());
 		root->addAppender(
-			new ConsoleAppender(
-				new PatternLayout(
-					LOG4CXX_STR("%d{ABSOLUTE} [%t] %level %c{2}#%M:%L - %m%n"))));
+            ConsoleAppenderPtr(new ConsoleAppender(
+                PatternLayoutPtr(new PatternLayout(
+                    LOG4CXX_STR("%d{ABSOLUTE} [%t] %level %c{2}#%M:%L - %m%n"))))));
 		this->internalSetUp(this->num_test);
 	}
 
@@ -454,7 +454,7 @@
 		RollingFileAppenderPtr  rfa2(   new RollingFileAppender());
 		rfa2->setLayout(layout2);
 
-		TimeBasedRollingPolicyPtr tbrp2 = new TimeBasedRollingPolicy();
+        TimeBasedRollingPolicyPtr tbrp2 = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
 		tbrp2->setFileNamePattern(LOG4CXX_STR("output/test2-%d{" DATE_PATTERN "}"));
 		tbrp2->activateOptions(pool);
 		rfa2->setRollingPolicy(tbrp2);
@@ -479,7 +479,7 @@
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 
-		TimeBasedRollingPolicyPtr tbrp = new TimeBasedRollingPolicy();
+        TimeBasedRollingPolicyPtr tbrp = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
 		tbrp->setFileNamePattern(LogString(LOG4CXX_STR("output/test3-%d{" DATE_PATTERN "}.gz")));
 		tbrp->activateOptions(pool);
 		rfa->setRollingPolicy(tbrp);
@@ -506,7 +506,7 @@
 		RollingFileAppenderPtr  rfa1(   new RollingFileAppender());
 		rfa1->setLayout(layout1);
 
-		TimeBasedRollingPolicyPtr tbrp1 = new TimeBasedRollingPolicy();
+        TimeBasedRollingPolicyPtr tbrp1 = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
 		rfa1->setFile(LOG4CXX_STR("output/test4.log"));
 		tbrp1->setFileNamePattern(LOG4CXX_STR("output/test4-%d{" DATE_PATTERN "}"));
 		tbrp1->activateOptions(pool);
@@ -526,7 +526,7 @@
 		RollingFileAppenderPtr  rfa2(   new RollingFileAppender());
 		rfa2->setLayout(layout2);
 
-		TimeBasedRollingPolicyPtr tbrp2 = new TimeBasedRollingPolicy();
+        TimeBasedRollingPolicyPtr tbrp2 = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
 		tbrp2->setFileNamePattern(LOG4CXX_STR("output/test4-%d{" DATE_PATTERN "}"));
 		rfa2->setFile(fileNames[3]);
 		tbrp2->activateOptions(pool);
@@ -551,7 +551,7 @@
 		RollingFileAppenderPtr  rfa(    new RollingFileAppender());
 		rfa->setLayout(layout);
 
-		TimeBasedRollingPolicyPtr tbrp = new TimeBasedRollingPolicy();
+        TimeBasedRollingPolicyPtr tbrp = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
 		tbrp->setFileNamePattern(LOG4CXX_STR("output/test5-%d{" DATE_PATTERN "}"));
 		rfa->setFile(LOG4CXX_STR("output/test5.log"));
 
@@ -581,7 +581,7 @@
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 
-		TimeBasedRollingPolicyPtr tbrp = new TimeBasedRollingPolicy();
+        TimeBasedRollingPolicyPtr tbrp = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
 		tbrp->setFileNamePattern(LogString(LOG4CXX_STR("output/test6-%d{" DATE_PATTERN "}.gz")));
 		rfa->setFile(LOG4CXX_STR("output/test6.log"));
 		tbrp->activateOptions(pool);
diff --git a/src/test/cpp/spi/loggingeventtest.cpp b/src/test/cpp/spi/loggingeventtest.cpp
index ba07301..306ef87 100644
--- a/src/test/cpp/spi/loggingeventtest.cpp
+++ b/src/test/cpp/spi/loggingeventtest.cpp
@@ -62,9 +62,9 @@
 	 */
 	void testSerializationSimple()
 	{
-		LoggingEventPtr event =
+        LoggingEventPtr event = LoggingEventPtr(
 			new LoggingEvent(
-			LOG4CXX_STR("root"), Level::getInfo(), LOG4CXX_STR("Hello, world."), LocationInfo::getLocationUnavailable());
+            LOG4CXX_STR("root"), Level::getInfo(), LOG4CXX_STR("Hello, world."), LocationInfo::getLocationUnavailable()));
 
 		LOGUNIT_ASSERT_EQUAL(true, SerializationTestHelper::compare(
 				"witness/serialization/simple.bin", event, 237));
@@ -79,9 +79,9 @@
 	 */
 	void testSerializationWithLocation()
 	{
-		LoggingEventPtr event =
+        LoggingEventPtr event = LoggingEventPtr(
 			new LoggingEvent(
-			LOG4CXX_STR("root"), Level::getInfo(), LOG4CXX_STR("Hello, world."), LOG4CXX_LOCATION);
+            LOG4CXX_STR("root"), Level::getInfo(), LOG4CXX_STR("Hello, world."), LOG4CXX_LOCATION));
 
 		LOGUNIT_ASSERT_EQUAL(true, SerializationTestHelper::compare(
 				"witness/serialization/location.bin", event, 237));
@@ -96,9 +96,9 @@
 	{
 		NDC::push("ndc test");
 
-		LoggingEventPtr event =
+        LoggingEventPtr event = LoggingEventPtr(
 			new LoggingEvent(
-			LOG4CXX_STR("root"), Level::getInfo(), LOG4CXX_STR("Hello, world."), LocationInfo::getLocationUnavailable());
+            LOG4CXX_STR("root"), Level::getInfo(), LOG4CXX_STR("Hello, world."), LocationInfo::getLocationUnavailable()));
 
 		LOGUNIT_ASSERT_EQUAL(true, SerializationTestHelper::compare(
 				"witness/serialization/ndc.bin", event, 237));
@@ -113,9 +113,9 @@
 	{
 		MDC::put("mdckey", "mdcvalue");
 
-		LoggingEventPtr event =
+        LoggingEventPtr event = LoggingEventPtr(
 			new LoggingEvent(
-			LOG4CXX_STR("root"), Level::getInfo(), LOG4CXX_STR("Hello, world."), LocationInfo::getLocationUnavailable());
+            LOG4CXX_STR("root"), Level::getInfo(), LOG4CXX_STR("Hello, world."), LocationInfo::getLocationUnavailable()));
 
 		LOGUNIT_ASSERT_EQUAL(true, SerializationTestHelper::compare(
 				"witness/serialization/mdc.bin", event, 237));
diff --git a/src/test/cpp/streamtestcase.cpp b/src/test/cpp/streamtestcase.cpp
index 271e65e..9ec3140 100644
--- a/src/test/cpp/streamtestcase.cpp
+++ b/src/test/cpp/streamtestcase.cpp
@@ -127,7 +127,7 @@
 	{
 		LoggerPtr root(Logger::getRootLogger());
 		LayoutPtr layout(new SimpleLayout());
-		vectorAppender = new VectorAppender();
+        vectorAppender = VectorAppenderPtr(new VectorAppender());
 		root->addAppender(vectorAppender);
 	}
 
diff --git a/src/test/cpp/util/compare.cpp b/src/test/cpp/util/compare.cpp
index b16fc37..f81e1aa 100644
--- a/src/test/cpp/util/compare.cpp
+++ b/src/test/cpp/util/compare.cpp
@@ -29,13 +29,13 @@
 bool Compare::compare(const File& file1, const File& file2)
 {
 	Pool pool;
-	InputStreamPtr fileIn1 = new FileInputStream(file1);
-	InputStreamReaderPtr reader1 = new InputStreamReader(fileIn1);
+    InputStreamPtr fileIn1 = InputStreamPtr( new FileInputStream(file1) );
+    InputStreamReaderPtr reader1 = InputStreamReaderPtr( new InputStreamReader(fileIn1) );
 	LogString in1(reader1->read(pool));
 
 	Pool pool2;
-	InputStreamPtr fileIn2 = new FileInputStream(file2);
-	InputStreamReaderPtr reader2 = new InputStreamReader(fileIn2);
+    InputStreamPtr fileIn2 = InputStreamPtr( new FileInputStream(file2) );
+    InputStreamReaderPtr reader2 = InputStreamReaderPtr( new InputStreamReader(fileIn2) );
 	LogString in2(reader2->read(pool2));
 
 	LogString back1(in1);
diff --git a/src/test/cpp/util/serializationtesthelper.cpp b/src/test/cpp/util/serializationtesthelper.cpp
index 6c82e91..dd21168 100644
--- a/src/test/cpp/util/serializationtesthelper.cpp
+++ b/src/test/cpp/util/serializationtesthelper.cpp
@@ -33,7 +33,7 @@
 bool SerializationTestHelper::compare(
 	const char* witness, const LoggingEventPtr& event, size_t endCompare)
 {
-	ByteArrayOutputStreamPtr memOut = new ByteArrayOutputStream();
+    ByteArrayOutputStreamPtr memOut = ByteArrayOutputStreamPtr( new ByteArrayOutputStream() );
 	Pool p;
 	ObjectOutputStream objOut(memOut, p);
 	event->write(objOut, p);
diff --git a/src/test/cpp/varia/errorhandlertestcase.cpp b/src/test/cpp/varia/errorhandlertestcase.cpp
index 1385182..8fd2444 100644
--- a/src/test/cpp/varia/errorhandlertestcase.cpp
+++ b/src/test/cpp/varia/errorhandlertestcase.cpp
@@ -19,6 +19,7 @@
 #include <log4cxx/xml/domconfigurator.h>
 #include <log4cxx/fileappender.h>
 #include <log4cxx/varia/fallbackerrorhandler.h>
+#include <log4cxx/appender.h>
 #include "../logunit.h"
 #include "../util/transformer.h"
 #include "../util/compare.h"
@@ -56,8 +57,11 @@
 	void test1()
 	{
 		DOMConfigurator::configure("input/xml/fallback1.xml");
-		FileAppenderPtr primary(root->getAppender(LOG4CXX_STR("PRIMARY")));
-		log4cxx::varia::FallbackErrorHandlerPtr eh(primary->getErrorHandler());
+        AppenderPtr appender = root->getAppender(LOG4CXX_STR("PRIMARY"));
+        FileAppenderPtr primary = log4cxx::cast<FileAppender>(appender);
+        log4cxx::varia::FallbackErrorHandlerPtr eh;
+        log4cxx::spi::ErrorHandlerPtr errHandle = primary->getErrorHandler();
+        eh = log4cxx::cast<log4cxx::varia::FallbackErrorHandler>(errHandle);
 		LOGUNIT_ASSERT(eh != 0);
 
 		common();
diff --git a/src/test/cpp/varia/levelmatchfiltertestcase.cpp b/src/test/cpp/varia/levelmatchfiltertestcase.cpp
index e8f9c7a..18c7d61 100644
--- a/src/test/cpp/varia/levelmatchfiltertestcase.cpp
+++ b/src/test/cpp/varia/levelmatchfiltertestcase.cpp
@@ -62,11 +62,11 @@
 	void accept()
 	{
 		// set up appender
-		LayoutPtr layout = new SimpleLayout();
-		AppenderPtr appender = new FileAppender(layout, ACCEPT_FILE, false);
+        LayoutPtr layout = LayoutPtr(new SimpleLayout());
+        AppenderPtr appender = AppenderPtr(new FileAppender(layout, ACCEPT_FILE, false));
 
 		// create LevelMatchFilter
-		LevelMatchFilterPtr matchFilter = new LevelMatchFilter();
+        LevelMatchFilterPtr matchFilter = LevelMatchFilterPtr(new LevelMatchFilter());
 
 		// attach match filter to appender
 		appender->addFilter(matchFilter);
@@ -105,11 +105,11 @@
 	void deny()
 	{
 		// set up appender
-		LayoutPtr layout = new SimpleLayout();
-		AppenderPtr appender = new FileAppender(layout, DENY_FILE, false);
+        LayoutPtr layout = LayoutPtr(new SimpleLayout());
+        AppenderPtr appender = AppenderPtr(new FileAppender(layout, DENY_FILE, false));
 
 		// create LevelMatchFilter, set to deny matches
-		LevelMatchFilterPtr matchFilter = new LevelMatchFilter();
+        LevelMatchFilterPtr matchFilter = LevelMatchFilterPtr(new LevelMatchFilter());
 		matchFilter->setAcceptOnMatch(false);
 
 		// attach match filter to appender
diff --git a/src/test/cpp/varia/levelrangefiltertestcase.cpp b/src/test/cpp/varia/levelrangefiltertestcase.cpp
index 13c4300..5fb23ba 100644
--- a/src/test/cpp/varia/levelrangefiltertestcase.cpp
+++ b/src/test/cpp/varia/levelrangefiltertestcase.cpp
@@ -62,11 +62,11 @@
 	void accept()
 	{
 		// set up appender
-		LayoutPtr layout = new SimpleLayout();
-		AppenderPtr appender = new FileAppender(layout, ACCEPT_FILE, false);
+        LayoutPtr layout = LayoutPtr(new SimpleLayout());
+        AppenderPtr appender = AppenderPtr(new FileAppender(layout, ACCEPT_FILE, false));
 
 		// create LevelMatchFilter
-		LevelRangeFilterPtr rangeFilter = new LevelRangeFilter();
+        LevelRangeFilterPtr rangeFilter = LevelRangeFilterPtr(new LevelRangeFilter());
 
 		// set it to accept on a match
 		rangeFilter->setAcceptOnMatch(true);
@@ -98,7 +98,7 @@
 
 		// create a clean filter
 		appender->clearFilters();
-		rangeFilter = new LevelRangeFilter();
+        rangeFilter = LevelRangeFilterPtr(new LevelRangeFilter());
 		appender->addFilter(rangeFilter);
 
 		//test with max set
@@ -149,11 +149,11 @@
 	void neutral()
 	{
 		// set up appender
-		LayoutPtr layout = new SimpleLayout();
-		AppenderPtr appender = new FileAppender(layout, NEUTRAL_FILE, false);
+        LayoutPtr layout = LayoutPtr(new SimpleLayout());
+        AppenderPtr appender = AppenderPtr(new FileAppender(layout, NEUTRAL_FILE, false));
 
 		// create LevelMatchFilter
-		LevelRangeFilterPtr rangeFilter = new LevelRangeFilter();
+        LevelRangeFilterPtr rangeFilter = LevelRangeFilterPtr(new LevelRangeFilter());
 
 		// set it to accept on a match
 		rangeFilter->setAcceptOnMatch(true);
@@ -187,7 +187,7 @@
 
 		// create a clean filter
 		appender->clearFilters();
-		rangeFilter = new LevelRangeFilter();
+        rangeFilter = LevelRangeFilterPtr(new LevelRangeFilter());
 		appender->addFilter(rangeFilter);
 
 		//test with max set
diff --git a/src/test/cpp/vectorappender.cpp b/src/test/cpp/vectorappender.cpp
index fef8e7c..e562513 100644
--- a/src/test/cpp/vectorappender.cpp
+++ b/src/test/cpp/vectorappender.cpp
@@ -16,7 +16,6 @@
  */
 
 #include "vectorappender.h"
-#include <log4cxx/helpers/thread.h>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -25,13 +24,7 @@
 
 void VectorAppender::append(const spi::LoggingEventPtr& event, Pool& /*p*/)
 {
-	try
-	{
-		Thread::sleep(100);
-	}
-	catch (Exception&)
-	{
-	}
+	std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
 
 	vector.push_back(event);
 }
diff --git a/src/test/cpp/vectorappender.h b/src/test/cpp/vectorappender.h
index 5bbca23..2f6176f 100644
--- a/src/test/cpp/vectorappender.h
+++ b/src/test/cpp/vectorappender.h
@@ -61,5 +61,5 @@
 			return false;
 		}
 };
-typedef helpers::ObjectPtrT<VectorAppender> VectorAppenderPtr;
+typedef std::shared_ptr<VectorAppender> VectorAppenderPtr;
 }
diff --git a/src/test/cpp/writerappendertestcase.cpp b/src/test/cpp/writerappendertestcase.cpp
index 35b18ff..c593612 100644
--- a/src/test/cpp/writerappendertestcase.cpp
+++ b/src/test/cpp/writerappendertestcase.cpp
@@ -16,7 +16,6 @@
  */
 
 #include "writerappendertestcase.h"
-#include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/writerappender.h>
 
 
diff --git a/src/test/cpp/xml/domtestcase.cpp b/src/test/cpp/xml/domtestcase.cpp
index 251770a..9868093 100644
--- a/src/test/cpp/xml/domtestcase.cpp
+++ b/src/test/cpp/xml/domtestcase.cpp
@@ -30,6 +30,7 @@
 #include <apr_pools.h>
 #include <apr_file_io.h>
 #include "../testchar.h"
+#include "log4cxx/helpers/loglog.h"
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -45,180 +46,181 @@
 
 LOGUNIT_CLASS(DOMTestCase)
 {
-	LOGUNIT_TEST_SUITE(DOMTestCase);
-	LOGUNIT_TEST(test1);
+    LOGUNIT_TEST_SUITE(DOMTestCase);
+    LOGUNIT_TEST(test1);
 #if defined(_WIN32)
-	LOGUNIT_TEST(test2);
+    LOGUNIT_TEST(test2);
 #endif
-	LOGUNIT_TEST(test3);
-	LOGUNIT_TEST(test4);
-	LOGUNIT_TEST_SUITE_END();
+    LOGUNIT_TEST(test3);
+    LOGUNIT_TEST(test4);
+    LOGUNIT_TEST_SUITE_END();
 
-	LoggerPtr root;
-	LoggerPtr logger;
+    LoggerPtr root;
+    LoggerPtr logger;
 
-	static const File TEMP_A1;
-	static const File TEMP_A2;
-	static const File FILTERED_A1;
-	static const File FILTERED_A2;
-	static const File TEMP_A1_2;
-	static const File TEMP_A2_2;
-	static const File FILTERED_A1_2;
-	static const File FILTERED_A2_2;
+    static const File TEMP_A1;
+    static const File TEMP_A2;
+    static const File FILTERED_A1;
+    static const File FILTERED_A2;
+    static const File TEMP_A1_2;
+    static const File TEMP_A2_2;
+    static const File FILTERED_A1_2;
+    static const File FILTERED_A2_2;
 
 public:
-	void setUp()
-	{
-		root = Logger::getRootLogger();
-		logger = Logger::getLogger(LOG4CXX_TEST_STR("org.apache.log4j.xml.DOMTestCase"));
-	}
+    void setUp()
+    {
+        root = Logger::getRootLogger();
+        logger = Logger::getLogger(LOG4CXX_TEST_STR("org.apache.log4j.xml.DOMTestCase"));
+    }
 
-	void tearDown()
-	{
-		root->getLoggerRepository()->resetConfiguration();
-	}
+    void tearDown()
+    {
+        root->getLoggerRepository()->resetConfiguration();
+    }
 
-	void test1()
-	{
-		DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase1.xml"));
-		common();
+    void test1()
+    {
+        LogLog::setInternalDebugging(true);
+        DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase1.xml"));
+        common();
 
-		ControlFilter cf1;
-		cf1 << TEST1_1A_PAT << TEST1_1B_PAT;
+        ControlFilter cf1;
+        cf1 << TEST1_1A_PAT << TEST1_1B_PAT;
 
-		ControlFilter cf2;
-		cf2 << TEST1_2_PAT;
+        ControlFilter cf2;
+        cf2 << TEST1_2_PAT;
 
-		ThreadFilter threadFilter;
-		ISO8601Filter iso8601Filter;
+        ThreadFilter threadFilter;
+        ISO8601Filter iso8601Filter;
 
-		std::vector<Filter*> filters1;
-		filters1.push_back(&cf1);
+        std::vector<Filter*> filters1;
+        filters1.push_back(&cf1);
 
-		std::vector<Filter*> filters2;
-		filters2.push_back(&cf2);
-		filters2.push_back(&threadFilter);
-		filters2.push_back(&iso8601Filter);
+        std::vector<Filter*> filters2;
+        filters2.push_back(&cf2);
+        filters2.push_back(&threadFilter);
+        filters2.push_back(&iso8601Filter);
 
-		try
-		{
-			Transformer::transform(TEMP_A1, FILTERED_A1, filters1);
-			Transformer::transform(TEMP_A2, FILTERED_A2, filters2);
-		}
-		catch (UnexpectedFormatException& e)
-		{
-			std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
-			throw;
-		}
+        try
+        {
+            Transformer::transform(TEMP_A1, FILTERED_A1, filters1);
+            Transformer::transform(TEMP_A2, FILTERED_A2, filters2);
+        }
+        catch (UnexpectedFormatException& e)
+        {
+            std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
+            throw;
+        }
 
-		const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.1"));
-		const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.1"));
-		// TODO: A1 doesn't contain duplicate entries
-		//
-		// LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
-		LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
-	}
+        const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.1"));
+        const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.1"));
+        // TODO: A1 doesn't contain duplicate entries
+        //
+        // LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
+        LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
+    }
 
-	//
-	// Same test but backslashes instead of forward
-	//
-	void test2()
-	{
-		DOMConfigurator::configure(LOG4CXX_TEST_STR("input\\xml\\DOMTestCase2.xml"));
-		common();
+    //
+    // Same test but backslashes instead of forward
+    //
+    void test2()
+    {
+        DOMConfigurator::configure(LOG4CXX_TEST_STR("input\\xml\\DOMTestCase2.xml"));
+        common();
 
-		ThreadFilter threadFilter;
-		ISO8601Filter iso8601Filter;
+        ThreadFilter threadFilter;
+        ISO8601Filter iso8601Filter;
 
-		std::vector<Filter*> filters1;
+        std::vector<Filter*> filters1;
 
-		std::vector<Filter*> filters2;
-		filters2.push_back(&threadFilter);
-		filters2.push_back(&iso8601Filter);
+        std::vector<Filter*> filters2;
+        filters2.push_back(&threadFilter);
+        filters2.push_back(&iso8601Filter);
 
-		try
-		{
-			Transformer::transform(TEMP_A1_2, FILTERED_A1_2, filters1);
-			Transformer::transform(TEMP_A2_2, FILTERED_A2_2, filters2);
-		}
-		catch (UnexpectedFormatException& e)
-		{
-			std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
-			throw;
-		}
+        try
+        {
+            Transformer::transform(TEMP_A1_2, FILTERED_A1_2, filters1);
+            Transformer::transform(TEMP_A2_2, FILTERED_A2_2, filters2);
+        }
+        catch (UnexpectedFormatException& e)
+        {
+            std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
+            throw;
+        }
 
-		const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.2"));
-		const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.2"));
-		// TODO: A1 doesn't contain duplicate entries
-		//
-		// LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
-		LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
-	}
+        const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.2"));
+        const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.2"));
+        // TODO: A1 doesn't contain duplicate entries
+        //
+        // LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
+        LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
+    }
 
 
-	void common()
-	{
-		int i = 0;
+    void common()
+    {
+        int i = 0;
 
-		LOG4CXX_DEBUG(logger, "Message " << i);
-		LOG4CXX_DEBUG(root, "Message " << i);
+        LOG4CXX_DEBUG(logger, "Message " << i);
+        LOG4CXX_DEBUG(root, "Message " << i);
 
-		i++;
-		LOG4CXX_INFO(logger, "Message " << i);
-		LOG4CXX_INFO(root, "Message " << i);
+        i++;
+        LOG4CXX_INFO(logger, "Message " << i);
+        LOG4CXX_INFO(root, "Message " << i);
 
-		i++;
-		LOG4CXX_WARN(logger, "Message " << i);
-		LOG4CXX_WARN(root, "Message " << i);
+        i++;
+        LOG4CXX_WARN(logger, "Message " << i);
+        LOG4CXX_WARN(root, "Message " << i);
 
-		i++;
-		LOG4CXX_ERROR(logger, "Message " << i);
-		LOG4CXX_ERROR(root, "Message " << i);
+        i++;
+        LOG4CXX_ERROR(logger, "Message " << i);
+        LOG4CXX_ERROR(root, "Message " << i);
 
-		i++;
-		LOG4CXX_FATAL(logger, "Message " << i);
-		LOG4CXX_FATAL(root, "Message " << i);
-	}
+        i++;
+        LOG4CXX_FATAL(logger, "Message " << i);
+        LOG4CXX_FATAL(root, "Message " << i);
+    }
 
-	/**
-	 * Creates a output file that ends with a superscript 3.
-	 * Output file is checked by build.xml after completion.
-	 */
-	void test3()
-	{
-		DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase3.xml"));
-		LOG4CXX_INFO(logger, "File name is expected to end with a superscript 3");
+    /**
+     * Creates a output file that ends with a superscript 3.
+     * Output file is checked by build.xml after completion.
+     */
+    void test3()
+    {
+        DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase3.xml"));
+        LOG4CXX_INFO(logger, "File name is expected to end with a superscript 3");
 #if LOG4CXX_LOGCHAR_IS_UTF8
-		const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xC2), static_cast<logchar>(0xB3), 0 };
+        const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xC2), static_cast<logchar>(0xB3), 0 };
 #else
-		const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xB3), 0 };
+        const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xB3), 0 };
 #endif
-		File file;
-		file.setPath(fname);
-		Pool p;
-		bool exists = file.exists(p);
-		LOGUNIT_ASSERT(exists);
-	}
+        File file;
+        file.setPath(fname);
+        Pool p;
+        bool exists = file.exists(p);
+        LOGUNIT_ASSERT(exists);
+    }
 
-	/**
-	 * Creates a output file that ends with a ideographic 4.
-	 * Output file is checked by build.xml after completion.
-	 */
-	void test4()
-	{
-		DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase4.xml"));
-		LOG4CXX_INFO(logger, "File name is expected to end with an ideographic 4");
+    /**
+     * Creates a output file that ends with a ideographic 4.
+     * Output file is checked by build.xml after completion.
+     */
+    void test4()
+    {
+        DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase4.xml"));
+        LOG4CXX_INFO(logger, "File name is expected to end with an ideographic 4");
 #if LOG4CXX_LOGCHAR_IS_UTF8
-		const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xE3), static_cast<logchar>(0x86), static_cast<logchar>(0x95), 0 };
+        const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xE3), static_cast<logchar>(0x86), static_cast<logchar>(0x95), 0 };
 #else
-		const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0x3195), 0 };
+        const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0x3195), 0 };
 #endif
-		File file;
-		file.setPath(fname);
-		Pool p;
-		bool exists = file.exists(p);
-		LOGUNIT_ASSERT(exists);
-	}
+        File file;
+        file.setPath(fname);
+        Pool p;
+        bool exists = file.exists(p);
+        LOGUNIT_ASSERT(exists);
+    }
 };
 
 LOGUNIT_TEST_SUITE_REGISTRATION(DOMTestCase);
diff --git a/src/test/cpp/xml/xmllayouttest.cpp b/src/test/cpp/xml/xmllayouttest.cpp
index 626ee22..6c4e1b8 100644
--- a/src/test/cpp/xml/xmllayouttest.cpp
+++ b/src/test/cpp/xml/xmllayouttest.cpp
@@ -274,9 +274,9 @@
 	void testFormat()
 	{
 		LogString logger = LOG4CXX_STR("org.apache.log4j.xml.XMLLayoutTest");
-		LoggingEventPtr event =
+        LoggingEventPtr event = LoggingEventPtr(
 			new LoggingEvent(
-			logger, Level::getInfo(), LOG4CXX_STR("Hello, World"), LOG4CXX_LOCATION);
+            logger, Level::getInfo(), LOG4CXX_STR("Hello, World"), LOG4CXX_LOCATION));
 		Pool p;
 		XMLLayout layout;
 		LogString result;
@@ -308,9 +308,9 @@
 		LogString logger = LOG4CXX_STR("org.apache.log4j.xml.XMLLayoutTest");
 		NDC::push("NDC goes here");
 
-		LoggingEventPtr event =
+        LoggingEventPtr event = LoggingEventPtr(
 			new LoggingEvent(
-			logger, Level::getInfo(), LOG4CXX_STR("Hello, World"), LOG4CXX_LOCATION);
+            logger, Level::getInfo(), LOG4CXX_STR("Hello, World"), LOG4CXX_LOCATION));
 		Pool p;
 		XMLLayout layout;
 		LogString result;
@@ -372,12 +372,12 @@
 	{
 		std::string problemName = "com.example.bar<>&\"'";
 		LogString problemNameLS = LOG4CXX_STR("com.example.bar<>&\"'");
-		LevelPtr level = new XLevel(6000, problemNameLS, 7);
+        LevelPtr level = LevelPtr(new XLevel(6000, problemNameLS, 7));
 		NDC::push(problemName);
 		MDC::clear();
 		MDC::put(problemName, problemName);
-		LoggingEventPtr event =
-			new LoggingEvent(problemNameLS, level, problemNameLS, LOG4CXX_LOCATION);
+        LoggingEventPtr event = LoggingEventPtr(
+            new LoggingEvent(problemNameLS, level, problemNameLS, LOG4CXX_LOCATION));
 		XMLLayout layout;
 		layout.setProperties(true);
 		Pool p;
@@ -428,9 +428,9 @@
 		LevelPtr level = Level::getInfo();
 		std::string ndcMessage = "<envelope><faultstring><![CDATA[The EffectiveDate]]></faultstring><envelope>";
 		NDC::push(ndcMessage);
-		LoggingEventPtr event =
+        LoggingEventPtr event = LoggingEventPtr(
 			new LoggingEvent(
-			logger, level, LOG4CXX_STR("Hello, World"), LOG4CXX_LOCATION);
+            logger, level, LOG4CXX_STR("Hello, World"), LOG4CXX_LOCATION));
 		XMLLayout layout;
 		Pool p;
 		LogString result;
diff --git a/src/test/cpp/xml/xmllayouttestcase.cpp b/src/test/cpp/xml/xmllayouttestcase.cpp
index de13ef2..bf1e5cb 100644
--- a/src/test/cpp/xml/xmllayouttestcase.cpp
+++ b/src/test/cpp/xml/xmllayouttestcase.cpp
@@ -90,7 +90,7 @@
 		const LogString tempFileName(LOG4CXX_STR("output/temp.xmlLayout.1"));
 		const File filteredFile("output/filtered.xmlLayout.1");
 
-		XMLLayoutPtr xmlLayout = new XMLLayout();
+        XMLLayoutPtr xmlLayout = XMLLayoutPtr(new XMLLayout());
 		AppenderPtr appender(new FileAppender(xmlLayout, tempFileName, false));
 		root->addAppender(appender);
 		common();
@@ -120,9 +120,9 @@
 		const LogString tempFileName(LOG4CXX_STR("output/temp.xmlLayout.2"));
 		const File filteredFile("output/filtered.xmlLayout.2");
 
-		XMLLayoutPtr xmlLayout = new XMLLayout();
+        XMLLayoutPtr xmlLayout = XMLLayoutPtr(new XMLLayout());
 		xmlLayout->setLocationInfo(true);
-		root->addAppender(new FileAppender(xmlLayout, tempFileName, false));
+        root->addAppender(AppenderPtr(new FileAppender(xmlLayout, tempFileName, false)));
 		common();
 
 		XMLTimestampFilter xmlTimestampFilter;
@@ -163,7 +163,7 @@
 		const LogString tempFileName(LOG4CXX_STR("output/temp.xmlLayout.3"));
 		const File filteredFile("output/filtered.xmlLayout.3");
 
-		XMLLayoutPtr xmlLayout = new XMLLayout();
+        XMLLayoutPtr xmlLayout = XMLLayoutPtr(new XMLLayout());
 		xmlLayout->setLocationInfo(true);
 		FileAppenderPtr appender(new FileAppender(xmlLayout, tempFileName, false));
 		root->addAppender(appender);
@@ -202,7 +202,7 @@
 		const LogString tempFileName(LOG4CXX_STR("output/temp.xmlLayout.null"));
 		const File filteredFile("output/filtered.xmlLayout.null");
 
-		XMLLayoutPtr xmlLayout = new XMLLayout();
+        XMLLayoutPtr xmlLayout = XMLLayoutPtr(new XMLLayout());
 		FileAppenderPtr appender(new FileAppender(xmlLayout, tempFileName, false));
 		root->addAppender(appender);
 
@@ -235,7 +235,7 @@
 		const LogString tempFileName(LOG4CXX_STR("output/temp.xmlLayout.mdc.1"));
 		const File filteredFile("output/filtered.xmlLayout.mdc.1");
 
-		XMLLayoutPtr xmlLayout = new XMLLayout();
+        XMLLayoutPtr xmlLayout = XMLLayoutPtr(new XMLLayout());
 		xmlLayout->setProperties(true);
 		FileAppenderPtr appender(new FileAppender(xmlLayout, tempFileName, false));
 		root->addAppender(appender);
@@ -274,7 +274,7 @@
 		const LogString tempFileName(LOG4CXX_STR("output/temp.xmlLayout.mdc.2"));
 		const File filteredFile("output/filtered.xmlLayout.mdc.2");
 
-		XMLLayoutPtr xmlLayout = new XMLLayout();
+        XMLLayoutPtr xmlLayout = XMLLayoutPtr(new XMLLayout());
 		xmlLayout->setProperties(true);
 		FileAppenderPtr appender(new FileAppender(xmlLayout, tempFileName, false));
 		root->addAppender(appender);