Fix several bugs of memory management and exception handling.
Fix wrong usage of boost::object_pool.