Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 441a0227f374ddeb6867c49eb47f973085dadd11)
+++ CMakeLists.txt	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -358,12 +358,6 @@
 	${NSCP_INCLUDEDIR}/utils.h
 	${NSCP_INCLUDEDIR}/NSCAPI.h
-#	${NSCP_INCLUDEDIR}/nscapi/macros.hpp
-	${NSCP_INCLUDEDIR}/nscapi/nscapi_helper.hpp
-	${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_wrapper.hpp	
-	${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.hpp
+	#${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_wrapper.hpp	
 	${NSCP_INCLUDEDIR}/settings/client/settings_client.hpp
-#	${NSCP_INCLUDEDIR}/nscapi/settings_proxy.hpp
-	${NSCP_INCLUDEDIR}/nscapi/macros.hpp
-	${NSCP_INCLUDEDIR}/nscapi/functions.hpp
 )
 
Index: build.cmake
===================================================================
--- build.cmake	(revision d48afa1dea8f818de11d50451a975ea31f153da1)
+++ build.cmake	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -36,5 +36,5 @@
 	SET(ARCHIVE_FOLDER "D:/archive")
 	
-	SET(TARGET_SITE "")
+	SET(TARGET_SITE "nscp@nsclient.org:/var/nsclient/www/files/nightly/;op5=mickem@home.medin.name:/home/nscp-dist/op5/nscp/;opsera=mickem@home.medin.name:/home/nscp-dist/opsera/nscp/")
 
 ELSE(WIN32)
Index: include/NSCAPI.h
===================================================================
--- include/NSCAPI.h	(revision 8013c0c69eb8c8810105e7655994c71fbd9bf105)
+++ include/NSCAPI.h	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -24,5 +24,5 @@
 #include <unicode_char.hpp>
 #include <string>
-#include <strEx.h>
+//#include <strEx.h>
 
 namespace NSCAPI {
@@ -125,14 +125,10 @@
 	class nscapi_exception : public std::exception {
 	public:
-		std::string msg_;
-		nscapi_exception(std::wstring msg) : msg_(utf8::cvt<std::string>(msg)) {}
-
+		std::string msg;
+		nscapi_exception(std::string msg) : msg(msg) {}
 
 		~nscapi_exception() throw() {}
 		const char* what() const throw() {
-			return msg_.c_str();
-		}
-		const std::wstring wwhat() const throw() {
-			return utf8::cvt<std::wstring>(msg_);
+			return msg.c_str();
 		}
 	};
Index: include/client/command_line_parser.hpp
===================================================================
--- include/client/command_line_parser.hpp	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ include/client/command_line_parser.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -7,5 +7,7 @@
 #include <boost/tuple/tuple.hpp>
 
-#include <nscapi/functions.hpp>
+#include <nscapi/nscapi_protobuf_types.hpp>
+
+#include <protobuf/plugin.pb.h>
 
 namespace client {
@@ -35,6 +37,6 @@
 		std::vector<std::wstring> arguments;
 
-		nscapi::functions::destination_container host_self;
-		nscapi::functions::destination_container recipient;
+		nscapi::protobuf::types::destination_container host_self;
+		nscapi::protobuf::types::destination_container recipient;
 
 		bool submit;
@@ -64,5 +66,5 @@
 
 	struct target_lookup_interface {
-		virtual nscapi::functions::destination_container lookup_target(std::wstring &id) = 0;
+		virtual nscapi::protobuf::types::destination_container lookup_target(std::wstring &id) = 0;
 	};
 	struct configuration /*: boost::noncopyable*/ {
@@ -172,5 +174,5 @@
 
 	private:
-		static void modify_header(configuration &config, ::Plugin::Common_Header* header, nscapi::functions::destination_container &recipient);
+		static void modify_header(configuration &config, ::Plugin::Common_Header* header, nscapi::protobuf::types::destination_container &recipient);
 	};
 }
Index: include/nrpe/client/socket.hpp
===================================================================
--- include/nrpe/client/socket.hpp	(revision 72eea1f23cecafb8201ac66e2ff2607a5482b2d0)
+++ include/nrpe/client/socket.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -4,5 +4,4 @@
 
 #include <socket/socket_helpers.hpp>
-//#include <nsca/nsca_packet.hpp>
 #include <iostream>
 
Index: include/nsca/nsca_socket.hpp
===================================================================
--- include/nsca/nsca_socket.hpp	(revision 523576eadf9e7b348291f0071b7260593ff2aacb)
+++ include/nsca/nsca_socket.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -33,5 +33,5 @@
 
 		virtual void connect(std::string host, std::string port) {
-			NSC_DEBUG_MSG(_T("Connecting to: ") + to_wstring(host) + _T(" (") + to_wstring(port) + _T(")"));
+			NSC_DEBUG_MSG(_T("Connecting to: ") + utf8::cvt<std::wstring>(host) + _T(" (") + utf8::cvt<std::wstring>(port) + _T(")"));
 			tcp::resolver resolver(io_service_);
 			tcp::resolver::query query(host, port);
@@ -45,5 +45,5 @@
 				socket_->close();
 				socket_->connect(*endpoint_iterator++, error);
-				NSC_DEBUG_MSG(_T("Connected to: ") + to_wstring(ep.address().to_string()));
+				NSC_DEBUG_MSG(_T("Connected to: ") + utf8::cvt<std::wstring>(ep.address().to_string()));
 			}
 			if (error) {
Index: include/nscapi/functions.hpp
===================================================================
--- include/nscapi/functions.hpp	(revision 523576eadf9e7b348291f0071b7260593ff2aacb)
+++ include/nscapi/functions.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -1,907 +1,5 @@
-/**************************************************************************
-*   Copyright (C) 2004-2007 by Michael Medin <michael@medin.name>         *
-*                                                                         *
-*   This code is part of NSClient++ - http://trac.nakednuns.org/nscp      *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU General Public License     *
-*   along with this program; if not, write to the                         *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
 #pragma once
+// For legacy use only, dont use!
 
-#include <boost/math/special_functions.hpp>
+#include <nscapi/nscapi_protobuf_functions.hpp>
 
-#include <string>
-#include <list>
-#include <set>
-#include <iostream>
-
-#include <NSCAPI.h>
-#include <charEx.h>
-//#include <arrayBuffer.h>
-#include <types.hpp>
-#include <net/net.hpp>
-#include <unicode_char.hpp>
-#include <strEx.h>
-#include <nscapi/settings_proxy.hpp>
-
-#include <protobuf/plugin.pb.h>
-
-using namespace nscp::helpers;
-
-namespace nscapi {
-
-	namespace traits {
-
-		template<class T>
-		struct perf_data_consts {
-			static const T get_valid_perf_numbers();
-			static const T get_replace_perf_coma_src();
-			static const T get_replace_perf_coma_tgt();
-		};
-
-		template<>
-		struct perf_data_consts<std::wstring> {
-			static const std::wstring get_valid_perf_numbers() {
-				return _T("0123456789,.");
-			}
-			static const std::wstring get_replace_perf_coma_src() {
-				return _T(",");
-			}
-			static const std::wstring get_replace_perf_coma_tgt() {
-				return _T(".");
-			}
-		};
-		template<>
-		struct perf_data_consts<std::string> {
-			static const std::string get_valid_perf_numbers() {
-				return "0123456789,.";
-			}
-			static const std::string get_replace_perf_coma_src() {
-				return ",";
-			}
-			static const std::string get_replace_perf_coma_tgt() {
-				return ".";
-			}
-		};
-	}
-	class functions {
-	public:
-		static Plugin::Common::ResultCode nagios_status_to_gpb(int ret) {
-			if (ret == NSCAPI::returnOK)
-				return Plugin::Common_ResultCode_OK;
-			if (ret == NSCAPI::returnWARN)
-				return Plugin::Common_ResultCode_WARNING;
-			if (ret == NSCAPI::returnCRIT)
-				return Plugin::Common_ResultCode_CRITCAL;
-			return Plugin::Common_ResultCode_UNKNOWN;
-		}
-		static int gbp_to_nagios_status(Plugin::Common::ResultCode ret) {
-			if (ret == Plugin::Common_ResultCode_OK)
-				return NSCAPI::returnOK;
-			if (ret == Plugin::Common_ResultCode_WARNING)
-				return NSCAPI::returnWARN;
-			if (ret == Plugin::Common_ResultCode_CRITCAL)
-				return NSCAPI::returnCRIT;
-			return NSCAPI::returnUNKNOWN;
-		}
-		static Plugin::Common::Status::StatusType status_to_gpb(int ret) {
-			if (ret == NSCAPI::isSuccess)
-				return Plugin::Common_Status_StatusType_OK;
-			return Plugin::Common_Status_StatusType_PROBLEM;
-		}
-		static int gbp_to_status(Plugin::Common::Status::StatusType ret) {
-			if (ret == Plugin::Common_Status_StatusType_OK)
-				return NSCAPI::isSuccess;
-			return NSCAPI::hasFailed;
-		}
-		static Plugin::Common::ResultCode gbp_status_to_gbp_nagios(Plugin::Common::Status::StatusType ret) {
-			if (ret == Plugin::Common_Status_StatusType_OK)
-				return Plugin::Common_ResultCode_OK;
-			return Plugin::Common_ResultCode_UNKNOWN;
-		}
-		static Plugin::Common::Status::StatusType gbp_to_nagios_gbp_status(Plugin::Common::ResultCode ret) {
-			if (ret == Plugin::Common_ResultCode_UNKNOWN||ret == Plugin::Common_ResultCode_WARNING||ret == Plugin::Common_ResultCode_CRITCAL)
-				return Plugin::Common_Status_StatusType_CRITICAL;
-			return Plugin::Common_Status_StatusType_OK;
-		}
-		
-		static Plugin::LogEntry::Entry::Level log_to_gpb(NSCAPI::messageTypes ret) {
-			if (ret == NSCAPI::log_level::critical)
-				return Plugin::LogEntry_Entry_Level_LOG_CRITICAL;
-			if (ret == NSCAPI::log_level::debug)
-				return Plugin::LogEntry_Entry_Level_LOG_DEBUG;
-			if (ret == NSCAPI::log_level::error)
-				return Plugin::LogEntry_Entry_Level_LOG_ERROR;
-			if (ret == NSCAPI::log_level::log)
-				return Plugin::LogEntry_Entry_Level_LOG_INFO;
-			if (ret == NSCAPI::log_level::info)
-				return Plugin::LogEntry_Entry_Level_LOG_INFO;
-			if (ret == NSCAPI::log_level::warning)
-				return Plugin::LogEntry_Entry_Level_LOG_WARNING;
-			return Plugin::LogEntry_Entry_Level_LOG_ERROR;
-		}
-		static NSCAPI::messageTypes gpb_to_log(Plugin::LogEntry::Entry::Level ret) {
-			if (ret == Plugin::LogEntry_Entry_Level_LOG_CRITICAL)
-				return NSCAPI::log_level::critical;
-			if (ret == Plugin::LogEntry_Entry_Level_LOG_DEBUG)
-				return NSCAPI::log_level::debug;
-			if (ret == Plugin::LogEntry_Entry_Level_LOG_ERROR)
-				return NSCAPI::log_level::error;
-			if (ret == Plugin::LogEntry_Entry_Level_LOG_INFO)
-				return NSCAPI::log_level::info;
-			if (ret == Plugin::LogEntry_Entry_Level_LOG_WARNING)
-				return NSCAPI::log_level::warning;
-			return NSCAPI::log_level::error;
-		}
-
-
-		template<class T>
-		static double trim_to_double(T s) {
-			typename T::size_type pend = s.find_first_not_of(nscapi::traits::perf_data_consts<T>::get_valid_perf_numbers());
-			if (pend != T::npos)
-				s = s.substr(0,pend);
-			strEx::replace(s, nscapi::traits::perf_data_consts<T>::get_replace_perf_coma_src(), nscapi::traits::perf_data_consts<T>::get_replace_perf_coma_tgt());
-			return strEx::stod(s);
-		}
-
-		
-
-		struct decoded_simple_command_data {
-			std::wstring command;
-			std::wstring target;
-			std::list<std::wstring> args;
-			//std::vector<std::wstring> args_vector;
-		};
-
-
-
-		static void create_simple_header(Plugin::Common::Header* hdr)  {
-			hdr->set_version(Plugin::Common_Version_VERSION_1);
-			hdr->set_max_supported_version(Plugin::Common_Version_VERSION_1);
-			// @todo add additional fields here!
-		}
-
-		//////////////////////////////////////////////////////////////////////////
-
-		struct destination_container {
-			std::string id;
-			net::url address;
-			std::string comment;
-			std::set<std::string> tags;
-			typedef std::map<std::string,std::string> data_map;
-			data_map data;
-			void set_host(std::string value) {
-				address.host = value;
-			}
-			void set_address(std::string value) {
-				address = net::parse(value);
-			}
-			void set_port(std::string value) {
-				address.port = strEx::stoi(value);
-			}
-			std::string get_protocol() const {
-				return address.protocol;
-			}
-			bool has_protocol() const {
-				return !address.protocol.empty();
-			}
-			/*
-			net::url get_url(unsigned int port = 80) const {
-				return net::parse(address, port);
-			}
-			*/
-			static bool to_bool(std::string value, bool def = false) {
-				if (value.empty())
-					return def;
-				if (value == "true" || value == "1" || value == "True")
-					return true;
-				return false;
-			}
-			static int to_int(std::string value, int def = 0) {
-				if (value.empty())
-					return def;
-				try {
-					return boost::lexical_cast<int>(value);
-				} catch (...) {
-					return def;
-				}
-			}
-
-			inline int get_int_data(std::string key, int def = 0) {
-				return to_int(data[key], def);
-			}
-			inline bool get_bool_data(std::string key, bool def = false) {
-				return to_bool(data[key], def);
-			}
-			inline std::string get_string_data(std::string key, std::string def = "") {
-				data_map::iterator it = data.find(key);
-				if (it == data.end())
-					return def;
-				return it->second;
-			}
-			inline bool has_data(std::string key) {
-				return data.find(key) != data.end();
-			}
-
-			/*
-			inline net::url get_url(int default_port) {
-				return net::parse(address, default_port);
-			}
-			*/
-			void set_string_data(std::string key, std::string value) {
-				if (key == "host")
-					set_host(value);
-				else 
-					data[key] = value;
-			}
-			void set_int_data(std::string key, int value) {
-				if (key == "port")
-					address.port = value;
-				else 
-					data[key] = boost::lexical_cast<std::string>(value);
-			}
-			void set_bool_data(std::string key, bool value) {
-				data[key] = value?"true":"false";
-			}
-
-			std::string to_string() {
-				std::stringstream ss;
-				ss << "id: " << id;
-				ss << ", address: " << address.to_string();
-				ss << ", comment: " << comment;
-				int i=0;
-				BOOST_FOREACH(std::string a, tags) {
-					ss << ", tags[" << i++ << "]: " << a;
-				}
-				BOOST_FOREACH(const data_map::value_type &kvp, data) {
-					ss << ", data[" << kvp.first << "]: " << kvp.second;
-				}
-				return ss.str();
-			}
-
-			void import(const destination_container &other) {
-				if (id.empty() && !other.id.empty())
-					id = other.id;
-				address.import(other.address);
-				if (comment.empty() && !other.comment.empty())
-					comment = other.comment;
-				BOOST_FOREACH(const std::string &t, other.tags) {
-					tags.insert(t);
-				}
-				BOOST_FOREACH(const data_map::value_type &kvp, other.data) {
-					if (data.find(kvp.first) == data.end())
-						data[kvp.first] = kvp.second;
-				}
-			}
-			void apply(const destination_container &other) {
-				if (!other.id.empty())
-					id = other.id;
-				address.apply(other.address);
-				if (!other.comment.empty())
-					comment = other.comment;
-				BOOST_FOREACH(const std::string &t, other.tags) {
-					tags.insert(t);
-				}
-				BOOST_FOREACH(const data_map::value_type &kvp, other.data) {
-					data[kvp.first] = kvp.second;
-				}
-			}
-		};
-
-		static void add_host(Plugin::Common::Header* hdr, const destination_container &dst)  {
-			::Plugin::Common::Host *host = hdr->add_hosts();
-			if (!dst.id.empty())
-				host->set_id(dst.id);
-			if (!dst.address.host.empty())
-				host->set_address(dst.address.to_string());
- 			if (!dst.has_protocol())
- 				host->set_protocol(dst.get_protocol());
-			if (!dst.comment.empty())
-				host->set_comment(dst.comment);
-			BOOST_FOREACH(const std::string &t, dst.tags) {
-				host->add_tags(t);
-			}
-			BOOST_FOREACH(const destination_container::data_map::value_type &kvp, dst.data) {
-				::Plugin::Common_KeyValue* x = host->add_metadata();
-				x->set_key(kvp.first);
-				x->set_value(kvp.second);
-			}
-		}
-
-		static bool parse_destination(const ::Plugin::Common_Header &header, const std::string tag, destination_container &data, const bool expand_meta = false) {
-			for (int i=0;i<header.hosts_size();++i) {
-				const ::Plugin::Common::Host &host = header.hosts(i);
-				if (host.id() == tag) {
-					data.id = tag;
-					if (!host.address().empty())
-						data.address.import(net::parse(host.address()));
-					if (!host.comment().empty())
-						data.comment = host.comment();
-					if (expand_meta) {
-						for(int j=0;j<host.tags_size(); ++j) {
-							data.tags.insert(host.tags(j));
-						}
-						for(int j=0;j<host.metadata_size(); ++j) {
-							data.data[host.metadata(j).key()] = host.metadata(j).value();
-						}
-					}
-					return true;
-				}
-			}
-			return false;
-		}
-
-		//////////////////////////////////////////////////////////////////////////
-
-		static void make_submit_from_query(std::string &message, const std::wstring channel, const std::wstring alias = _T(""), const std::wstring target = _T("")) {
-			Plugin::QueryResponseMessage response;
-			response.ParseFromString(message);
-			Plugin::SubmitRequestMessage request;
-			request.mutable_header()->CopyFrom(response.header());
-			request.mutable_header()->set_source_id(request.mutable_header()->recipient_id());
-			request.set_channel(to_string(channel));
-			if (!target.empty()) {
-				request.mutable_header()->set_recipient_id(to_string(target));
-			}
-			for (int i=0;i<response.payload_size();++i) {
-				request.add_payload()->CopyFrom(response.payload(i));
-				if (!alias.empty())
-					request.mutable_payload(i)->set_alias(to_string(alias));
-			}
-			message = request.SerializeAsString();
-		}
-
-		static void make_query_from_exec(std::string &data) {
-			Plugin::ExecuteResponseMessage exec_response_message;
-			exec_response_message.ParseFromString(data);
-			Plugin::QueryResponseMessage query_response_message;
-			query_response_message.mutable_header()->CopyFrom(exec_response_message.header());
-			for (int i=0;i<exec_response_message.payload_size();++i) {
-				Plugin::ExecuteResponseMessage::Response p = exec_response_message.payload(i);
-				append_simple_query_response_payload(query_response_message.add_payload(), p.command(), p.result(), p.message());
-			}
-			data = query_response_message.SerializeAsString();
-		}
-		static void make_query_from_submit(std::string &data) {
-			Plugin::SubmitResponseMessage submit_response_message;
-			submit_response_message.ParseFromString(data);
-			Plugin::QueryResponseMessage query_response_message;
-			query_response_message.mutable_header()->CopyFrom(submit_response_message.header());
-			for (int i=0;i<submit_response_message.payload_size();++i) {
-				Plugin::SubmitResponseMessage::Response p = submit_response_message.payload(i);
-				append_simple_query_response_payload(query_response_message.add_payload(), p.command(), gbp_status_to_gbp_nagios(p.status().status()), p.status().message(), "");
-			}
-			data = query_response_message.SerializeAsString();
-		}
-
-		static void make_exec_from_submit(std::string &data) {
-			Plugin::SubmitResponseMessage submit_response_message;
-			submit_response_message.ParseFromString(data);
-			Plugin::ExecuteResponseMessage exec_response_message;
-			exec_response_message.mutable_header()->CopyFrom(submit_response_message.header());
-			for (int i=0;i<submit_response_message.payload_size();++i) {
-				Plugin::SubmitResponseMessage::Response p = submit_response_message.payload(i);
-				append_simple_exec_response_payload(exec_response_message.add_payload(), p.command(), gbp_status_to_gbp_nagios(p.status().status()), p.status().message());
-			}
-			data = exec_response_message.SerializeAsString();
-		}
-		static void make_exec_from_query(std::string &data) {
-			Plugin::QueryResponseMessage query_response_message;
-			query_response_message.ParseFromString(data);
-			Plugin::ExecuteResponseMessage exec_response_message;
-			exec_response_message.mutable_header()->CopyFrom(query_response_message.header());
-			for (int i=0;i<query_response_message.payload_size();++i) {
-				Plugin::QueryResponseMessage::Response p = query_response_message.payload(i);
-				std::string s = build_performance_data(p);
-				if (!s.empty())
-					s = p.message() + "|" + s;
-				else
-					s = p.message();
-				append_simple_exec_response_payload(exec_response_message.add_payload(), p.command(), p.result(), s);
-			}
-			data = exec_response_message.SerializeAsString();
-		}
-
-
-		static void make_return_header(::Plugin::Common_Header *target, const ::Plugin::Common_Header &source) {
-			target->CopyFrom(source);
-			target->set_source_id(target->recipient_id());
-		}
-
-		static void create_simple_query_request(std::wstring command, std::vector<std::wstring> arguments, std::string &buffer) {
-			Plugin::QueryRequestMessage message;
-			create_simple_header(message.mutable_header());
-
-			Plugin::QueryRequestMessage::Request *payload = message.add_payload();
-			payload->set_command(to_string(command));
-
-			BOOST_FOREACH(std::wstring s, arguments)
-				payload->add_arguments(to_string(s));
-
-			message.SerializeToString(&buffer);
-		}
-
-		static void create_simple_submit_request(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf, std::string &buffer) {
-			Plugin::SubmitRequestMessage message;
-			create_simple_header(message.mutable_header());
-			message.set_channel(to_string(channel));
-
-			Plugin::QueryResponseMessage::Response *payload = message.add_payload();
-			payload->set_command(to_string(command));
-			payload->set_message(to_string(msg));
-			payload->set_result(nagios_status_to_gpb(ret));
-			if (!perf.empty())
-				parse_performance_data(payload, perf);
-
-			message.SerializeToString(&buffer);
-		}
-		static void create_simple_submit_response(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::string &buffer) {
-			Plugin::SubmitResponseMessage message;
-			create_simple_header(message.mutable_header());
-			//message.set_channel(to_string(channel));
-
-			Plugin::SubmitResponseMessage::Response *payload = message.add_payload();
-			payload->set_command(utf8::cvt<std::string>(command));
-			payload->mutable_status()->set_message(to_string(msg));
-			payload->mutable_status()->set_status(status_to_gpb(ret));
-			message.SerializeToString(&buffer);
-		}
-		static NSCAPI::errorReturn parse_simple_submit_request(const std::string &request, std::wstring &source, std::wstring &command, std::wstring &msg, std::wstring &perf) {
-			Plugin::SubmitRequestMessage message;
-			message.ParseFromString(request);
-
-			if (message.payload_size() != 1) {
-				throw nscapi_exception(_T("Whoops, invalid payload size (for now)"));
-			}
-			Plugin::QueryResponseMessage::Response payload = message.payload().Get(0);
-			source = utf8::cvt<std::wstring>(payload.source());
-			command = utf8::cvt<std::wstring>(payload.command());
-			msg = utf8::cvt<std::wstring>(payload.message());
-			perf = utf8::cvt<std::wstring>(build_performance_data(payload));
-			return gbp_to_nagios_status(payload.result());
-		}
-		/*
-		static NSCAPI::errorReturn parse_simple_submit_request_payload(const Plugin::QueryResponseMessage::Response &payload, std::wstring &alias, std::wstring &command, std::wstring &msg, std::wstring &perf) {
-			alias = utf8::cvt<std::wstring>(payload.alias());
-			command = utf8::cvt<std::wstring>(payload.command());
-			msg = utf8::cvt<std::wstring>(payload.message());
-			perf = utf8::cvt<std::wstring>(build_performance_data(payload));
-			return gbp_to_nagios_status(payload.result());
-		}
-		*/
-		static int parse_simple_submit_request_payload(const Plugin::QueryResponseMessage::Response &payload, std::wstring &alias, std::wstring &message) {
-			alias = utf8::cvt<std::wstring>(payload.alias());
-			if (alias.empty())
-				alias = utf8::cvt<std::wstring>(payload.command());
-			message = utf8::cvt<std::wstring>(payload.message());
-			return gbp_to_nagios_status(payload.result());
-		}
-		static void parse_simple_query_request_payload(const Plugin::QueryRequestMessage::Request &payload, std::wstring &alias, std::wstring &command) {
-			alias = utf8::cvt<std::wstring>(payload.alias());
-			command = utf8::cvt<std::wstring>(payload.command());
-		}
-		static NSCAPI::errorReturn parse_simple_submit_response(const std::string &request, std::wstring &response) {
-			Plugin::SubmitResponseMessage message;
-			message.ParseFromString(request);
-
-			if (message.payload_size() != 1) {
-				throw nscapi_exception(_T("Whoops, invalid payload size (for now)"));
-			}
-			::Plugin::SubmitResponseMessage::Response payload = message.payload().Get(0);
-			response = to_wstring(payload.mutable_status()->message());
-			return gbp_to_status(payload.mutable_status()->status());
-		}
-		static NSCAPI::errorReturn parse_simple_submit_response(const std::string &request, std::string response) {
-			Plugin::SubmitResponseMessage message;
-			message.ParseFromString(request);
-
-			if (message.payload_size() != 1) {
-				throw nscapi_exception(_T("Whoops, invalid payload size (for now)"));
-			}
-			::Plugin::SubmitResponseMessage::Response payload = message.payload().Get(0);
-			response = payload.mutable_status()->message();
-			return gbp_to_status(payload.mutable_status()->status());
-		}
-		/*
-		static void create_simple_submit_response(std::wstring msg, int status, std::string &buffer) {
-			Plugin::SubmitResponseMessage message;
-			create_simple_header(message.mutable_header());
-
-			Plugin::SubmitResponseMessage::Response *payload = message.add_payload();
-			payload->mutable_status()->set_message(to_string(msg));
-			payload->mutable_status()->set_status(status_to_gpb(status));
-
-			message.SerializeToString(&buffer);
-		}*/
-
-		static void create_simple_query_request(std::wstring command, std::list<std::wstring> arguments, std::string &buffer) {
-			Plugin::QueryRequestMessage message;
-			create_simple_header(message.mutable_header());
-
-			Plugin::QueryRequestMessage::Request *payload = message.add_payload();
-			payload->set_command(to_string(command));
-
-			BOOST_FOREACH(std::wstring s, arguments)
-				payload->add_arguments(to_string(s));
-
-			message.SerializeToString(&buffer);
-		}
-		static NSCAPI::nagiosReturn create_simple_query_response_unknown(std::wstring command, std::wstring msg, std::wstring perf, std::string &buffer) {
-			create_simple_query_response(command, NSCAPI::returnUNKNOWN, msg, perf, buffer);
-			return NSCAPI::returnUNKNOWN;
-		}
-		static NSCAPI::nagiosReturn create_simple_query_response_unknown(std::wstring command, std::wstring msg, std::string &buffer) {
-			create_simple_query_response(command, NSCAPI::returnUNKNOWN, msg, _T(""), buffer);
-			return NSCAPI::returnUNKNOWN;
-		}
-
-		static void create_simple_query_response(std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf, std::string &buffer) {
-			Plugin::QueryResponseMessage message;
-			create_simple_header(message.mutable_header());
-
-			append_simple_query_response_payload(message.add_payload(), command, ret, msg, perf);
-
-			message.SerializeToString(&buffer);
-		}
-
-		
-		static void append_simple_submit_request_payload(Plugin::QueryResponseMessage::Response *payload, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf = _T("")) {
-			payload->set_command(to_string(command));
-			payload->set_message(to_string(msg));
-			payload->set_result(nagios_status_to_gpb(ret));
-			if (!perf.empty())
-				parse_performance_data(payload, perf);
-		}
-
-		static void append_simple_query_response_payload(Plugin::QueryResponseMessage::Response *payload, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf) {
-			payload->set_command(to_string(command));
-			payload->set_message(to_string(msg));
-			payload->set_result(nagios_status_to_gpb(ret));
-			if (!perf.empty())
-				parse_performance_data(payload, perf);
-		}
-
-		template<class T>
-		static void append_response_payloads(T &target_message, std::string &payload) {
-			T source_message;
-			source_message.ParseFromString(payload);
-			for (int i=0;i<source_message.payload_size();++i)
-				target_message.add_payload()->CopyFrom(source_message.payload(i));
-		}
-
-		static void append_simple_query_response_payload(Plugin::QueryResponseMessage::Response *payload, std::string command, NSCAPI::nagiosReturn ret, std::string msg, std::string perf = "") {
-			payload->set_command(to_string(command));
-			payload->set_message(to_string(msg));
-			payload->set_result(nagios_status_to_gpb(ret));
-			if (!perf.empty())
-				parse_performance_data(payload, perf);
-		}
-/*
-		static void append_simple_exec_response_payload(Plugin::ExecuteResponseMessage::Response *payload, std::string command, Plugin::Common::ResultCode ret, std::string msg) {
-			payload->set_command(command);
-			payload->set_message(msg);
-			payload->set_result(ret);
-		}
-		*/
-		static void append_simple_exec_response_payload(Plugin::ExecuteResponseMessage::Response *payload, std::string command, int ret, std::string msg) {
-			payload->set_command(command);
-			payload->set_message(msg);
-			payload->set_result(nagios_status_to_gpb(ret));
-		}
-		/*
-		static void append_simple_submit_response_payload(Plugin::SubmitResponseMessage::Response *payload, std::string command, Plugin::Common::ResultCode ret, std::string msg) {
-			payload->set_command(command);
-			payload->mutable_status()->set_status(gbp_to_nagios_gbp_status(ret));
-			payload->mutable_status()->set_message(msg);
-		}
-		*/
-		static void append_simple_submit_response_payload(Plugin::SubmitResponseMessage::Response *payload, std::string command, int ret, std::string msg) {
-			payload->set_command(command);
-			payload->mutable_status()->set_status(status_to_gpb(ret));
-			payload->mutable_status()->set_message(msg);
-		}
-
-
-		static void append_simple_query_request_payload(Plugin::QueryRequestMessage::Request *payload, std::wstring command, std::vector<std::wstring> arguments) {
-			payload->set_command(to_string(command));
-			BOOST_FOREACH(const std::wstring &s, arguments) {
-				payload->add_arguments(to_string(s));
-			}
-		}
-
-		static void append_simple_exec_request_payload(Plugin::ExecuteRequestMessage::Request *payload, std::wstring command, std::vector<std::wstring> arguments) {
-			payload->set_command(to_string(command));
-			BOOST_FOREACH(const std::wstring &s, arguments) {
-				payload->add_arguments(to_string(s));
-			}
-		}
-
-
-		static decoded_simple_command_data parse_simple_query_request(const wchar_t* char_command, const std::string &request) {
-			decoded_simple_command_data data;
-
-			data.command = char_command;
-			Plugin::QueryRequestMessage message;
-			message.ParseFromString(request);
-
-			if (message.payload_size() != 1) {
-				throw nscapi_exception(_T("Whoops, invalid payload size (for now)"));
-			}
-			::Plugin::QueryRequestMessage::Request payload = message.payload().Get(0);
-			for (int i=0;i<payload.arguments_size();i++) {
-				data.args.push_back(to_wstring(payload.arguments(i)));
-			}
-			return data;
-		}
-		static decoded_simple_command_data parse_simple_query_request(const ::Plugin::QueryRequestMessage::Request &payload) {
-			decoded_simple_command_data data;
-			data.command = utf8::cvt<std::wstring>(payload.command());
-			for (int i=0;i<payload.arguments_size();i++) {
-				data.args.push_back(utf8::cvt<std::wstring>(payload.arguments(i)));
-			}
-			return data;
-		}
-
-		static int parse_simple_query_response(const std::string &response, std::wstring &msg, std::wstring &perf) {
-			Plugin::QueryResponseMessage message;
-			message.ParseFromString(response);
-
-
-			if (message.payload_size() == 0) {
-				return NSCAPI::returnUNKNOWN;
-			} else if (message.payload_size() > 1) {
-				throw nscapi_exception(_T("Whoops, invalid payload size (for now)"));
-			}
-
-			Plugin::QueryResponseMessage::Response payload = message.payload().Get(0);
-			msg = utf8::cvt<std::wstring>(payload.message());
-			perf = utf8::cvt<std::wstring>(build_performance_data(payload));
-			return gbp_to_nagios_status(payload.result());
-		}
-
-
-		//////////////////////////////////////////////////////////////////////////
-
-		static void create_simple_exec_request(const std::wstring &command, const std::list<std::wstring> & args, std::string &request) {
-			
-			Plugin::ExecuteRequestMessage message;
-			create_simple_header(message.mutable_header());
-
-			Plugin::ExecuteRequestMessage::Request *payload = message.add_payload();
-			payload->set_command(to_string(command));
-
-			BOOST_FOREACH(std::wstring s, args)
-				payload->add_arguments(to_string(s));
-
-			message.SerializeToString(&request);
-		}
-		static void create_simple_exec_request(const std::wstring &command, const std::vector<std::wstring> & args, std::string &request) {
-
-			Plugin::ExecuteRequestMessage message;
-			create_simple_header(message.mutable_header());
-
-			Plugin::ExecuteRequestMessage::Request *payload = message.add_payload();
-			payload->set_command(to_string(command));
-
-			BOOST_FOREACH(std::wstring s, args)
-				payload->add_arguments(to_string(s));
-
-			message.SerializeToString(&request);
-		}
-		static void parse_simple_exec_result(const std::string &response, std::list<std::wstring> &result) {
-			Plugin::ExecuteResponseMessage message;
-			message.ParseFromString(response);
-
-			for (int i=0;i<message.payload_size(); i++) {
-				result.push_back(utf8::cvt<std::wstring>(message.payload(i).message()));
-			}
-		}
-		static void parse_simple_exec_result(const std::string &response, std::wstring &result) {
-			Plugin::ExecuteResponseMessage message;
-			message.ParseFromString(response);
-
-			for (int i=0;i<message.payload_size(); i++) {
-				result += utf8::cvt<std::wstring>(message.payload(i).message());
-			}
-		}
-
-		template<class T>
-		static int create_simple_exec_response(T command, NSCAPI::nagiosReturn ret, T result, std::string &response) {
-			Plugin::ExecuteResponseMessage message;
-			create_simple_header(message.mutable_header());
-
-			Plugin::ExecuteResponseMessage::Response *payload = message.add_payload();
-			payload->set_command(to_string(command));
-			payload->set_message(to_string(result));
-
-			payload->set_result(nagios_status_to_gpb(ret));
-			message.SerializeToString(&response);
-			return ret;
-		}
-		template<class T>
-		static int create_simple_exec_response_unknown(T command, T result, std::string &response) {
-			Plugin::ExecuteResponseMessage message;
-			create_simple_header(message.mutable_header());
-
-			Plugin::ExecuteResponseMessage::Response *payload = message.add_payload();
-			payload->set_command(to_string(command));
-			payload->set_message(to_string(result));
-
-			payload->set_result(nagios_status_to_gpb(NSCAPI::returnUNKNOWN));
-			message.SerializeToString(&response);
-			return NSCAPI::returnUNKNOWN;
-		}
-		static decoded_simple_command_data parse_simple_exec_request(const wchar_t* char_command, const std::string &request) {
-			Plugin::ExecuteRequestMessage message;
-			message.ParseFromString(request);
-
-			return parse_simple_exec_request(char_command, message);
-		}
-		static decoded_simple_command_data parse_simple_exec_request(const std::wstring cmd, const Plugin::ExecuteRequestMessage &message) {
-			decoded_simple_command_data data;
-			data.command = cmd;
-			if (message.has_header())
-				data.target = utf8::cvt<std::wstring>(message.header().recipient_id());
-
-			if (message.payload_size() != 1) {
-				throw nscapi_exception(_T("Whoops, invalid payload size (for now)"));
-			}
-			Plugin::ExecuteRequestMessage::Request payload = message.payload().Get(0);
-			for (int i=0;i<payload.arguments_size();i++) {
-				data.args.push_back(to_wstring(payload.arguments(i)));
-			}
-			return data;
-		}
-		static decoded_simple_command_data parse_simple_exec_request_payload(const Plugin::ExecuteRequestMessage::Request &payload) {
-			decoded_simple_command_data data;
-			data.command = utf8::cvt<std::wstring>(payload.command());
-			for (int i=0;i<payload.arguments_size();i++) {
-				data.args.push_back(utf8::cvt<std::wstring>(payload.arguments(i)));
-			}
-			return data;
-		}
-
-
-		//////////////////////////////////////////////////////////////////////////
-
-		template<class T>
-		struct tokenizer_data {
-			T perf_lable_enclosure;						// '
-			T perf_separator;							// ' '
-			T perf_item_splitter;						// ; 
-			T perf_equal_sign;							// =
-			T perf_valid_number;						// 0123456789.,
-
-		};
-
-		template<class T>
-		static void parse_performance_data(Plugin::QueryResponseMessage::Response *payload, T &perf, tokenizer_data<T> tokenizer_data) {
-			while (true) {
-				if (perf.size() == 0)
-					return;
-				typename T::size_type p = 0;
-				if (perf[0] == tokenizer_data.perf_lable_enclosure[0]) {
-					p = perf.find(tokenizer_data.perf_lable_enclosure[0], 1)+1;
-					if (p == T::npos)
-						return;
-				}
-				p = perf.find(tokenizer_data.perf_separator, p);
-				if (p == 0)
-					return;
-				T chunk;
-				if (p == T::npos) {
-					chunk = perf;
-					perf = T();
-				} else {
-					chunk = perf.substr(0, p);
-					p = perf.find_first_not_of(tokenizer_data.perf_separator, p);
-					perf = perf.substr(p);
-				}
-				std::vector<T> items = strEx::splitV(chunk, tokenizer_data.perf_item_splitter);
-				if (items.size() < 1) {
-					Plugin::Common::PerformanceData* perfData = payload->add_perf();
-					perfData->set_type(Plugin::Common_DataType_STRING);
-					std::pair<T,T> fitem = strEx::split(T(), tokenizer_data.perf_equal_sign);
-					perfData->set_alias("invalid");
-					Plugin::Common_PerformanceData_StringValue* stringPerfData = perfData->mutable_string_value();
-					stringPerfData->set_value("invalid performance data");
-					break;
-				}
-
-				Plugin::Common::PerformanceData* perfData = payload->add_perf();
-				perfData->set_type(Plugin::Common_DataType_FLOAT);
-				std::pair<T,T> fitem = strEx::split(items[0], tokenizer_data.perf_equal_sign);
-				T alias = fitem.first;
-				if (alias.size() > 0 && alias[0] == tokenizer_data.perf_lable_enclosure[0] && alias[alias.size()-1] == tokenizer_data.perf_lable_enclosure[0])
-					alias = alias.substr(1, alias.size()-2);
-					
-				perfData->set_alias(to_string(alias));
-				Plugin::Common_PerformanceData_FloatValue* floatPerfData = perfData->mutable_float_value();
-
-				typename T::size_type pend = fitem.second.find_first_not_of(tokenizer_data.perf_valid_number);
-				if (pend == T::npos) {
-					floatPerfData->set_value(trim_to_double(fitem.second));
-				} else {
-					floatPerfData->set_value(trim_to_double(fitem.second.substr(0,pend)));
-					floatPerfData->set_unit(to_string(fitem.second.substr(pend)));
-				}
-				if (items.size() > 2) {
-					floatPerfData->set_warning(trim_to_double(items[1]));
-					floatPerfData->set_critical(trim_to_double(items[2]));
-				}
-				if (items.size() >= 5) {
-					floatPerfData->set_minimum(trim_to_double(items[3]));
-					floatPerfData->set_maximum(trim_to_double(items[4]));
-				}
-			}
-		}
-		static void parse_performance_data(Plugin::QueryResponseMessage::Response *payload, std::wstring &perf) {
-			typedef std::wstring t_string;
-			typedef wchar_t t_char;
-			tokenizer_data<t_string> data;
-			data.perf_separator = _T(" ");
-			data.perf_lable_enclosure = _T("'");
-			data.perf_equal_sign = _T("=");
-			data.perf_item_splitter = _T(";");
-			data.perf_valid_number = _T("0123456789,.");
-			parse_performance_data<t_string>(payload, perf, data);
-		}
-		static void parse_performance_data(Plugin::QueryResponseMessage::Response *payload, std::string &perf) {
-			typedef std::string t_string;
-			typedef char t_char;
-			tokenizer_data<t_string> data;
-			data.perf_separator = " ";
-			data.perf_lable_enclosure = "'";
-			data.perf_equal_sign = "=";
-			data.perf_item_splitter = ";";
-			data.perf_valid_number = "0123456789,.";
-			parse_performance_data<t_string>(payload, perf, data);
-		}
-
-		static std::string build_performance_data(Plugin::QueryResponseMessage::Response const &payload) {
-			std::stringstream ss;
-			ss.precision(5);
-
-			bool first = true;
-			for (int i=0;i<payload.perf_size();i++) {
-				Plugin::Common::PerformanceData perfData = payload.perf(i);
-				if (!first)
-					ss << " ";
-				first = false;
-				ss << '\'' << perfData.alias() << "'=";
-				if (perfData.has_float_value()) {
-					Plugin::Common_PerformanceData_FloatValue fval = perfData.float_value();
-
-					ss << strEx::s::itos_non_sci(fval.value());
-					if (fval.has_unit())
-						ss << fval.unit();
-					if (!fval.has_warning())
-						continue;
-					ss << ";" << fval.warning();
-					if (!fval.has_critical())	
-						continue;
-					ss << ";" << fval.critical();
-					if (!fval.has_minimum())
-						continue;
-					ss << ";" << fval.minimum();
-					if (!fval.has_maximum())
-						continue;
-					ss << ";" << fval.maximum();
-				}
-			}
-			return ss.str();
-		}
-	};
-}
Index: include/nscapi/nscapi_core_wrapper.cpp
===================================================================
--- include/nscapi/nscapi_core_wrapper.cpp	(revision 8013c0c69eb8c8810105e7655994c71fbd9bf105)
+++ include/nscapi/nscapi_core_wrapper.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -20,35 +20,19 @@
 ***************************************************************************/
 
-#include <boost/foreach.hpp>
-#include <boost/tokenizer.hpp>
+#include <iostream>
+
+#include <nscapi/nscapi_core_wrapper.hpp>
+#include <nscapi/nscapi_helper.hpp>
+#include <nscapi/nscapi_protobuf_functions.hpp>
 
 #include <strEx.h>
 #include <arrayBuffer.h>
 
-#include <nscapi/nscapi_core_wrapper.hpp>
-#include <nscapi/nscapi_plugin_wrapper.hpp>
-#include <nscapi/functions.hpp>
-#include <settings/macros.h>
-
 #include <protobuf/plugin.pb.h>
-
-using namespace nscp::helpers;
-
 
 #define CORE_LOG_ERROR_STD(msg) if (should_log(NSCAPI::log_level::error)) { log(NSCAPI::log_level::error, __FILE__, __LINE__, (std::wstring)msg); }
 #define CORE_LOG_ERROR(msg) if (should_log(NSCAPI::log_level::error)) { log(NSCAPI::log_level::error, __FILE__, __LINE__, msg); }
 
-//#define CORE_LOG_CRITICAL_STD(msg) if (matches(NSCAPI::critical)) { CORE_ANY_MSG(NSCAPI::critical, __FILE__, __LINE__, (std::wstring)msg) }
-//#define CORE_LOG_CRITICAL(msg) if (matches(NSCAPI::critical)) { CORE_ANY_MSG(NSCAPI::critical, __FILE__, __LINE__, msg) }
-
-//#define CORE_LOG_MESSAGE_STD(msg) if (matches(NSCAPI::info)) { CORE_ANY_MSG(NSCAPI::info, __FILE__, __LINE__, (std::wstring)msg) }
-//#define CORE_LOG_MESSAGE(msg) if (matches(NSCAPI::info)) { CORE_ANY_MSG(NSCAPI::info, __FILE__, __LINE__, msg) }
-
-//#define CORE_DEBUG_MSG_STD(msg) if (matches(NSCAPI::debug)) { CORE_ANY_MSG(NSCAPI::debug, __FILE__, __LINE__, (std::wstring)msg) }
-//#define CORE_DEBUG_MSG(msg) if (matches(NSCAPI::debug)) { CORE_ANY_MSG(NSCAPI::debug, __FILE__, __LINE__, msg) }
-
-//#define CORE_ANY_MSG(msg, type) log(type, __FILE__, __LINE__, msg)
-
-
+#define LEGACY_BUFFER_LENGTH 4096
 //////////////////////////////////////////////////////////////////////////
 // Callbacks into the core
@@ -80,5 +64,5 @@
 		return;
 	if (!fNSAPIMessage) {
-		std::wcout << _T("*** *** *** NSCore not loaded, dumping log: ") << to_wstring(file) << _T(":") << line << _T(": ") << std::endl << logMessage << std::endl;
+		std::wcout << _T("NSCORE NOT LOADED Dumping log: ") << line << _T(": ") << std::endl << logMessage << std::endl;
 		return;
 	}
@@ -136,5 +120,5 @@
 {
 	if (!fNSAPIInject)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPIInject(command, request, request_len, response, response_len);
 }
@@ -143,5 +127,5 @@
 void nscapi::core_wrapper::DestroyBuffer(char**buffer) {
 	if (!fNSAPIDestroyBuffer)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPIDestroyBuffer(buffer);
 }
@@ -151,5 +135,5 @@
 
 	if (!fNSAPINotify)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	char *buffer = NULL;
 	unsigned int buffer_size = 0;
@@ -167,5 +151,5 @@
 
 	if (!fNSAPIReload)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPIReload(module.c_str());
 }
@@ -190,5 +174,5 @@
 {
 	if (!fNSAPINotify)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPINotify(channel, request, request_len, response, response_len);
 }
@@ -206,5 +190,5 @@
 {
 	if (!fNSAPIInject)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	std::string response;
 	NSCAPI::nagiosReturn ret = simple_query(command, argument, response);
@@ -231,5 +215,5 @@
 {
 	if (!fNSAPIInject)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 
 	std::string request;
@@ -246,5 +230,5 @@
 {
 	if (!fNSAPIInject)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	char *buffer = NULL;
 	unsigned int buffer_size = 0;
@@ -267,5 +251,5 @@
 			break;
 		default:
-			throw nscapi::nscapi_exception(_T("Unknown return code when injecting: ") + std::wstring(command));
+			throw nscapi::nscapi_exception("Unknown return code from query: " + utf8::cvt<std::string>(command));
 	}
 	return retC;
@@ -275,5 +259,5 @@
 NSCAPI::nagiosReturn nscapi::core_wrapper::simple_query_from_nrpe(const std::wstring command, const std::wstring & buffer, std::wstring & message, std::wstring & perf) {
 	if (!fNSAPIInject)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	boost::tokenizer<boost::char_separator<wchar_t>, std::wstring::const_iterator, std::wstring > tok(buffer, boost::char_separator<wchar_t>(_T("!")));
 	std::list<std::wstring> arglist;
@@ -303,5 +287,5 @@
 			break;
 		default:
-			throw nscapi::nscapi_exception(_T("Unknown return code when injecting: ") + std::wstring(command));
+			throw nscapi::nscapi_exception("Unknown return from exec: " + utf8::cvt<std::string>(command));
 	}
 	return retC;
@@ -310,5 +294,5 @@
 {
 	if (!fNSAPIExecCommand)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPIExecCommand(target, command, request, request_len, response, response_len);
 }
@@ -352,10 +336,10 @@
 std::wstring nscapi::core_wrapper::getSettingsString(std::wstring section, std::wstring key, std::wstring defaultValue) {
 	if (!fNSAPIGetSettingsString)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
-	unsigned int buf_len = getBufferLength();
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
+	unsigned int buf_len = LEGACY_BUFFER_LENGTH;
 	wchar_t *buffer = new wchar_t[buf_len+1];
 	if (fNSAPIGetSettingsString(section.c_str(), key.c_str(), defaultValue.c_str(), buffer, buf_len) != NSCAPI::isSuccess) {
 		delete [] buffer;
-		throw nscapi::nscapi_exception(_T("Settings could not be retrieved."));
+		throw nscapi::nscapi_exception("Settings could not be retrieved.");
 	}
 	std::wstring ret = buffer;
@@ -366,10 +350,10 @@
 std::wstring nscapi::core_wrapper::expand_path(std::wstring value) {
 	if (!fNSAPIExpandPath)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
-	unsigned int buf_len = getBufferLength();
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
+	unsigned int buf_len = LEGACY_BUFFER_LENGTH;
 	wchar_t *buffer = new wchar_t[buf_len+1];
 	if (fNSAPIExpandPath(value.c_str(), buffer, buf_len) != NSCAPI::isSuccess) {
 		delete [] buffer;
-		throw nscapi::nscapi_exception(_T("Settings could not be retrieved."));
+		throw nscapi::nscapi_exception("Settings could not be retrieved.");
 	}
 	std::wstring ret = buffer;
@@ -384,32 +368,32 @@
 std::list<std::wstring> nscapi::core_wrapper::getSettingsSection(std::wstring section) {
 	if (!fNSAPIGetSettingsSection)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	array_buffer::arrayBuffer aBuffer = NULL;
 	unsigned int argLen = 0;
 	if (fNSAPIGetSettingsSection(section.c_str(), &aBuffer, &argLen) != NSCAPI::isSuccess) {
-		throw nscapi::nscapi_exception(_T("Settings could not be retrieved."));
+		throw nscapi::nscapi_exception("Settings could not be retrieved.");
 	}
 	std::list<std::wstring> ret = array_buffer::arrayBuffer2list(argLen, aBuffer);
 	if (fNSAPIReleaseSettingsSectionBuffer(&aBuffer, &argLen) != NSCAPI::isSuccess) {
-		throw nscapi::nscapi_exception(_T("Settings could not be destroyed."));
+		throw nscapi::nscapi_exception("Settings could not be destroyed.");
 	}
 	if (aBuffer != NULL)
-		throw nscapi::nscapi_exception(_T("buffer is not null?."));
+		throw nscapi::nscapi_exception("buffer is not null?.");
 	return ret;
 }
 std::list<std::wstring> nscapi::core_wrapper::getSettingsSections(std::wstring section) {
 	if (!fNSAPIGetSettingsSections)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	array_buffer::arrayBuffer aBuffer = NULL;
 	unsigned int argLen = 0;
 	if (fNSAPIGetSettingsSections(section.c_str(), &aBuffer, &argLen) != NSCAPI::isSuccess) {
-		throw nscapi::nscapi_exception(_T("Settings could not be retrieved."));
+		throw nscapi::nscapi_exception("Settings could not be retrieved.");
 	}
 	std::list<std::wstring> ret = array_buffer::arrayBuffer2list(argLen, aBuffer);
 	if (fNSAPIReleaseSettingsSectionBuffer(&aBuffer, &argLen) != NSCAPI::isSuccess) {
-		throw nscapi::nscapi_exception(_T("Settings could not be destroyed."));
+		throw nscapi::nscapi_exception("Settings could not be destroyed.");
 	}
 	if (aBuffer != NULL)
-		throw nscapi::nscapi_exception(_T("buffer is not null?."));
+		throw nscapi::nscapi_exception("buffer is not null?.");
 	return ret;
 }
@@ -426,20 +410,20 @@
 int nscapi::core_wrapper::getSettingsInt(std::wstring section, std::wstring key, int defaultValue) {
 	if (!fNSAPIGetSettingsInt)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPIGetSettingsInt(section.c_str(), key.c_str(), defaultValue);
 }
 bool nscapi::core_wrapper::getSettingsBool(std::wstring section, std::wstring key, bool defaultValue) {
 	if (!fNSAPIGetSettingsBool)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPIGetSettingsBool(section.c_str(), key.c_str(), defaultValue?1:0) == 1;
 }
 void nscapi::core_wrapper::settings_register_key(std::wstring path, std::wstring key, NSCAPI::settings_type type, std::wstring title, std::wstring description, std::wstring defaultValue, bool advanced) {
 	if (!fNSAPISettingsRegKey)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	fNSAPISettingsRegKey(path.c_str(), key.c_str(), type, title.c_str(), description.c_str(), defaultValue.c_str(), advanced);
 }
 void nscapi::core_wrapper::settings_register_path(std::wstring path, std::wstring title, std::wstring description, bool advanced) {
 	if (!fNSAPISettingsRegPath)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	fNSAPISettingsRegPath(path.c_str(), title.c_str(), description.c_str(), advanced);
 }
@@ -448,5 +432,5 @@
 void nscapi::core_wrapper::settings_save() {
 	if (!fNSAPISettingsSave)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	fNSAPISettingsSave();
 }
@@ -459,10 +443,10 @@
 std::wstring nscapi::core_wrapper::getApplicationName() {
 	if (!fNSAPIGetApplicationName)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
-	unsigned int buf_len = getBufferLength();
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
+	unsigned int buf_len = LEGACY_BUFFER_LENGTH;
 	wchar_t *buffer = new wchar_t[buf_len+1];
 	if (fNSAPIGetApplicationName(buffer, buf_len) != NSCAPI::isSuccess) {
 		delete [] buffer;
-		throw nscapi::nscapi_exception(_T("Application name could not be retrieved"));
+		throw nscapi::nscapi_exception("Application name could not be retrieved");
 	}
 	std::wstring ret = buffer;
@@ -477,10 +461,10 @@
 std::wstring nscapi::core_wrapper::getBasePath() {
 	if (!fNSAPIGetBasePath)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
-	unsigned int buf_len = getBufferLength();
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
+	unsigned int buf_len = LEGACY_BUFFER_LENGTH;
 	wchar_t *buffer = new wchar_t[buf_len+1];
 	if (fNSAPIGetBasePath(buffer, buf_len) != NSCAPI::isSuccess) {
 		delete [] buffer;
-		throw nscapi::nscapi_exception(_T("Base path could not be retrieved"));
+		throw nscapi::nscapi_exception("Base path could not be retrieved");
 	}
 	std::wstring ret = buffer;
@@ -489,16 +473,7 @@
 }
 
-unsigned int nscapi::core_wrapper::getBufferLength() {
-	static unsigned int len = 0;
-	if (len == 0) {
-		len = getSettingsInt(setting_keys::settings_def::PAYLOAD_LEN_PATH, setting_keys::settings_def::PAYLOAD_LEN, setting_keys::settings_def::PAYLOAD_LEN_DEFAULT);
-	}
-	return len;
-}
-
-
 std::wstring nscapi::core_wrapper::Encrypt(std::wstring str, unsigned int algorithm) {
 	if (!fNSAPIEncrypt)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	unsigned int len = 0;
 	// @todo investigate potential problems with static_cast<unsigned int>
@@ -516,5 +491,5 @@
 std::wstring nscapi::core_wrapper::Decrypt(std::wstring str, unsigned int algorithm) {
 	if (!fNSAPIDecrypt)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	unsigned int len = 0;
 	// @todo investigate potential problems with: static_cast<unsigned int>(str.size())
@@ -532,30 +507,30 @@
 NSCAPI::errorReturn nscapi::core_wrapper::SetSettingsString(std::wstring section, std::wstring key, std::wstring value) {
 	if (!fNSAPISetSettingsString)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPISetSettingsString(section.c_str(), key.c_str(), value.c_str());
 }
 NSCAPI::errorReturn nscapi::core_wrapper::SetSettingsInt(std::wstring section, std::wstring key, int value) {
 	if (!fNSAPISetSettingsInt)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPISetSettingsInt(section.c_str(), key.c_str(), value);
 }
 NSCAPI::errorReturn nscapi::core_wrapper::WriteSettings(int type) {
 	if (!fNSAPIWriteSettings)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPIWriteSettings(type);
 }
 NSCAPI::errorReturn nscapi::core_wrapper::ReadSettings(int type) {
 	if (!fNSAPIReadSettings)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPIReadSettings(type);
 }
 NSCAPI::errorReturn nscapi::core_wrapper::Rehash(int flag) {
 	if (!fNSAPIRehash)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPIRehash(flag);
 }
 nscapi::core_wrapper::plugin_info_list nscapi::core_wrapper::getPluginList() {
 	if (!fNSAPIGetPluginList || !fNSAPIReleasePluginList)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	plugin_info_list ret;
 	
@@ -583,26 +558,26 @@
 std::list<std::wstring> nscapi::core_wrapper::getAllCommandNames() {
 	if (!fNSAPIGetAllCommandNames || !fNSAPIReleaseAllCommandNamessBuffer )
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	array_buffer::arrayBuffer aBuffer = NULL;
 	unsigned int argLen = 0;
 	if (fNSAPIGetAllCommandNames(&aBuffer, &argLen) != NSCAPI::isSuccess) {
-		throw nscapi::nscapi_exception(_T("Commands could not be retrieved."));
+		throw nscapi::nscapi_exception("Commands could not be retrieved.");
 	}
 	std::list<std::wstring> ret = array_buffer::arrayBuffer2list(argLen, aBuffer);
 	if (fNSAPIReleaseAllCommandNamessBuffer(&aBuffer, &argLen) != NSCAPI::isSuccess) {
-		throw nscapi::nscapi_exception(_T("Commands could not be destroyed."));
+		throw nscapi::nscapi_exception("Commands could not be destroyed.");
 	}
 	if (aBuffer != NULL)
-		throw nscapi::nscapi_exception(_T("buffer is not null?."));
+		throw nscapi::nscapi_exception("buffer is not null?.");
 	return ret;
 }
 std::wstring nscapi::core_wrapper::describeCommand(std::wstring command) {
 	if (!fNSAPIDescribeCommand)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
-	unsigned int buf_len = getBufferLength();
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
+	unsigned int buf_len = LEGACY_BUFFER_LENGTH;
 	wchar_t *buffer = new wchar_t[buf_len+1];
 	if (fNSAPIDescribeCommand(command.c_str(), buffer, buf_len) != NSCAPI::isSuccess) {
 		delete [] buffer;
-		throw nscapi::nscapi_exception(_T("Base path could not be retrieved"));
+		throw nscapi::nscapi_exception("Base path could not be retrieved");
 	}
 	std::wstring ret = buffer;
@@ -612,7 +587,7 @@
 void nscapi::core_wrapper::registerCommand(unsigned int id, std::wstring command, std::wstring description) {
 	if (!fNSAPIRegisterCommand)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	if (fNSAPIRegisterCommand(id, command.c_str(), description.c_str()) != NSCAPI::isSuccess) {
-		CORE_LOG_ERROR_STD(_T("Failed to register command: ") + command + _T(" in plugin: ") + to_wstring(id));
+		CORE_LOG_ERROR_STD(_T("Failed to register command: ") + command + _T(" in plugin: ") + strEx::itos(id));
 	}
 }
@@ -620,14 +595,14 @@
 void nscapi::core_wrapper::registerSubmissionListener(unsigned int id, std::wstring channel) {
 	if (!fNSAPIRegisterSubmissionListener)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	if (fNSAPIRegisterSubmissionListener(id, channel.c_str()) != NSCAPI::isSuccess) {
-		CORE_LOG_ERROR_STD(_T("Failed to register channel: ") + channel + _T(" in plugin: ") + to_wstring(id));
+		CORE_LOG_ERROR_STD(_T("Failed to register channel: ") + channel + _T(" in plugin: ") + strEx::itos(id));
 	}
 }
 void nscapi::core_wrapper::registerRoutingListener(unsigned int id, std::wstring channel) {
 	if (!fNSAPIRegisterRoutingListener)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	if (fNSAPIRegisterRoutingListener(id, channel.c_str()) != NSCAPI::isSuccess) {
-		CORE_LOG_ERROR_STD(_T("Failed to register channel: ") + channel + _T(" in plugin: ") + to_wstring(id));
+		CORE_LOG_ERROR_STD(_T("Failed to register channel: ") + channel + _T(" in plugin: ") + strEx::itos(id));
 	}
 }
@@ -636,5 +611,5 @@
 bool nscapi::core_wrapper::checkLogMessages(int type) {
 	if (!fNSAPICheckLogMessages)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
 	return fNSAPICheckLogMessages(type) == NSCAPI::istrue;
 }
@@ -646,6 +621,6 @@
 std::wstring nscapi::core_wrapper::getApplicationVersionString() {
 	if (!fNSAPIGetApplicationVersionStr)
-		throw nscapi::nscapi_exception(_T("NSCore has not been initiated..."));
-	unsigned int buf_len = getBufferLength();
+		throw nscapi::nscapi_exception("NSCore has not been initiated...");
+	unsigned int buf_len = LEGACY_BUFFER_LENGTH;
 	wchar_t *buffer = new wchar_t[buf_len+1];
 	if (fNSAPIGetApplicationVersionStr(buffer, buf_len) != NSCAPI::isSuccess) {
Index: include/nscapi/nscapi_core_wrapper.hpp
===================================================================
--- include/nscapi/nscapi_core_wrapper.hpp	(revision 8013c0c69eb8c8810105e7655994c71fbd9bf105)
+++ include/nscapi/nscapi_core_wrapper.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -23,13 +23,6 @@
 #include <string>
 #include <list>
-//#include <iostream>
 
 #include <NSCAPI.h>
-//#include <charEx.h>
-//#include <arrayBuffer.h>
-//#include <types.hpp>
-
-//#include <unicode_char.hpp>
-//#include <strEx.h>
 
 namespace nscapi {
@@ -173,5 +166,4 @@
 		void registerRoutingListener(unsigned int id, std::wstring channel);
 
-		unsigned int getBufferLength();
 		bool load_endpoints(nscapi::core_api::lpNSAPILoader f);
 
Index: include/nscapi/nscapi_helper.cpp
===================================================================
--- include/nscapi/nscapi_helper.cpp	(revision 8013c0c69eb8c8810105e7655994c71fbd9bf105)
+++ include/nscapi/nscapi_helper.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -20,13 +20,7 @@
 ***************************************************************************/
 
-#include <unicode_char.hpp>
 #include <strEx.h>
 
 #include <nscapi/nscapi_helper.hpp>
-#include <nscapi/macros.hpp>
-#include <settings/macros.h>
-
-#include <boost/foreach.hpp>
-#include <boost/tokenizer.hpp>
 
 #define REPORT_ERROR	0x01
Index: include/nscapi/nscapi_plugin_impl.cpp
===================================================================
--- include/nscapi/nscapi_plugin_impl.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
+++ include/nscapi/nscapi_plugin_impl.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -0,0 +1,66 @@
+#include <nscapi/nscapi_plugin_impl.hpp>
+
+#include <nscapi/nscapi_protobuf_functions.hpp>
+#include <nscapi/nscapi_core_wrapper.hpp>
+#include <nscapi/nscapi_plugin_wrapper.hpp>
+
+#include <iostream>
+
+#include <protobuf/plugin.pb.h>
+
+extern nscapi::helper_singleton* plugin_singleton;
+
+nscapi::core_wrapper* nscapi::impl::simple_plugin::get_core() {
+	return plugin_singleton->get_core();
+}
+
+void nscapi::impl::simple_log_handler::handleMessageRAW(std::string data) {
+	try {
+		Plugin::LogEntry message;
+		message.ParseFromString(data);
+
+		for (int i=0;i<message.entry_size();i++) {
+			Plugin::LogEntry::Entry msg = message.entry(i);
+			handleMessage(msg.level(), msg.file(), msg.line(), msg.message());
+		}
+	} catch (std::exception &e) {
+		std::cout << "Failed to parse data from: " << strEx::strip_hex(data) << e.what() <<  std::endl;;
+	} catch (...) {
+		std::cout << "Failed to parse data from: " << strEx::strip_hex(data) << std::endl;;
+	}
+}
+
+NSCAPI::nagiosReturn nscapi::impl::simple_command_handler::handleRAWCommand(const wchar_t* char_command, const std::string &request, std::string &response) {
+	nscapi::protobuf::types::decoded_simple_command_data data = nscapi::functions::parse_simple_query_request(char_command, request);
+	std::wstring msg, perf;
+
+	NSCAPI::nagiosReturn ret = handleCommand(data.target, boost::algorithm::to_lower_copy(data.command), data.args, msg, perf);
+	nscapi::functions::create_simple_query_response(data.command, ret, msg, perf, response);
+	return ret;
+}
+
+NSCAPI::nagiosReturn nscapi::impl::simple_command_line_exec::commandRAWLineExec(const wchar_t* char_command, const std::string &request, std::string &response) {
+	nscapi::protobuf::types::decoded_simple_command_data data = nscapi::functions::parse_simple_exec_request(char_command, request);
+	std::wstring result;
+	NSCAPI::nagiosReturn ret = commandLineExec(data.command, data.args, result);
+	if (ret == NSCAPI::returnIgnored)
+		return NSCAPI::returnIgnored;
+	nscapi::functions::create_simple_exec_response(data.command, ret, result, response);
+	return ret;
+}
+
+NSCAPI::nagiosReturn nscapi::impl::simple_submission_handler::handleRAWNotification(const wchar_t* channel, std::string request, std::string &response) {
+	try {
+		std::wstring source, command, msg, perf;
+		int code = nscapi::functions::parse_simple_submit_request(request, source, command, msg, perf);
+		NSCAPI::nagiosReturn ret = handleSimpleNotification(channel, source, command, code, msg, perf);
+		if (ret == NSCAPI::returnIgnored)
+			return NSCAPI::returnIgnored;
+		nscapi::functions::create_simple_submit_response(channel, command, ret, _T(""), response);
+	} catch (std::exception &e) {
+		nscapi::plugin_singleton->get_core()->log(NSCAPI::log_level::error, __FILE__, __LINE__, utf8::cvt<std::wstring>("Failed to parse data from: " + strEx::strip_hex(request) + ": " + e.what()));
+	} catch (...) {
+		nscapi::plugin_singleton->get_core()->log(NSCAPI::log_level::error, __FILE__, __LINE__, utf8::cvt<std::wstring>("Failed to parse data from: " + strEx::strip_hex(request)));
+	}
+	return NSCAPI::returnIgnored;
+}
Index: include/nscapi/nscapi_plugin_impl.hpp
===================================================================
--- include/nscapi/nscapi_plugin_impl.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
+++ include/nscapi/nscapi_plugin_impl.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -0,0 +1,60 @@
+#pragma once
+
+#include <string>
+
+#include <boost/shared_ptr.hpp>
+
+#include <NSCAPI.h>
+
+#include <nscapi/settings_proxy.hpp>
+
+namespace nscapi {
+	namespace impl {
+		struct simple_plugin {
+			int id_;
+			nscapi::core_wrapper* get_core();
+			inline unsigned int get_id() {
+				return id_;
+			}
+			inline void set_id(unsigned int id) {
+				id_ = id;
+			}
+			inline boost::shared_ptr<nscapi::settings_proxy> get_settings_proxy() {
+				return boost::shared_ptr<nscapi::settings_proxy>(new nscapi::settings_proxy(get_core()));
+			}
+			void register_command(std::wstring command, std::wstring description) {
+				get_core()->registerCommand(get_id(), command, description);
+			}
+
+		};
+
+		class simple_submission_handler {
+		public:
+			NSCAPI::nagiosReturn handleRAWNotification(const wchar_t* channel, std::string request, std::string &response);
+			virtual NSCAPI::nagiosReturn handleSimpleNotification(const std::wstring channel, const std::wstring source, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf) = 0;
+
+		};
+
+		class simple_command_handler {
+		public:
+			NSCAPI::nagiosReturn handleRAWCommand(const wchar_t* char_command, const std::string &request, std::string &response);
+			virtual NSCAPI::nagiosReturn handleCommand(const std::wstring &target, const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &msg, std::wstring &perf) = 0;
+		};
+		class simple_command_line_exec {
+		public:
+			NSCAPI::nagiosReturn commandRAWLineExec(const wchar_t* char_command, const std::string &request, std::string &response);
+			virtual NSCAPI::nagiosReturn commandLineExec(const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &result) = 0;
+		};
+
+
+		class simple_log_handler {
+		public:
+			void handleMessageRAW(std::string data);
+			virtual void handleMessage(int msgType, const std::string file, int line, std::string message) = 0;
+		};
+
+	};
+
+
+
+};
Index: include/nscapi/nscapi_plugin_wrapper.cpp
===================================================================
--- include/nscapi/nscapi_plugin_wrapper.cpp	(revision 8013c0c69eb8c8810105e7655994c71fbd9bf105)
+++ include/nscapi/nscapi_plugin_wrapper.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -21,21 +21,5 @@
 
 #include <nscapi/nscapi_plugin_wrapper.hpp>
-#include <nscapi/nscapi_helper.hpp>
 #include <nscapi/nscapi_core_wrapper.hpp>
-
-#include <nscapi/functions.hpp>
-#include <nscapi/macros.hpp>
-#include <settings/macros.h>
-#include <arrayBuffer.h>
-//#include <config.h>
-#include <strEx.h>
-
-#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
-#include <boost/tokenizer.hpp>
-
-#include <protobuf/plugin.pb.h>
-
-using namespace nscp::helpers;
 
 
@@ -71,56 +55,6 @@
  */
 int nscapi::plugin_wrapper::wrapModuleHelperInit(unsigned int id, nscapi::core_api::lpNSAPILoader f) {
-	return GET_CORE()->load_endpoints(f)?NSCAPI::isSuccess:NSCAPI::hasFailed;
+	return nscapi::plugin_singleton->get_core()->load_endpoints(f)?NSCAPI::isSuccess:NSCAPI::hasFailed;
 }
 
 
-void nscapi::impl::simple_log_handler::handleMessageRAW(std::string data) {
-	try {
-		Plugin::LogEntry message;
-		message.ParseFromString(data);
-
-		for (int i=0;i<message.entry_size();i++) {
-			Plugin::LogEntry::Entry msg = message.entry(i);
-			handleMessage(msg.level(), msg.file(), msg.line(), msg.message());
-		}
-	} catch (std::exception &e) {
-		std::cout << "Failed to parse data from: " << strEx::strip_hex(data) << e.what() <<  std::endl;;
-	} catch (...) {
-		std::cout << "Failed to parse data from: " << strEx::strip_hex(data) << std::endl;;
-	}
-}
-
-NSCAPI::nagiosReturn nscapi::impl::simple_command_handler::handleRAWCommand(const wchar_t* char_command, const std::string &request, std::string &response) {
-	nscapi::functions::decoded_simple_command_data data = nscapi::functions::parse_simple_query_request(char_command, request);
-	std::wstring msg, perf;
-
-	NSCAPI::nagiosReturn ret = handleCommand(data.target, boost::algorithm::to_lower_copy(data.command), data.args, msg, perf);
-	nscapi::functions::create_simple_query_response(data.command, ret, msg, perf, response);
-	return ret;
-}
-
-NSCAPI::nagiosReturn nscapi::impl::simple_command_line_exec::commandRAWLineExec(const wchar_t* char_command, const std::string &request, std::string &response) {
-	nscapi::functions::decoded_simple_command_data data = nscapi::functions::parse_simple_exec_request(char_command, request);
-	std::wstring result;
-	NSCAPI::nagiosReturn ret = commandLineExec(data.command, data.args, result);
-	if (ret == NSCAPI::returnIgnored)
-		return NSCAPI::returnIgnored;
-	nscapi::functions::create_simple_exec_response(data.command, ret, result, response);
-	return ret;
-}
-
-NSCAPI::nagiosReturn nscapi::impl::simple_submission_handler::handleRAWNotification(const wchar_t* channel, std::string request, std::string &response) {
-	try {
-		std::wstring source, command, msg, perf;
-		int code = nscapi::functions::parse_simple_submit_request(request, source, command, msg, perf);
-		NSCAPI::nagiosReturn ret = handleSimpleNotification(channel, source, command, code, msg, perf);
-		if (ret == NSCAPI::returnIgnored)
-			return NSCAPI::returnIgnored;
-		nscapi::functions::create_simple_submit_response(channel, command, ret, _T(""), response);
-	} catch (std::exception &e) {
-		nscapi::plugin_singleton->get_core()->log(NSCAPI::log_level::error, __FILE__, __LINE__, utf8::cvt<std::wstring>("Failed to parse data from: " + strEx::strip_hex(request) + ": " + e.what()));
-	} catch (...) {
-		nscapi::plugin_singleton->get_core()->log(NSCAPI::log_level::error, __FILE__, __LINE__, utf8::cvt<std::wstring>("Failed to parse data from: " + strEx::strip_hex(request)));
-	}
-	return NSCAPI::returnIgnored;
-}
Index: include/nscapi/nscapi_plugin_wrapper.hpp
===================================================================
--- include/nscapi/nscapi_plugin_wrapper.hpp	(revision a87ce04e3c7a1696a9de2386727e8713114deda5)
+++ include/nscapi/nscapi_plugin_wrapper.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -21,23 +21,21 @@
 #pragma once
 
+#include <unicode_char.hpp>
+
 #include <string>
 #include <list>
-#include <vector>
 #include <map>
-
+#include <string.h>
+
+#include <boost/shared_ptr.hpp>
 #include <boost/make_shared.hpp>
-#include <unicode_char.hpp>
 
 #include <NSCAPI.h>
-#include <nscapi/settings_proxy.hpp>
 #include <nscapi/macros.hpp>
 #include <nscapi/nscapi_helper.hpp>
-
-
-namespace PluginCommand {
-	class Request;
-	class Response;
-
-};
+#include <nscapi/nscapi_core_wrapper.hpp>
+
+#include <strEx.h>
+
 namespace nscapi {
 	class plugin_wrapper {
@@ -81,5 +79,4 @@
 	};
 
-	class core_wrapper;
 	class helper_singleton {
 		core_wrapper* core_;
@@ -96,56 +93,4 @@
 
 	extern helper_singleton* plugin_singleton;
-
-
-
-	namespace impl {
-		struct simple_plugin {
-			int id_;
-			inline nscapi::core_wrapper* get_core() {
-				return plugin_singleton->get_core();
-			}
-			inline unsigned int get_id() {
-				return id_;
-			}
-			inline void set_id(unsigned int id) {
-				id_ = id;
-			}
-			inline boost::shared_ptr<nscapi::settings_proxy> get_settings_proxy() {
-				return boost::shared_ptr<nscapi::settings_proxy>(new nscapi::settings_proxy(get_core()));
-			}
-			void register_command(std::wstring command, std::wstring description) {
-				get_core()->registerCommand(get_id(), command, description);
-			}
-
-		};
-
-		class simple_submission_handler {
-		public:
-			NSCAPI::nagiosReturn handleRAWNotification(const wchar_t* channel, std::string request, std::string &response);
-			virtual NSCAPI::nagiosReturn handleSimpleNotification(const std::wstring channel, const std::wstring source, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf) = 0;
-
-		};
-
-		class simple_command_handler {
-		public:
-			NSCAPI::nagiosReturn handleRAWCommand(const wchar_t* char_command, const std::string &request, std::string &response);
-			virtual NSCAPI::nagiosReturn handleCommand(const std::wstring &target, const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &msg, std::wstring &perf) = 0;
-		};
-		class simple_command_line_exec {
-		public:
-			NSCAPI::nagiosReturn commandRAWLineExec(const wchar_t* char_command, const std::string &request, std::string &response);
-			virtual NSCAPI::nagiosReturn commandLineExec(const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &result) = 0;
-		};
-
-
-		class simple_log_handler {
-		public:
-			void handleMessageRAW(std::string data);
-			virtual void handleMessage(int msgType, const std::string file, int line, std::string message) = 0;
-		};
-
-	};
-
-
 
 	template<class impl_type>
@@ -180,5 +125,4 @@
 			if (str.length() >= bufLen) {
 				std::wstring sstr = str.substr(0, bufLen-2);
-				NSC_DEBUG_MSG_STD(_T("String (") + strEx::itos(str.length()) + _T(") to long to fit inside buffer(") + strEx::itos(bufLen) + _T(") : ") + sstr);
 				return NSCAPI::isInvalidBufferLen;
 			}
Index: include/nscapi/nscapi_protobuf_functions.cpp
===================================================================
--- include/nscapi/nscapi_protobuf_functions.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
+++ include/nscapi/nscapi_protobuf_functions.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -0,0 +1,612 @@
+/**************************************************************************
+*   Copyright (C) 2004-2007 by Michael Medin <michael@medin.name>         *
+*                                                                         *
+*   This code is part of NSClient++ - http://trac.nakednuns.org/nscp      *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU General Public License     *
+*   along with this program; if not, write to the                         *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#include <nscapi/nscapi_protobuf_functions.hpp>
+
+namespace nscapi {
+	namespace protobuf {
+
+		namespace traits {
+
+			template<class T>
+			struct perf_data_consts {
+				static const T get_valid_perf_numbers();
+				static const T get_replace_perf_coma_src();
+				static const T get_replace_perf_coma_tgt();
+			};
+
+			template<>
+			struct perf_data_consts<std::wstring> {
+				static const std::wstring get_valid_perf_numbers() {
+					return _T("0123456789,.");
+				}
+				static const std::wstring get_replace_perf_coma_src() {
+					return _T(",");
+				}
+				static const std::wstring get_replace_perf_coma_tgt() {
+					return _T(".");
+				}
+			};
+			template<>
+			struct perf_data_consts<std::string> {
+				static const std::string get_valid_perf_numbers() {
+					return "0123456789,.";
+				}
+				static const std::string get_replace_perf_coma_src() {
+					return ",";
+				}
+				static const std::string get_replace_perf_coma_tgt() {
+					return ".";
+				}
+			};
+		}
+
+		template<class T>
+		double trim_to_double(T s) {
+			typename T::size_type pend = s.find_first_not_of(traits::perf_data_consts<T>::get_valid_perf_numbers());
+			if (pend != T::npos)
+				s = s.substr(0,pend);
+			strEx::replace(s, traits::perf_data_consts<T>::get_replace_perf_coma_src(), traits::perf_data_consts<T>::get_replace_perf_coma_tgt());
+			return strEx::stod(s);
+		}
+
+
+
+		void functions::create_simple_header(Plugin::Common::Header* hdr)  {
+			hdr->set_version(Plugin::Common_Version_VERSION_1);
+			hdr->set_max_supported_version(Plugin::Common_Version_VERSION_1);
+			// @todo add additional fields here!
+		}
+
+		//////////////////////////////////////////////////////////////////////////
+
+		void functions::add_host(Plugin::Common::Header* hdr, const destination_container &dst)  {
+			::Plugin::Common::Host *host = hdr->add_hosts();
+			if (!dst.id.empty())
+				host->set_id(dst.id);
+			if (!dst.address.host.empty())
+				host->set_address(dst.address.to_string());
+			if (!dst.has_protocol())
+				host->set_protocol(dst.get_protocol());
+			if (!dst.comment.empty())
+				host->set_comment(dst.comment);
+			BOOST_FOREACH(const std::string &t, dst.tags) {
+				host->add_tags(t);
+			}
+			BOOST_FOREACH(const destination_container::data_map::value_type &kvp, dst.data) {
+				::Plugin::Common_KeyValue* x = host->add_metadata();
+				x->set_key(kvp.first);
+				x->set_value(kvp.second);
+			}
+		}
+
+		bool functions::parse_destination(const ::Plugin::Common_Header &header, const std::string tag, destination_container &data, const bool expand_meta) {
+			for (int i=0;i<header.hosts_size();++i) {
+				const ::Plugin::Common::Host &host = header.hosts(i);
+				if (host.id() == tag) {
+					data.id = tag;
+					if (!host.address().empty())
+						data.address.import(net::parse(host.address()));
+					if (!host.comment().empty())
+						data.comment = host.comment();
+					if (expand_meta) {
+						for(int j=0;j<host.tags_size(); ++j) {
+							data.tags.insert(host.tags(j));
+						}
+						for(int j=0;j<host.metadata_size(); ++j) {
+							data.data[host.metadata(j).key()] = host.metadata(j).value();
+						}
+					}
+					return true;
+				}
+			}
+			return false;
+		}
+
+		//////////////////////////////////////////////////////////////////////////
+
+		void functions::make_submit_from_query(std::string &message, const std::wstring channel, const std::wstring alias, const std::wstring target) {
+			Plugin::QueryResponseMessage response;
+			response.ParseFromString(message);
+			Plugin::SubmitRequestMessage request;
+			request.mutable_header()->CopyFrom(response.header());
+			request.mutable_header()->set_source_id(request.mutable_header()->recipient_id());
+			request.set_channel(utf8::cvt<std::string>(channel));
+			if (!target.empty()) {
+				request.mutable_header()->set_recipient_id(utf8::cvt<std::string>(target));
+			}
+			for (int i=0;i<response.payload_size();++i) {
+				request.add_payload()->CopyFrom(response.payload(i));
+				if (!alias.empty())
+					request.mutable_payload(i)->set_alias(utf8::cvt<std::string>(alias));
+			}
+			message = request.SerializeAsString();
+		}
+
+		void functions::make_query_from_exec(std::string &data) {
+			Plugin::ExecuteResponseMessage exec_response_message;
+			exec_response_message.ParseFromString(data);
+			Plugin::QueryResponseMessage query_response_message;
+			query_response_message.mutable_header()->CopyFrom(exec_response_message.header());
+			for (int i=0;i<exec_response_message.payload_size();++i) {
+				Plugin::ExecuteResponseMessage::Response p = exec_response_message.payload(i);
+				append_simple_query_response_payload(query_response_message.add_payload(), p.command(), p.result(), p.message());
+			}
+			data = query_response_message.SerializeAsString();
+		}
+		void functions::make_query_from_submit(std::string &data) {
+			Plugin::SubmitResponseMessage submit_response_message;
+			submit_response_message.ParseFromString(data);
+			Plugin::QueryResponseMessage query_response_message;
+			query_response_message.mutable_header()->CopyFrom(submit_response_message.header());
+			for (int i=0;i<submit_response_message.payload_size();++i) {
+				Plugin::SubmitResponseMessage::Response p = submit_response_message.payload(i);
+				append_simple_query_response_payload(query_response_message.add_payload(), p.command(), gbp_status_to_gbp_nagios(p.status().status()), p.status().message(), "");
+			}
+			data = query_response_message.SerializeAsString();
+		}
+
+		void functions::make_exec_from_submit(std::string &data) {
+			Plugin::SubmitResponseMessage submit_response_message;
+			submit_response_message.ParseFromString(data);
+			Plugin::ExecuteResponseMessage exec_response_message;
+			exec_response_message.mutable_header()->CopyFrom(submit_response_message.header());
+			for (int i=0;i<submit_response_message.payload_size();++i) {
+				Plugin::SubmitResponseMessage::Response p = submit_response_message.payload(i);
+				append_simple_exec_response_payload(exec_response_message.add_payload(), p.command(), gbp_status_to_gbp_nagios(p.status().status()), p.status().message());
+			}
+			data = exec_response_message.SerializeAsString();
+		}
+		void functions::make_exec_from_query(std::string &data) {
+			Plugin::QueryResponseMessage query_response_message;
+			query_response_message.ParseFromString(data);
+			Plugin::ExecuteResponseMessage exec_response_message;
+			exec_response_message.mutable_header()->CopyFrom(query_response_message.header());
+			for (int i=0;i<query_response_message.payload_size();++i) {
+				Plugin::QueryResponseMessage::Response p = query_response_message.payload(i);
+				std::string s = build_performance_data(p);
+				if (!s.empty())
+					s = p.message() + "|" + s;
+				else
+					s = p.message();
+				append_simple_exec_response_payload(exec_response_message.add_payload(), p.command(), p.result(), s);
+			}
+			data = exec_response_message.SerializeAsString();
+		}
+
+
+		void functions::make_return_header(::Plugin::Common_Header *target, const ::Plugin::Common_Header &source) {
+			target->CopyFrom(source);
+			target->set_source_id(target->recipient_id());
+		}
+
+		void functions::create_simple_query_request(std::wstring command, std::vector<std::wstring> arguments, std::string &buffer) {
+			Plugin::QueryRequestMessage message;
+			create_simple_header(message.mutable_header());
+
+			Plugin::QueryRequestMessage::Request *payload = message.add_payload();
+			payload->set_command(utf8::cvt<std::string>(command));
+
+			BOOST_FOREACH(std::wstring s, arguments)
+				payload->add_arguments(utf8::cvt<std::string>(s));
+
+			message.SerializeToString(&buffer);
+		}
+
+		void functions::create_simple_submit_request(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf, std::string &buffer) {
+			Plugin::SubmitRequestMessage message;
+			create_simple_header(message.mutable_header());
+			message.set_channel(utf8::cvt<std::string>(channel));
+
+			Plugin::QueryResponseMessage::Response *payload = message.add_payload();
+			payload->set_command(utf8::cvt<std::string>(command));
+			payload->set_message(utf8::cvt<std::string>(msg));
+			payload->set_result(nagios_status_to_gpb(ret));
+			if (!perf.empty())
+				parse_performance_data(payload, perf);
+
+			message.SerializeToString(&buffer);
+		}
+		void functions::create_simple_submit_response(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::string &buffer) {
+			Plugin::SubmitResponseMessage message;
+			create_simple_header(message.mutable_header());
+			//message.set_channel(to_string(channel));
+
+			Plugin::SubmitResponseMessage::Response *payload = message.add_payload();
+			payload->set_command(utf8::cvt<std::string>(command));
+			payload->mutable_status()->set_message(utf8::cvt<std::string>(msg));
+			payload->mutable_status()->set_status(status_to_gpb(ret));
+			message.SerializeToString(&buffer);
+		}
+		NSCAPI::errorReturn functions::parse_simple_submit_request(const std::string &request, std::wstring &source, std::wstring &command, std::wstring &msg, std::wstring &perf) {
+			Plugin::SubmitRequestMessage message;
+			message.ParseFromString(request);
+
+			if (message.payload_size() != 1) {
+				throw nscapi_exception("Whoops, invalid payload size (for now)");
+			}
+			Plugin::QueryResponseMessage::Response payload = message.payload().Get(0);
+			source = utf8::cvt<std::wstring>(payload.source());
+			command = utf8::cvt<std::wstring>(payload.command());
+			msg = utf8::cvt<std::wstring>(payload.message());
+			perf = utf8::cvt<std::wstring>(build_performance_data(payload));
+			return gbp_to_nagios_status(payload.result());
+		}
+		int functions::parse_simple_submit_request_payload(const Plugin::QueryResponseMessage::Response &payload, std::wstring &alias, std::wstring &message) {
+			alias = utf8::cvt<std::wstring>(payload.alias());
+			if (alias.empty())
+				alias = utf8::cvt<std::wstring>(payload.command());
+			message = utf8::cvt<std::wstring>(payload.message());
+			return gbp_to_nagios_status(payload.result());
+		}
+		void functions::parse_simple_query_request_payload(const Plugin::QueryRequestMessage::Request &payload, std::wstring &alias, std::wstring &command) {
+			alias = utf8::cvt<std::wstring>(payload.alias());
+			command = utf8::cvt<std::wstring>(payload.command());
+		}
+		NSCAPI::errorReturn functions::parse_simple_submit_response(const std::string &request, std::wstring &response) {
+			Plugin::SubmitResponseMessage message;
+			message.ParseFromString(request);
+
+			if (message.payload_size() != 1) {
+				throw nscapi_exception("Whoops, invalid payload size (for now)");
+			}
+			::Plugin::SubmitResponseMessage::Response payload = message.payload().Get(0);
+			response = utf8::cvt<std::wstring>(payload.mutable_status()->message());
+			return gbp_to_status(payload.mutable_status()->status());
+		}
+		NSCAPI::errorReturn functions::parse_simple_submit_response(const std::string &request, std::string response) {
+			Plugin::SubmitResponseMessage message;
+			message.ParseFromString(request);
+
+			if (message.payload_size() != 1) {
+				throw nscapi_exception("Whoops, invalid payload size (for now)");
+			}
+			::Plugin::SubmitResponseMessage::Response payload = message.payload().Get(0);
+			response = payload.mutable_status()->message();
+			return gbp_to_status(payload.mutable_status()->status());
+		}
+
+		void functions::create_simple_query_request(std::wstring command, std::list<std::wstring> arguments, std::string &buffer) {
+			Plugin::QueryRequestMessage message;
+			create_simple_header(message.mutable_header());
+
+			Plugin::QueryRequestMessage::Request *payload = message.add_payload();
+			payload->set_command(utf8::cvt<std::string>(command));
+
+			BOOST_FOREACH(std::wstring s, arguments)
+				payload->add_arguments(utf8::cvt<std::string>(s));
+
+			message.SerializeToString(&buffer);
+		}
+		NSCAPI::nagiosReturn functions::create_simple_query_response_unknown(std::wstring command, std::wstring msg, std::wstring perf, std::string &buffer) {
+			create_simple_query_response(command, NSCAPI::returnUNKNOWN, msg, perf, buffer);
+			return NSCAPI::returnUNKNOWN;
+		}
+		NSCAPI::nagiosReturn functions::create_simple_query_response_unknown(std::wstring command, std::wstring msg, std::string &buffer) {
+			create_simple_query_response(command, NSCAPI::returnUNKNOWN, msg, _T(""), buffer);
+			return NSCAPI::returnUNKNOWN;
+		}
+
+		void functions::create_simple_query_response(std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf, std::string &buffer) {
+			Plugin::QueryResponseMessage message;
+			create_simple_header(message.mutable_header());
+
+			append_simple_query_response_payload(message.add_payload(), command, ret, msg, perf);
+
+			message.SerializeToString(&buffer);
+		}
+
+
+		void functions::append_simple_submit_request_payload(Plugin::QueryResponseMessage::Response *payload, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf) {
+			payload->set_command(utf8::cvt<std::string>(command));
+			payload->set_message(utf8::cvt<std::string>(msg));
+			payload->set_result(nagios_status_to_gpb(ret));
+			if (!perf.empty())
+				parse_performance_data(payload, perf);
+		}
+
+		void functions::append_simple_query_response_payload(Plugin::QueryResponseMessage::Response *payload, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf) {
+			payload->set_command(utf8::cvt<std::string>(command));
+			payload->set_message(utf8::cvt<std::string>(msg));
+			payload->set_result(nagios_status_to_gpb(ret));
+			if (!perf.empty())
+				parse_performance_data(payload, perf);
+		}
+
+		void functions::append_simple_query_response_payload(Plugin::QueryResponseMessage::Response *payload, std::string command, NSCAPI::nagiosReturn ret, std::string msg, std::string perf) {
+			payload->set_command(utf8::cvt<std::string>(command));
+			payload->set_message(utf8::cvt<std::string>(msg));
+			payload->set_result(nagios_status_to_gpb(ret));
+			if (!perf.empty())
+				parse_performance_data(payload, perf);
+		}
+		void functions::append_simple_exec_response_payload(Plugin::ExecuteResponseMessage::Response *payload, std::string command, int ret, std::string msg) {
+			payload->set_command(command);
+			payload->set_message(msg);
+			payload->set_result(nagios_status_to_gpb(ret));
+		}
+		void functions::append_simple_submit_response_payload(Plugin::SubmitResponseMessage::Response *payload, std::string command, int ret, std::string msg) {
+			payload->set_command(command);
+			payload->mutable_status()->set_status(status_to_gpb(ret));
+			payload->mutable_status()->set_message(msg);
+		}
+
+
+		void functions::append_simple_query_request_payload(Plugin::QueryRequestMessage::Request *payload, std::wstring command, std::vector<std::wstring> arguments) {
+			payload->set_command(utf8::cvt<std::string>(command));
+			BOOST_FOREACH(const std::wstring &s, arguments) {
+				payload->add_arguments(utf8::cvt<std::string>(s));
+			}
+		}
+
+		void functions::append_simple_exec_request_payload(Plugin::ExecuteRequestMessage::Request *payload, std::wstring command, std::vector<std::wstring> arguments) {
+			payload->set_command(utf8::cvt<std::string>(command));
+			BOOST_FOREACH(const std::wstring &s, arguments) {
+				payload->add_arguments(utf8::cvt<std::string>(s));
+			}
+		}
+
+
+		functions::decoded_simple_command_data functions::parse_simple_query_request(const wchar_t* char_command, const std::string &request) {
+			decoded_simple_command_data data;
+
+			data.command = char_command;
+			Plugin::QueryRequestMessage message;
+			message.ParseFromString(request);
+
+			if (message.payload_size() != 1) {
+				throw nscapi_exception("Whoops, invalid payload size (for now)");
+			}
+			::Plugin::QueryRequestMessage::Request payload = message.payload().Get(0);
+			for (int i=0;i<payload.arguments_size();i++) {
+				data.args.push_back(utf8::cvt<std::wstring>(payload.arguments(i)));
+			}
+			return data;
+		}
+		functions::decoded_simple_command_data functions::parse_simple_query_request(const ::Plugin::QueryRequestMessage::Request &payload) {
+			decoded_simple_command_data data;
+			data.command = utf8::cvt<std::wstring>(payload.command());
+			for (int i=0;i<payload.arguments_size();i++) {
+				data.args.push_back(utf8::cvt<std::wstring>(payload.arguments(i)));
+			}
+			return data;
+		}
+
+		int functions::parse_simple_query_response(const std::string &response, std::wstring &msg, std::wstring &perf) {
+			Plugin::QueryResponseMessage message;
+			message.ParseFromString(response);
+
+
+			if (message.payload_size() == 0) {
+				return NSCAPI::returnUNKNOWN;
+			} else if (message.payload_size() > 1) {
+				throw nscapi_exception("Whoops, invalid payload size (for now)");
+			}
+
+			Plugin::QueryResponseMessage::Response payload = message.payload().Get(0);
+			msg = utf8::cvt<std::wstring>(payload.message());
+			perf = utf8::cvt<std::wstring>(build_performance_data(payload));
+			return gbp_to_nagios_status(payload.result());
+		}
+
+
+		//////////////////////////////////////////////////////////////////////////
+
+		void functions::create_simple_exec_request(const std::wstring &command, const std::list<std::wstring> & args, std::string &request) {
+
+			Plugin::ExecuteRequestMessage message;
+			create_simple_header(message.mutable_header());
+
+			Plugin::ExecuteRequestMessage::Request *payload = message.add_payload();
+			payload->set_command(utf8::cvt<std::string>(command));
+
+			BOOST_FOREACH(std::wstring s, args)
+				payload->add_arguments(utf8::cvt<std::string>(s));
+
+			message.SerializeToString(&request);
+		}
+		void functions::create_simple_exec_request(const std::wstring &command, const std::vector<std::wstring> & args, std::string &request) {
+
+			Plugin::ExecuteRequestMessage message;
+			create_simple_header(message.mutable_header());
+
+			Plugin::ExecuteRequestMessage::Request *payload = message.add_payload();
+			payload->set_command(utf8::cvt<std::string>(command));
+
+			BOOST_FOREACH(std::wstring s, args)
+				payload->add_arguments(utf8::cvt<std::string>(s));
+
+			message.SerializeToString(&request);
+		}
+		void functions::parse_simple_exec_result(const std::string &response, std::list<std::wstring> &result) {
+			Plugin::ExecuteResponseMessage message;
+			message.ParseFromString(response);
+
+			for (int i=0;i<message.payload_size(); i++) {
+				result.push_back(utf8::cvt<std::wstring>(message.payload(i).message()));
+			}
+		}
+		void functions::parse_simple_exec_result(const std::string &response, std::wstring &result) {
+			Plugin::ExecuteResponseMessage message;
+			message.ParseFromString(response);
+
+			for (int i=0;i<message.payload_size(); i++) {
+				result += utf8::cvt<std::wstring>(message.payload(i).message());
+			}
+		}
+
+		functions::decoded_simple_command_data functions::parse_simple_exec_request(const wchar_t* char_command, const std::string &request) {
+			Plugin::ExecuteRequestMessage message;
+			message.ParseFromString(request);
+
+			return parse_simple_exec_request(char_command, message);
+		}
+		functions::decoded_simple_command_data functions::parse_simple_exec_request(const std::wstring cmd, const Plugin::ExecuteRequestMessage &message) {
+			decoded_simple_command_data data;
+			data.command = cmd;
+			if (message.has_header())
+				data.target = utf8::cvt<std::wstring>(message.header().recipient_id());
+
+			if (message.payload_size() != 1) {
+				throw nscapi_exception("Whoops, invalid payload size (for now)");
+			}
+			Plugin::ExecuteRequestMessage::Request payload = message.payload().Get(0);
+			for (int i=0;i<payload.arguments_size();i++) {
+				data.args.push_back(utf8::cvt<std::wstring>(payload.arguments(i)));
+			}
+			return data;
+		}
+		functions::decoded_simple_command_data functions::parse_simple_exec_request_payload(const Plugin::ExecuteRequestMessage::Request &payload) {
+			decoded_simple_command_data data;
+			data.command = utf8::cvt<std::wstring>(payload.command());
+			for (int i=0;i<payload.arguments_size();i++) {
+				data.args.push_back(utf8::cvt<std::wstring>(payload.arguments(i)));
+			}
+			return data;
+		}
+
+
+		//////////////////////////////////////////////////////////////////////////
+
+		template<class T>
+		struct tokenizer_data {
+			T perf_lable_enclosure;						// '
+			T perf_separator;							// ' '
+			T perf_item_splitter;						// ; 
+			T perf_equal_sign;							// =
+			T perf_valid_number;						// 0123456789.,
+
+		};
+
+		template<class T>
+		void parse_performance_data_(Plugin::QueryResponseMessage::Response *payload, T &perf, tokenizer_data<T> tokenizer_data) {
+			while (true) {
+				if (perf.size() == 0)
+					return;
+				typename T::size_type p = 0;
+				if (perf[0] == tokenizer_data.perf_lable_enclosure[0]) {
+					p = perf.find(tokenizer_data.perf_lable_enclosure[0], 1)+1;
+					if (p == T::npos)
+						return;
+				}
+				p = perf.find(tokenizer_data.perf_separator, p);
+				if (p == 0)
+					return;
+				T chunk;
+				if (p == T::npos) {
+					chunk = perf;
+					perf = T();
+				} else {
+					chunk = perf.substr(0, p);
+					p = perf.find_first_not_of(tokenizer_data.perf_separator, p);
+					perf = perf.substr(p);
+				}
+				std::vector<T> items = strEx::splitV(chunk, tokenizer_data.perf_item_splitter);
+				if (items.size() < 1) {
+					Plugin::Common::PerformanceData* perfData = payload->add_perf();
+					perfData->set_type(Plugin::Common_DataType_STRING);
+					std::pair<T,T> fitem = strEx::split(T(), tokenizer_data.perf_equal_sign);
+					perfData->set_alias("invalid");
+					Plugin::Common_PerformanceData_StringValue* stringPerfData = perfData->mutable_string_value();
+					stringPerfData->set_value("invalid performance data");
+					break;
+				}
+
+				Plugin::Common::PerformanceData* perfData = payload->add_perf();
+				perfData->set_type(Plugin::Common_DataType_FLOAT);
+				std::pair<T,T> fitem = strEx::split(items[0], tokenizer_data.perf_equal_sign);
+				T alias = fitem.first;
+				if (alias.size() > 0 && alias[0] == tokenizer_data.perf_lable_enclosure[0] && alias[alias.size()-1] == tokenizer_data.perf_lable_enclosure[0])
+					alias = alias.substr(1, alias.size()-2);
+
+				perfData->set_alias(utf8::cvt<std::string>(alias));
+				Plugin::Common_PerformanceData_FloatValue* floatPerfData = perfData->mutable_float_value();
+
+				typename T::size_type pend = fitem.second.find_first_not_of(tokenizer_data.perf_valid_number);
+				if (pend == T::npos) {
+					floatPerfData->set_value(trim_to_double(fitem.second));
+				} else {
+					floatPerfData->set_value(trim_to_double(fitem.second.substr(0,pend)));
+					floatPerfData->set_unit(utf8::cvt<std::string>(fitem.second.substr(pend)));
+				}
+				if (items.size() > 2) {
+					floatPerfData->set_warning(trim_to_double(items[1]));
+					floatPerfData->set_critical(trim_to_double(items[2]));
+				}
+				if (items.size() >= 5) {
+					floatPerfData->set_minimum(trim_to_double(items[3]));
+					floatPerfData->set_maximum(trim_to_double(items[4]));
+				}
+			}
+		}
+		void functions::parse_performance_data(Plugin::QueryResponseMessage::Response *payload, std::wstring &perf) {
+			tokenizer_data<std::wstring> data;
+			data.perf_separator = _T(" ");
+			data.perf_lable_enclosure = _T("'");
+			data.perf_equal_sign = _T("=");
+			data.perf_item_splitter = _T(";");
+			data.perf_valid_number = _T("0123456789,.");
+			parse_performance_data_<std::wstring>(payload, perf, data);
+		}
+		void functions::parse_performance_data(Plugin::QueryResponseMessage::Response *payload, std::string &perf) {
+			tokenizer_data<std::string> data;
+			data.perf_separator = " ";
+			data.perf_lable_enclosure = "'";
+			data.perf_equal_sign = "=";
+			data.perf_item_splitter = ";";
+			data.perf_valid_number = "0123456789,.";
+			parse_performance_data_<std::string>(payload, perf, data);
+		}
+
+		std::string functions::build_performance_data(Plugin::QueryResponseMessage::Response const &payload) {
+			std::stringstream ss;
+			ss.precision(5);
+
+			bool first = true;
+			for (int i=0;i<payload.perf_size();i++) {
+				Plugin::Common::PerformanceData perfData = payload.perf(i);
+				if (!first)
+					ss << " ";
+				first = false;
+				ss << '\'' << perfData.alias() << "'=";
+				if (perfData.has_float_value()) {
+					Plugin::Common_PerformanceData_FloatValue fval = perfData.float_value();
+
+					ss << strEx::s::itos_non_sci(fval.value());
+					if (fval.has_unit())
+						ss << fval.unit();
+					if (!fval.has_warning())
+						continue;
+					ss << ";" << fval.warning();
+					if (!fval.has_critical())	
+						continue;
+					ss << ";" << fval.critical();
+					if (!fval.has_minimum())
+						continue;
+					ss << ";" << fval.minimum();
+					if (!fval.has_maximum())
+						continue;
+					ss << ";" << fval.maximum();
+				}
+			}
+			return ss.str();
+		}
+	}
+}
Index: include/nscapi/nscapi_protobuf_functions.hpp
===================================================================
--- include/nscapi/nscapi_protobuf_functions.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
+++ include/nscapi/nscapi_protobuf_functions.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -0,0 +1,194 @@
+/**************************************************************************
+*   Copyright (C) 2004-2007 by Michael Medin <michael@medin.name>         *
+*                                                                         *
+*   This code is part of NSClient++ - http://trac.nakednuns.org/nscp      *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU General Public License     *
+*   along with this program; if not, write to the                         *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#pragma once
+#include <string>
+#include <list>
+
+#include <NSCAPI.h>
+#include <nscapi/nscapi_protobuf_types.hpp>
+
+#include <protobuf/plugin.pb.h>
+
+#include <strEx.h>
+
+namespace nscapi {
+	namespace protobuf {	
+
+		class functions {
+		public:
+
+			typedef nscapi::protobuf::types::destination_container destination_container;
+			typedef nscapi::protobuf::types::decoded_simple_command_data decoded_simple_command_data;
+		public:
+			static Plugin::Common::ResultCode nagios_status_to_gpb(int ret) {
+				if (ret == NSCAPI::returnOK)
+					return Plugin::Common_ResultCode_OK;
+				if (ret == NSCAPI::returnWARN)
+					return Plugin::Common_ResultCode_WARNING;
+				if (ret == NSCAPI::returnCRIT)
+					return Plugin::Common_ResultCode_CRITCAL;
+				return Plugin::Common_ResultCode_UNKNOWN;
+			}
+			static int gbp_to_nagios_status(Plugin::Common::ResultCode ret) {
+				if (ret == Plugin::Common_ResultCode_OK)
+					return NSCAPI::returnOK;
+				if (ret == Plugin::Common_ResultCode_WARNING)
+					return NSCAPI::returnWARN;
+				if (ret == Plugin::Common_ResultCode_CRITCAL)
+					return NSCAPI::returnCRIT;
+				return NSCAPI::returnUNKNOWN;
+			}
+			static Plugin::Common::Status::StatusType status_to_gpb(int ret) {
+				if (ret == NSCAPI::isSuccess)
+					return Plugin::Common_Status_StatusType_OK;
+				return Plugin::Common_Status_StatusType_PROBLEM;
+			}
+			static int gbp_to_status(Plugin::Common::Status::StatusType ret) {
+				if (ret == Plugin::Common_Status_StatusType_OK)
+					return NSCAPI::isSuccess;
+				return NSCAPI::hasFailed;
+			}
+			static Plugin::Common::ResultCode gbp_status_to_gbp_nagios(Plugin::Common::Status::StatusType ret) {
+				if (ret == Plugin::Common_Status_StatusType_OK)
+					return Plugin::Common_ResultCode_OK;
+				return Plugin::Common_ResultCode_UNKNOWN;
+			}
+			static Plugin::Common::Status::StatusType gbp_to_nagios_gbp_status(Plugin::Common::ResultCode ret) {
+				if (ret == Plugin::Common_ResultCode_UNKNOWN||ret == Plugin::Common_ResultCode_WARNING||ret == Plugin::Common_ResultCode_CRITCAL)
+					return Plugin::Common_Status_StatusType_CRITICAL;
+				return Plugin::Common_Status_StatusType_OK;
+			}
+			
+			static Plugin::LogEntry::Entry::Level log_to_gpb(NSCAPI::messageTypes ret) {
+				if (ret == NSCAPI::log_level::critical)
+					return Plugin::LogEntry_Entry_Level_LOG_CRITICAL;
+				if (ret == NSCAPI::log_level::debug)
+					return Plugin::LogEntry_Entry_Level_LOG_DEBUG;
+				if (ret == NSCAPI::log_level::error)
+					return Plugin::LogEntry_Entry_Level_LOG_ERROR;
+				if (ret == NSCAPI::log_level::log)
+					return Plugin::LogEntry_Entry_Level_LOG_INFO;
+				if (ret == NSCAPI::log_level::info)
+					return Plugin::LogEntry_Entry_Level_LOG_INFO;
+				if (ret == NSCAPI::log_level::warning)
+					return Plugin::LogEntry_Entry_Level_LOG_WARNING;
+				return Plugin::LogEntry_Entry_Level_LOG_ERROR;
+			}
+			static NSCAPI::messageTypes gpb_to_log(Plugin::LogEntry::Entry::Level ret) {
+				if (ret == Plugin::LogEntry_Entry_Level_LOG_CRITICAL)
+					return NSCAPI::log_level::critical;
+				if (ret == Plugin::LogEntry_Entry_Level_LOG_DEBUG)
+					return NSCAPI::log_level::debug;
+				if (ret == Plugin::LogEntry_Entry_Level_LOG_ERROR)
+					return NSCAPI::log_level::error;
+				if (ret == Plugin::LogEntry_Entry_Level_LOG_INFO)
+					return NSCAPI::log_level::info;
+				if (ret == Plugin::LogEntry_Entry_Level_LOG_WARNING)
+					return NSCAPI::log_level::warning;
+				return NSCAPI::log_level::error;
+			}
+
+
+			static void create_simple_header(Plugin::Common::Header* hdr);
+			static void add_host(Plugin::Common::Header* hdr, const destination_container &dst);
+			static bool parse_destination(const ::Plugin::Common_Header &header, const std::string tag, destination_container &data, const bool expand_meta = false);
+
+			static void make_submit_from_query(std::string &message, const std::wstring channel, const std::wstring alias = _T(""), const std::wstring target = _T(""));
+			static void make_query_from_exec(std::string &data);
+			static void make_query_from_submit(std::string &data);
+			static void make_exec_from_submit(std::string &data);
+			static void make_exec_from_query(std::string &data);
+			static void make_return_header(::Plugin::Common_Header *target, const ::Plugin::Common_Header &source);
+
+			static void create_simple_query_request(std::wstring command, std::vector<std::wstring> arguments, std::string &buffer);
+			static void create_simple_submit_request(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf, std::string &buffer);
+			static void create_simple_submit_response(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::string &buffer);
+			static NSCAPI::errorReturn parse_simple_submit_request(const std::string &request, std::wstring &source, std::wstring &command, std::wstring &msg, std::wstring &perf);
+			static int parse_simple_submit_request_payload(const Plugin::QueryResponseMessage::Response &payload, std::wstring &alias, std::wstring &message);
+			static void parse_simple_query_request_payload(const Plugin::QueryRequestMessage::Request &payload, std::wstring &alias, std::wstring &command);
+			static NSCAPI::errorReturn parse_simple_submit_response(const std::string &request, std::wstring &response);
+			static NSCAPI::errorReturn parse_simple_submit_response(const std::string &request, std::string response);
+			static void create_simple_query_request(std::wstring command, std::list<std::wstring> arguments, std::string &buffer);
+			static NSCAPI::nagiosReturn create_simple_query_response_unknown(std::wstring command, std::wstring msg, std::wstring perf, std::string &buffer);
+			static NSCAPI::nagiosReturn create_simple_query_response_unknown(std::wstring command, std::wstring msg, std::string &buffer);
+			static void create_simple_query_response(std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf, std::string &buffer);
+			static void append_simple_submit_request_payload(Plugin::QueryResponseMessage::Response *payload, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf = _T(""));
+			static void append_simple_query_response_payload(Plugin::QueryResponseMessage::Response *payload, std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf);
+
+
+			static void append_simple_query_response_payload(Plugin::QueryResponseMessage::Response *payload, std::string command, NSCAPI::nagiosReturn ret, std::string msg, std::string perf = "");
+			static void append_simple_exec_response_payload(Plugin::ExecuteResponseMessage::Response *payload, std::string command, int ret, std::string msg);
+			static void append_simple_submit_response_payload(Plugin::SubmitResponseMessage::Response *payload, std::string command, int ret, std::string msg);
+			static void append_simple_query_request_payload(Plugin::QueryRequestMessage::Request *payload, std::wstring command, std::vector<std::wstring> arguments);
+			static void append_simple_exec_request_payload(Plugin::ExecuteRequestMessage::Request *payload, std::wstring command, std::vector<std::wstring> arguments);
+			static decoded_simple_command_data parse_simple_query_request(const wchar_t* char_command, const std::string &request);
+			static decoded_simple_command_data parse_simple_query_request(const ::Plugin::QueryRequestMessage::Request &payload);
+			static int parse_simple_query_response(const std::string &response, std::wstring &msg, std::wstring &perf);
+			static void create_simple_exec_request(const std::wstring &command, const std::list<std::wstring> & args, std::string &request);
+			static void create_simple_exec_request(const std::wstring &command, const std::vector<std::wstring> & args, std::string &request);
+			static void parse_simple_exec_result(const std::string &response, std::list<std::wstring> &result);
+			static void parse_simple_exec_result(const std::string &response, std::wstring &result);
+
+			template<class T>
+			static void append_response_payloads(T &target_message, std::string &payload) {
+				T source_message;
+				source_message.ParseFromString(payload);
+				for (int i=0;i<source_message.payload_size();++i)
+					target_message.add_payload()->CopyFrom(source_message.payload(i));
+			}
+
+			template<class T>
+			static int create_simple_exec_response(T command, NSCAPI::nagiosReturn ret, T result, std::string &response) {
+				Plugin::ExecuteResponseMessage message;
+				create_simple_header(message.mutable_header());
+
+				Plugin::ExecuteResponseMessage::Response *payload = message.add_payload();
+				payload->set_command(utf8::cvt<std::string>(command));
+				payload->set_message(utf8::cvt<std::string>(result));
+
+				payload->set_result(nagios_status_to_gpb(ret));
+				message.SerializeToString(&response);
+				return ret;
+			}
+			template<class T>
+			static int create_simple_exec_response_unknown(T command, T result, std::string &response) {
+				Plugin::ExecuteResponseMessage message;
+				create_simple_header(message.mutable_header());
+
+				Plugin::ExecuteResponseMessage::Response *payload = message.add_payload();
+				payload->set_command(utf8::cvt<std::string>(command));
+				payload->set_message(utf8::cvt<std::string>(result));
+
+				payload->set_result(nagios_status_to_gpb(NSCAPI::returnUNKNOWN));
+				message.SerializeToString(&response);
+				return NSCAPI::returnUNKNOWN;
+			}
+			static decoded_simple_command_data parse_simple_exec_request(const wchar_t* char_command, const std::string &request);
+			static decoded_simple_command_data parse_simple_exec_request(const std::wstring cmd, const Plugin::ExecuteRequestMessage &message);
+			static decoded_simple_command_data parse_simple_exec_request_payload(const Plugin::ExecuteRequestMessage::Request &payload);
+
+			static void parse_performance_data(Plugin::QueryResponseMessage::Response *payload, std::wstring &perf);
+			static void parse_performance_data(Plugin::QueryResponseMessage::Response *payload, std::string &perf);
+			static std::string build_performance_data(Plugin::QueryResponseMessage::Response const &payload);
+		};
+	}
+	typedef protobuf::functions functions;
+}
Index: include/nscapi/nscapi_protobuf_types.cpp
===================================================================
--- include/nscapi/nscapi_protobuf_types.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
+++ include/nscapi/nscapi_protobuf_types.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -0,0 +1,70 @@
+/**************************************************************************
+*   Copyright (C) 2004-2007 by Michael Medin <michael@medin.name>         *
+*                                                                         *
+*   This code is part of NSClient++ - http://trac.nakednuns.org/nscp      *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU General Public License     *
+*   along with this program; if not, write to the                         *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#include <nscapi/nscapi_protobuf_types.hpp>
+
+namespace nscapi {
+	namespace protobuf {
+		namespace types {
+			std::string destination_container::to_string() {
+				std::stringstream ss;
+				ss << "id: " << id;
+				ss << ", address: " << address.to_string();
+				ss << ", comment: " << comment;
+				int i=0;
+				BOOST_FOREACH(std::string a, tags) {
+					ss << ", tags[" << i++ << "]: " << a;
+				}
+				BOOST_FOREACH(const data_map::value_type &kvp, data) {
+					ss << ", data[" << kvp.first << "]: " << kvp.second;
+				}
+				return ss.str();
+			}
+
+			void destination_container::import(const destination_container &other) {
+				if (id.empty() && !other.id.empty())
+					id = other.id;
+				address.import(other.address);
+				if (comment.empty() && !other.comment.empty())
+					comment = other.comment;
+				BOOST_FOREACH(const std::string &t, other.tags) {
+					tags.insert(t);
+				}
+				BOOST_FOREACH(const data_map::value_type &kvp, other.data) {
+					if (data.find(kvp.first) == data.end())
+						data[kvp.first] = kvp.second;
+				}
+			}
+			void destination_container::apply(const destination_container &other) {
+				if (!other.id.empty())
+					id = other.id;
+				address.apply(other.address);
+				if (!other.comment.empty())
+					comment = other.comment;
+				BOOST_FOREACH(const std::string &t, other.tags) {
+					tags.insert(t);
+				}
+				BOOST_FOREACH(const data_map::value_type &kvp, other.data) {
+					data[kvp.first] = kvp.second;
+				}
+			}
+		}
+	}
+}
Index: include/nscapi/nscapi_protobuf_types.hpp
===================================================================
--- include/nscapi/nscapi_protobuf_types.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
+++ include/nscapi/nscapi_protobuf_types.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -0,0 +1,122 @@
+/**************************************************************************
+*   Copyright (C) 2004-2007 by Michael Medin <michael@medin.name>         *
+*                                                                         *
+*   This code is part of NSClient++ - http://trac.nakednuns.org/nscp      *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU General Public License     *
+*   along with this program; if not, write to the                         *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#pragma once
+
+#include <string>
+#include <list>
+#include <set>
+#include <map>
+
+#include <unicode_char.hpp>
+
+#include <NSCAPI.h>
+#include <net/net.hpp>
+
+namespace nscapi {
+	namespace protobuf {
+		namespace types {
+	
+			struct decoded_simple_command_data {
+				std::wstring command;
+				std::wstring target;
+				std::list<std::wstring> args;
+			};
+
+			struct destination_container {
+				std::string id;
+				net::url address;
+				std::string comment;
+				std::set<std::string> tags;
+				typedef std::map<std::string,std::string> data_map;
+				data_map data;
+				void set_host(std::string value) {
+					address.host = value;
+				}
+				void set_address(std::string value) {
+					address = net::parse(value);
+				}
+				void set_port(std::string value) {
+					address.port = strEx::stoi(value);
+				}
+				std::string get_protocol() const {
+					return address.protocol;
+				}
+				bool has_protocol() const {
+					return !address.protocol.empty();
+				}
+
+				static bool to_bool(std::string value, bool def = false) {
+					if (value.empty())
+						return def;
+					if (value == "true" || value == "1" || value == "True")
+						return true;
+					return false;
+				}
+				static int to_int(std::string value, int def = 0) {
+					if (value.empty())
+						return def;
+					try {
+						return boost::lexical_cast<int>(value);
+					} catch (...) {
+						return def;
+					}
+				}
+
+				inline int get_int_data(std::string key, int def = 0) {
+					return to_int(data[key], def);
+				}
+				inline bool get_bool_data(std::string key, bool def = false) {
+					return to_bool(data[key], def);
+				}
+				inline std::string get_string_data(std::string key, std::string def = "") {
+					data_map::iterator it = data.find(key);
+					if (it == data.end())
+						return def;
+					return it->second;
+				}
+				inline bool has_data(std::string key) {
+					return data.find(key) != data.end();
+				}
+
+				void set_string_data(std::string key, std::string value) {
+					if (key == "host")
+						set_host(value);
+					else 
+						data[key] = value;
+				}
+				void set_int_data(std::string key, int value) {
+					if (key == "port")
+						address.port = value;
+					else 
+						data[key] = boost::lexical_cast<std::string>(value);
+				}
+				void set_bool_data(std::string key, bool value) {
+					data[key] = value?"true":"false";
+				}
+
+				std::string to_string();
+				void import(const destination_container &other);
+				void apply(const destination_container &other);
+			};
+		};
+
+	};
+}
Index: include/nscapi/nscapi_targets.cpp
===================================================================
--- include/nscapi/nscapi_targets.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
+++ include/nscapi/nscapi_targets.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -0,0 +1,2 @@
+#include <nscapi/nscapi_targets.hpp>
+
Index: include/nscapi/nscapi_targets.hpp
===================================================================
--- include/nscapi/nscapi_targets.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
+++ include/nscapi/nscapi_targets.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -0,0 +1,172 @@
+#pragma once
+
+#include <map>
+#include <string>
+
+#include <boost/foreach.hpp>
+#include <boost/optional.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <settings/client/settings_client.hpp>
+#include <nscapi/settings_proxy.hpp>
+#include <nscapi/settings_object.hpp>
+#include <nscapi/nscapi_protobuf_types.hpp>
+
+#include <net/net.hpp>
+
+namespace nscapi {
+	namespace targets {
+		struct target_object {
+
+			std::wstring path;
+			std::wstring alias;
+			std::wstring value;
+			std::wstring parent;
+			bool is_template;
+
+			net::wurl address;
+			typedef std::map<std::wstring,std::wstring> options_type;
+			options_type options;
+
+			std::wstring to_wstring() const {
+				std::wstringstream ss;
+				ss << _T("Target: ") << alias;
+				ss << _T(", address: ") << get_address();
+				ss << _T(", parent: ") << parent;
+				ss << _T(", is_template: ") << is_template;
+				BOOST_FOREACH(options_type::value_type o, options) {
+					ss << _T(", option[") << o.first << _T("]: ") << o.second;
+				}
+				return ss.str();
+			}
+			std::wstring get_address() const {
+				return address.to_string();
+			}
+			void set_address(std::wstring value) {
+				net::wurl n = net::parse(value);
+				address.apply(n);
+			}
+			void set_host(std::wstring value) {
+				address.host = value;
+			}
+			void set_port(int value) {
+				address.port = value;
+			}
+			bool has_option(std::wstring key) const {
+				return options.find(key) != options.end();
+			}
+			bool has_option(std::string key) const {
+				return has_option(utf8::cvt<std::wstring>(key));
+			}
+			void set_property_int(std::wstring key, int value) {
+				if (key == _T("port")) {
+					set_port(value);
+				} else 
+					options[key] = strEx::itos(value);
+			}
+			void set_property_bool(std::wstring key, bool value) {
+				options[key] = value?_T("true"):_T("false");
+			}
+			void set_property_string(std::wstring key, std::wstring value) {
+				if (key == _T("host")) {
+					set_host(value);
+				} else 
+					options[key] = value;
+			}
+
+			nscapi::protobuf::types::destination_container to_destination_container() const {
+				nscapi::protobuf::types::destination_container ret;
+				if (!alias.empty())
+					ret.id = utf8::cvt<std::string>(alias);
+				ret.address.apply(net::wide_to_url(address));
+				BOOST_FOREACH(const options_type::value_type &kvp, options) {
+					ret.data[utf8::cvt<std::string>(kvp.first)] = utf8::cvt<std::string>(kvp.second);
+				}
+				return ret;
+			}
+
+		};
+		typedef boost::optional<target_object> optional_target_object;
+		typedef std::map<std::wstring,std::wstring> targets_type;
+
+		struct target_object_reader {
+			typedef target_object object_type;
+			static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object);
+			static void apply_parent(object_type &object, object_type &parent);
+		};
+
+		namespace sh = nscapi::settings_helper;
+		struct dummy_custom_reader {
+			typedef target_object object_type;
+			static void add_custom_keys(sh::settings_registry &settings, boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object) {}
+		};
+
+		template<class custom_reader>
+		struct split_object_reader {
+			typedef target_object object_type;
+
+			static void post_process_object(object_type &object) {
+				custom_reader::post_process_target(object);
+			}
+
+			static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object) {
+				object.address = net::parse(object.value, 0);
+				if (object.alias == _T("default"))
+					custom_reader::init_default(object);
+
+				nscapi::settings_helper::settings_registry settings(proxy);
+
+				object_type::options_type options;
+				settings.path(object.path).add_path()
+					(object.alias, nscapi::settings_helper::wstring_map_path(&options), 
+					_T("TARGET DEFENITION"), _T("Target definition for: ") + object.alias)
+
+					;
+
+				settings.path(object.path).add_key()
+
+					(_T("address"), sh::string_fun_key<std::wstring>(boost::bind(&object_type::set_address, &object, _1)),
+					_T("TARGET ADDRESS"), _T("Target host address"))
+
+					(_T("host"), sh::string_fun_key<std::wstring>(boost::bind(&object_type::set_host, &object, _1)),
+					_T("TARGET HOST"), _T("The target server to report results to."))
+
+					(_T("port"), sh::int_fun_key<int>(boost::bind(&object_type::set_port, &object, _1)),
+					_T("TARGET PORT"), _T("The target server port"))
+
+					(_T("alias"), nscapi::settings_helper::wstring_key(&object.alias, object.alias),
+					_T("TARGET ALIAS"), _T("The alias for the target"))
+
+					(_T("parent"), nscapi::settings_helper::wstring_key(&object.parent, _T("default")),
+					_T("TARGET PARENT"), _T("The parent the target inherits from"))
+
+					(_T("is template"), nscapi::settings_helper::bool_key(&object.is_template, false),
+					_T("IS TEMPLATE"), _T("Declare this object as a template (this means it will not be avalible as a separate object)"))
+
+					;
+				custom_reader::add_custom_keys(settings, proxy, object);
+
+				settings.register_all();
+				settings.notify();
+
+				BOOST_FOREACH(const object_type::options_type::value_type &kvp, options) {
+					if (!object.has_option(kvp.first))
+						object.options[kvp.first] = kvp.second;
+				}
+
+			}
+
+			static void apply_parent(object_type &object, object_type &parent) {
+				object.address.import(parent.address);
+				BOOST_FOREACH(object_type::options_type::value_type i, parent.options) {
+					if (object.options.find(i.first) == object.options.end())
+						object.options[i.first] = i.second;
+				}
+			}
+
+		};
+		template<class custom_reader>
+		struct handler : public nscapi::settings_objects::object_handler<target_object, split_object_reader<custom_reader > > {};
+	}
+}
+
Index: include/nscapi/plugin.hpp
===================================================================
--- include/nscapi/plugin.hpp	(revision d66ccee5a63e30c64888165cea934f981285a5c3)
+++ include/nscapi/plugin.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -7,2 +7,3 @@
 #include <nscapi/nscapi_plugin_wrapper.hpp>
 #include <nscapi/nscapi_core_wrapper.hpp>
+#include <nscapi/nscapi_plugin_impl.hpp>
Index: clude/nscapi/targets.cpp
===================================================================
--- include/nscapi/targets.cpp	(revision e396b2ff5c993ba5464a6f4e5b07d9677acb553a)
+++ 	(revision )
@@ -1,2 +1,0 @@
-#include <nscapi/targets.hpp>
-
Index: include/nscapi/targets.hpp
===================================================================
--- include/nscapi/targets.hpp	(revision 76540c3258457ff0a673332e8da29bcce161e942)
+++ include/nscapi/targets.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -1,172 +1,5 @@
 #pragma once
+// For legacy use only, dont use!
 
-#include <map>
-#include <string>
+#include <nscapi/nscapi_targets.hpp>
 
-#include <boost/foreach.hpp>
-#include <boost/optional.hpp>
-#include <boost/shared_ptr.hpp>
-
-#include <settings/client/settings_client.hpp>
-#include <nscapi/settings_proxy.hpp>
-#include <nscapi/settings_object.hpp>
-#include <nscapi/functions.hpp>
-
-#include <net/net.hpp>
-
-namespace nscapi {
-	namespace targets {
-		struct target_object {
-
-			std::wstring path;
-			std::wstring alias;
-			std::wstring value;
-			std::wstring parent;
-			bool is_template;
-
-			net::wurl address;
-			typedef std::map<std::wstring,std::wstring> options_type;
-			options_type options;
-
-			std::wstring to_wstring() const {
-				std::wstringstream ss;
-				ss << _T("Target: ") << alias;
-				ss << _T(", address: ") << get_address();
-				ss << _T(", parent: ") << parent;
-				ss << _T(", is_template: ") << is_template;
-				BOOST_FOREACH(options_type::value_type o, options) {
-					ss << _T(", option[") << o.first << _T("]: ") << o.second;
-				}
-				return ss.str();
-			}
-			std::wstring get_address() const {
-				return address.to_string();
-			}
-			void set_address(std::wstring value) {
-				net::wurl n = net::parse(value);
-				address.apply(n);
-			}
-			void set_host(std::wstring value) {
-				address.host = value;
-			}
-			void set_port(int value) {
-				address.port = value;
-			}
-			bool has_option(std::wstring key) const {
-				return options.find(key) != options.end();
-			}
-			bool has_option(std::string key) const {
-				return has_option(utf8::cvt<std::wstring>(key));
-			}
-			void set_property_int(std::wstring key, int value) {
-				if (key == _T("port")) {
-					set_port(value);
-				} else 
-					options[key] = strEx::itos(value);
-			}
-			void set_property_bool(std::wstring key, bool value) {
-				options[key] = value?_T("true"):_T("false");
-			}
-			void set_property_string(std::wstring key, std::wstring value) {
-				if (key == _T("host")) {
-					set_host(value);
-				} else 
-					options[key] = value;
-			}
-
-			nscapi::functions::destination_container to_destination_container() const {
-				nscapi::functions::destination_container ret;
-				if (!alias.empty())
-					ret.id = utf8::cvt<std::string>(alias);
-				ret.address.apply(net::wide_to_url(address));
-				BOOST_FOREACH(const options_type::value_type &kvp, options) {
-					ret.data[utf8::cvt<std::string>(kvp.first)] = utf8::cvt<std::string>(kvp.second);
-				}
-				return ret;
-			}
-
-		};
-		typedef boost::optional<target_object> optional_target_object;
-		typedef std::map<std::wstring,std::wstring> targets_type;
-
-		struct target_object_reader {
-			typedef target_object object_type;
-			static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object);
-			static void apply_parent(object_type &object, object_type &parent);
-		};
-
-		namespace sh = nscapi::settings_helper;
-		struct dummy_custom_reader {
-			typedef target_object object_type;
-			static void add_custom_keys(sh::settings_registry &settings, boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object) {}
-		};
-
-		template<class custom_reader>
-		struct split_object_reader {
-			typedef target_object object_type;
-
-			static void post_process_object(object_type &object) {
-				custom_reader::post_process_target(object);
-			}
-
-			static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object) {
-				object.address = net::parse(object.value, 0);
-				if (object.alias == _T("default"))
-					custom_reader::init_default(object);
-
-				nscapi::settings_helper::settings_registry settings(proxy);
-
-				object_type::options_type options;
-				settings.path(object.path).add_path()
-					(object.alias, nscapi::settings_helper::wstring_map_path(&options), 
-					_T("TARGET DEFENITION"), _T("Target definition for: ") + object.alias)
-
-					;
-
-				settings.path(object.path).add_key()
-
-					(_T("address"), sh::string_fun_key<std::wstring>(boost::bind(&object_type::set_address, &object, _1)),
-					_T("TARGET ADDRESS"), _T("Target host address"))
-
-					(_T("host"), sh::string_fun_key<std::wstring>(boost::bind(&object_type::set_host, &object, _1)),
-					_T("TARGET HOST"), _T("The target server to report results to."))
-
-					(_T("port"), sh::int_fun_key<int>(boost::bind(&object_type::set_port, &object, _1)),
-					_T("TARGET PORT"), _T("The target server port"))
-
-					(_T("alias"), nscapi::settings_helper::wstring_key(&object.alias, object.alias),
-					_T("TARGET ALIAS"), _T("The alias for the target"))
-
-					(_T("parent"), nscapi::settings_helper::wstring_key(&object.parent, _T("default")),
-					_T("TARGET PARENT"), _T("The parent the target inherits from"))
-
-					(_T("is template"), nscapi::settings_helper::bool_key(&object.is_template, false),
-					_T("IS TEMPLATE"), _T("Declare this object as a template (this means it will not be avalible as a separate object)"))
-
-					;
-				custom_reader::add_custom_keys(settings, proxy, object);
-
-				settings.register_all();
-				settings.notify();
-
-				BOOST_FOREACH(const object_type::options_type::value_type &kvp, options) {
-					if (!object.has_option(kvp.first))
-						object.options[kvp.first] = kvp.second;
-				}
-
-			}
-
-			static void apply_parent(object_type &object, object_type &parent) {
-				object.address.import(parent.address);
-				BOOST_FOREACH(object_type::options_type::value_type i, parent.options) {
-					if (object.options.find(i.first) == object.options.end())
-						object.options[i.first] = i.second;
-				}
-			}
-
-		};
-		template<class custom_reader>
-		struct handler : public nscapi::settings_objects::object_handler<target_object, split_object_reader<custom_reader > > {};
-	}
-}
-
Index: include/settings/macros.h
===================================================================
--- include/settings/macros.h	(revision 7ec3dd1fd472743bd1d0420af09e8f962665441f)
+++ include/settings/macros.h	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -45,7 +45,4 @@
 	setting_keys::key ## _PATH, setting_keys::key ## _TITLE, setting_keys::key ## _DESC, setting_keys::key ## _ADVANCED
 
-
-
-
 #define GENERIC_KEY_ALLOWED_HOSTS "allowed hosts"
 #define GENERIC_KEY_BIND_TO "bind to"
@@ -63,357 +60,7 @@
 #define NS_REG_ROOT _T("SOFTWARE\\NSClient++")
 
-
-
 namespace setting_keys {
-
-#define DEFAULT_PROTOCOL_SECTION "/protocols/default"
-#define NSCLIENT_SECTION "/protocols/NSClient"
-#define NRPE_SECTION_PROTOCOL "/protocols/NRPE"
-#define DEFAULT_SECTION "/settings"
-#define NRPE_SECTION "/settings/NRPE"
-#define NRPE_CLIENT_HANDLER_SECTION "/settings/NRPE/client/handlers"
-#define NRPE_SECTION_HANDLERS "/settings/NRPE/Handlers"
 #define MAIN_MODULES_SECTION _T("/modules")
-#define EVENT_LOG_SECTION "/settings/eventlog"
-#define EXTSCRIPT_SECTION "/settings/external scripts"
-#define EXTSCRIPT_SCRIPT_SECTION "/settings/external scripts/scripts"
-#define EXTSCRIPT_ALIAS_SECTION "/settings/external scripts/alias"
-#define EXTSCRIPT_WRAPPINGS_SECTION "/settings/external scripts/wrappings"
-#define EXTSCRIPT_WRAPPED_SCRIPT "/settings/external scripts/wrapped scripts"
 #define CHECK_SYSTEM_SECTION "/settings/system"
 #define CHECK_SYSTEM_COUNTERS_SECTION "/settings/system/PDH counters"
-#define CHECK_SYSTEM_SERVICES_SECTION "/settings/system/services"
-#define NSCA_SECTION "/settings/NSCA"
-#define SCHEDULER_SECTION "/settings/scheduler"
-#define SCHEDULER_SECTION_SCH "/settings/scheduler/schedules"
-#define SCHEDULER_SECTION_FAKE "/settings/scheduler/schedules/<schedule name>"
-#define SCHEDULER_SECTION_DEF "/settings/scheduler/default"
-#define NSCA_SERVER_SECTION "/settings/NSCA/server"
-#define NSCA_CMD_SECTION "/settings/NSCA/server/commands"
-#define TASK_SCHED_SECTION "/settings/Task Scheduler"
-#define LUA_SECTION "/settings/Lua/script"
-#define LOG_SECTION "/settings/log"
-
-#define CHECK_DISK_SECTION "/settings/check/disk"
-	namespace settings_def {
-		DEFINE_SETTING_I(PAYLOAD_LEN, DEFAULT_SECTION, "payload length", 4096);
-		DESCRIBE_SETTING(PAYLOAD_LEN, "PAYLOAD LENGTH", "...");
-
-		DEFINE_SETTING_B(SHARED_SESSION, DEFAULT_SECTION, "shared session", true);
-		DESCRIBE_SETTING(SHARED_SESSION, "SHARED SESSION", "TODO");
-
-		DEFINE_SETTING_S(SYSTRAY_EXE, DEFAULT_SECTION, "systray_exe", "nstray.exe");
-		DESCRIBE_SETTING(SYSTRAY_EXE, "TODO", "TODO");
-	}
-/*
-
-	*/
-/*
-	// NSClient Setting headlines
-	namespace nrpe {
-		DEFINE_PATH(SECTION, NRPE_SECTION_PROTOCOL);
-		//DESCRIBE_SETTING(SECTION, "NRPE SECTION", "Section for NRPE (NRPEListener.dll) (check_nrpe) protocol options.");
-
-		
-		DEFINE_PATH(CH_SECTION, NRPE_CLIENT_HANDLER_SECTION);
-		//DESCRIBE_SETTING(CH_SECTION, "CLIENT HANDLER SECTION", "...");
-
-		DEFINE_SETTING_S(ALLOWED_HOSTS, NRPE_SECTION_PROTOCOL, GENERIC_KEY_ALLOWED_HOSTS, "");
-		DESCRIBE_SETTING(ALLOWED_HOSTS, "ALLOWED HOST ADDRESSES", "This is a comma-delimited list of IP address of hosts that are allowed to talk to NSClient deamon. If you leave this blank the global version will be used instead.");
-
-		DEFINE_SETTING_I(PORT, NRPE_SECTION_PROTOCOL, "port", 5666);
-		//DESCRIBE_SETTING(PORT, "NSCLIENT PORT NUMBER", "This is the port the NSClientListener.dll will listen to.");
-
-		DEFINE_SETTING_S(BINDADDR, NRPE_SECTION_PROTOCOL, GENERIC_KEY_BIND_TO, "");
-		//DESCRIBE_SETTING(BINDADDR, "BIND TO ADDRESS", "Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname. Leaving this blank will bind to all avalible IP adresses.");
-
-		DEFINE_SETTING_I(READ_TIMEOUT, NRPE_SECTION_PROTOCOL, GENERIC_KEY_SOCK_READ_TIMEOUT, 30);
-		//DESCRIBE_SETTING(READ_TIMEOUT, "SOCKET TIMEOUT", "Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out.");
-
-		DEFINE_SETTING_I(LISTENQUE, NRPE_SECTION_PROTOCOL, GENERIC_KEY_SOCK_LISTENQUE, 0);
-		//DESCRIBE_SETTING_ADVANCED(LISTENQUE, "LISTEN QUEUE", "Number of sockets to queue before starting to refuse new incoming connections. This can be used to tweak the amount of simultaneous sockets that the server accepts.");
-
-		DEFINE_SETTING_I(THREAD_POOL, NRPE_SECTION_PROTOCOL, "thread pool", 10);
-		//DESCRIBE_SETTING_ADVANCED(THREAD_POOL, "THREAD POOL", "");
-
-		
-
-		DEFINE_SETTING_B(CACHE_ALLOWED, NRPE_SECTION_PROTOCOL, GENERIC_KEY_SOCK_CACHE_ALLOWED, false);
-		DESCRIBE_SETTING_ADVANCED(CACHE_ALLOWED, "ALLOWED HOSTS CACHING", "Used to cache looked up hosts if you check dynamic/changing hosts set this to false.");
-
-		//DEFINE_SETTING_B(KEYUSE_SSL, NRPE_SECTION_PROTOCOL, GENERIC_KEY_USE_SSL, true);
-		//DESCRIBE_SETTING(KEYUSE_SSL, "USE SSL SOCKET", "This option controls if SSL should be used on the socket.");
-
-		//DEFINE_SETTING_I(PAYLOAD_LENGTH, NRPE_SECTION_PROTOCOL, "payload length", 1024);
-		//DESCRIBE_SETTING_ADVANCED(PAYLOAD_LENGTH, "PAYLOAD LENGTH", "Length of payload to/from the NRPE agent. This is a hard specific value so you have to \"configure\" (read recompile) your NRPE agent to use the same value for it to work.");
-
-		//DEFINE_SETTING_B(ALLOW_PERFDATA, NRPE_SECTION, "performance data", true);
-		//DESCRIBE_SETTING_ADVANCED(ALLOW_PERFDATA, "PERFORMANCE DATA", "Send performance data back to nagios (set this to 0 to remove all performance data).");
-
-		//DEFINE_SETTING_I(CMD_TIMEOUT, NRPE_SECTION, "command timeout", 60);
-		//DESCRIBE_SETTING(CMD_TIMEOUT, "COMMAND TIMEOUT", "This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off.");
-
-		DEFINE_SETTING_B(ALLOW_ARGS, NRPE_SECTION, "allow arguments", false);
-		//DESCRIBE_SETTING(ALLOW_ARGS, "COMMAND ARGUMENT PROCESSING", "This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed.");
-
-		DEFINE_SETTING_B(ALLOW_NASTY, NRPE_SECTION, "allow nasy characters", false);
-		//DESCRIBE_SETTING(ALLOW_NASTY, "COMMAND ALLOW NASTY META CHARS", "This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'\"\\[]{}) characters in arguments.");
-
-	}
-*/
-/*
-	namespace protocol_def {
-		DEFINE_SETTING_S(ALLOWED_HOSTS, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_ALLOWED_HOSTS, "");
-		DESCRIBE_SETTING(ALLOWED_HOSTS, "ALLOWED HOST ADDRESSES", "This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons. If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password). The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access");
-
-		DEFINE_SETTING_B(CACHE_ALLOWED, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_SOCK_CACHE_ALLOWED, false);
-		//DESCRIBE_SETTING_ADVANCED(CACHE_ALLOWED, "ALLOWED HOSTS CACHING", "Used to cache looked up hosts if you check dynamic/changing hosts set this to false.");
-
-		DEFINE_SETTING_S(MASTER_KEY, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_PWD_MASTER_KEY, "This is a secret key that you should change");
-		//DESCRIBE_SETTING(MASTER_KEY, "MASTER KEY", "The secret \"key\" used when (de)obfuscating passwords.");
-
-		DEFINE_SETTING_S(PWD, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_PWD, "");
-		//DESCRIBE_SETTING(PWD, "PASSWORD", "This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.");
-
-		DEFINE_SETTING_S(OBFUSCATED_PWD, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_OBFUSCATED_PWD, "");
-		//DESCRIBE_SETTING(OBFUSCATED_PWD, "OBFUSCATED PASSWORD", "This is the same as the password option but here you can store the password in an obfuscated manner. *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the password. Its just a bit harder to do it at first glance.");
-	}
-	
-	namespace event_log {
-		DEFINE_PATH(SECTION, EVENT_LOG_SECTION);
-		//DESCRIBE_SETTING(SECTION, "EVENT LOG SECTION", "Section for the EventLog Checker (CHeckEventLog.dll).");
-
-		DEFINE_SETTING_B(DEBUG_KEY, EVENT_LOG_SECTION, "debug", false);
-		//DESCRIBE_SETTING_ADVANCED(DEBUG_KEY, "DEBUG", "Log all \"hits\" and \"misses\" on the eventlog filter chain, useful for debugging eventlog checks but very very very noisy so you don't want to accidentally set this on a real machine.");
-
-		DEFINE_SETTING_B(LOOKUP_NAMES, EVENT_LOG_SECTION, "lookup_names", false);
-		//DESCRIBE_SETTING_ADVANCED(LOOKUP_NAMES, "TODO", "TODO");
-
-		DEFINE_SETTING_S(SYNTAX, EVENT_LOG_SECTION, "syntax", "");
-		//DESCRIBE_SETTING(SYNTAX, "SYNTAX", "Set this to use a specific syntax string for all commands (that don't specify one).");
-
-		DEFINE_SETTING_I(BUFFER_SIZE, EVENT_LOG_SECTION, "buffer_size", 65535);
-		//DESCRIBE_SETTING(BUFFER_SIZE, "BUFFER SIZE", "The size of the bugfer to use when getting messages this affects the speed and maximum size of messages you can recieve.");
-	}
-	*/
-/*
-	namespace external_scripts {
-		DEFINE_PATH(SECTION, EXTSCRIPT_SECTION);
-		//DESCRIBE_SETTING(SECTION, "EXTERNAL SCRIPT SECTION", "Section for external scripts (CheckExternalScripts.dll).");
-
-		DEFINE_SETTING_I(TIMEOUT, EXTSCRIPT_SECTION, "timeout", 60);
-		//DESCRIBE_SETTING(TIMEOUT, "COMMAND TIMEOUT", "The maximum time in seconds that a command can execute. (if more then this execution will be aborted). NOTICE this only affects external commands not internal ones.");
-
-		DEFINE_SETTING_B(ALLOW_ARGS, EXTSCRIPT_SECTION, "allow arguments", false);
-		//DESCRIBE_SETTING(ALLOW_ARGS, "COMMAND ARGUMENT PROCESSING", "This option determines whether or not the we will allow clients to specify arguments to commands that are executed.");
-
-		DEFINE_SETTING_B(ALLOW_NASTY, EXTSCRIPT_SECTION, "allow nasy characters", false);
-		//DESCRIBE_SETTING(ALLOW_NASTY, "COMMAND ALLOW NASTY META CHARS", "This option determines whether or not the we will allow clients to specify nasty (as in |`&><'\"\\[]{}) characters in arguments.");
-
-		DEFINE_SETTING_S(SCRIPT_PATH, EXTSCRIPT_SECTION, "script path", "");
-		//DESCRIBE_SETTING_ADVANCED(SCRIPT_PATH, "SCRIPT DIRECTORY", "Load all scripts in a directory and use them as commands. Probably dangerous but usefull if you have loads of scripts :)");
-
-		DEFINE_PATH(SCRIPT_SECTION, EXTSCRIPT_SCRIPT_SECTION);
-		//DESCRIBE_SETTING(SCRIPT_SECTION, "EXTERNAL SCRIPT SCRIPTS SECTION", "A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments> for instance:");
-
-		DEFINE_PATH(ALIAS_SECTION, EXTSCRIPT_ALIAS_SECTION);
-		//DESCRIBE_SETTING(ALIAS_SECTION, "EXTERNAL SCRIPT ALIAS SECTION", "Works like the \"inject\" concept of NRPE scripts module. But in short a list of aliases available. An alias is an internal command that has been \"wrapped\" (to add arguments). Be careful so you don't create loops (ie check_loop=check_a, check_a=check_loop)");
-
-		DEFINE_PATH(WRAPPINGS_SECTION, EXTSCRIPT_WRAPPINGS_SECTION);
-		//DESCRIBE_SETTING(WRAPPINGS_SECTION, "EXTERNAL SCRIPT WRAPPINGS SECTION", "");
-
-		DEFINE_PATH(WRAPPED_SCRIPT, EXTSCRIPT_WRAPPED_SCRIPT);
-		//DESCRIBE_SETTING(WRAPPED_SCRIPT, "EXTERNAL SCRIPT WRAPPINGS SECTION", "");
-
-	}
-*/
-/*
-	namespace check_system {
-
-		DEFINE_PATH(SECTION, CHECK_SYSTEM_SECTION);
-		DESCRIBE_SETTING(SECTION, "SYSTEM", "Section for system checks and system settings.");
-
-		DEFINE_SETTING_S(PROC_ENUM, CHECK_SYSTEM_SECTION, "process enumeration method", "auto");
-		DESCRIBE_SETTING_ADVANCED(PROC_ENUM, "COMMAND TIMEOUT", "Set the PROCESS enumeration method (auto, TOOLHELP or PSAPI)");
-		const std::wstring PROC_ENUM_PSAPI = _T("PSAPI");
-		const std::wstring PROC_ENUM_TH = _T("TOOLHELP");
-
-		DEFINE_SETTING_S(CPU_METHOD, CHECK_SYSTEM_SECTION, "method", "PDH_AUTO");
-		DESCRIBE_SETTING_ADVANCED(CPU_METHOD, "CPU METHOD", "Set this to false to disable auto detect (counters.defs) PDH language and OS version.");
-		const std::wstring CPU_METHOD_PDH_MANUAL = _T("PDH_MANUAL");
-		const std::wstring CPU_METHOD_PDH_AUTO = _T("PDH_AUTO");
-		const std::wstring CPU_METHOD_PDH_NO_INDEX = _T("PDH_NO_INDEX");
-
-		DEFINE_SETTING_S(BUFFER_SIZE, CHECK_SYSTEM_SECTION, "buffer size", "1h");
-		DESCRIBE_SETTING(BUFFER_SIZE, "BUFFER SIZE", "	The time to store CPU load data.");
-
-		DEFINE_SETTING_I(INTERVALL, CHECK_SYSTEM_SECTION, "interval", 10);
-		DESCRIBE_SETTING_ADVANCED(INTERVALL, "CHECK INTERVAL", "Time between checks in 1/10 of seconds.");
-
-		DEFINE_SETTING_S(FORCE_LANGUAGE, CHECK_SYSTEM_SECTION, "locale", "auto");
-		DESCRIBE_SETTING_ADVANCED(FORCE_LANGUAGE, "FORCE LOCALE", "Set this to a locale ID if you want to force auto-detection of counters from that locale.");
-		
-		DEFINE_PATH(COUNTERS_SECTION, CHECK_SYSTEM_COUNTERS_SECTION);
-		DESCRIBE_SETTING_ADVANCED(COUNTERS_SECTION, "PDH COUNTERS", "Section to define PDH counters to use");
-
-		DEFINE_SETTING_S(PDH_MEM_CMT_LIM, CHECK_SYSTEM_COUNTERS_SECTION, "memory commit limit", "\\Memory\\Commit Limit");
-		DESCRIBE_SETTING_ADVANCED(PDH_MEM_CMT_LIM, "PDH COUNTER", "Counter to use to check upper memory limit.");
-
-		DEFINE_SETTING_S(PDH_MEM_CMT_BYT, CHECK_SYSTEM_COUNTERS_SECTION, "memory commit byte", "\\Memory\\Committed Bytes");
-		DESCRIBE_SETTING_ADVANCED(PDH_MEM_CMT_BYT, "PDH COUNTER", "Counter to use to check current memory usage.");
-
-		DEFINE_SETTING_S(PDH_SYSUP, CHECK_SYSTEM_COUNTERS_SECTION, "system uptime", "\\System\\System Up Time");
-		DESCRIBE_SETTING_ADVANCED(PDH_SYSUP, "PDH COUNTER", "Counter to use to check the uptime of the system.");
-
-		DEFINE_SETTING_S(PDH_CPU, CHECK_SYSTEM_COUNTERS_SECTION, "processor time", "\\Processor(_total)\\% Processor Time");
-		DESCRIBE_SETTING_ADVANCED(PDH_CPU, "PDH COUNTER", "Counter to use for CPU load.");
-
-		//DEFINE_PATH(SERVICES_SECTION, CHECK_SYSTEM_SERVICES_SECTION);
-		//DESCRIBE_SETTING_ADVANCED(SERVICES_SECTION, "SERVICE CHECKS", "Section to define service checks to use");
-
-		//DEFINE_SETTING_S(SVC_BOOT_START, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_BOOT_START", "ignored");
-		//DESCRIBE_SETTING_ADVANCED(SVC_BOOT_START, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
-
-		//DEFINE_SETTING_S(SVC_SYSTEM_START, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_SYSTEM_START", "ignored");
-		//DESCRIBE_SETTING_ADVANCED(SVC_SYSTEM_START, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
-
-		//DEFINE_SETTING_S(SVC_AUTO_START, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_AUTO_START", "started");
-		//DESCRIBE_SETTING_ADVANCED(SVC_AUTO_START, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
-
-		//DEFINE_SETTING_S(SVC_DEMAND_START, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_DEMAND_START", "ignored");
-		//DESCRIBE_SETTING_ADVANCED(SVC_DEMAND_START, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
-
-		//DEFINE_SETTING_S(SVC_DISABLED, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_DISABLED", "stopped");
-		//DESCRIBE_SETTING_ADVANCED(SVC_DISABLED, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
-
-		DEFINE_SETTING_S(PDH_SUBSYSTEM, CHECK_SYSTEM_SECTION, "pdh_subsystem", "fast");
-		DESCRIBE_SETTING_ADVANCED(PDH_SUBSYSTEM, "PDH_SUBSYSTEM", "TODO");
-		const std::wstring PDH_SUBSYSTEM_FAST = _T("fast");
-		const std::wstring PDH_SUBSYSTEM_THREAD_SAFE = _T("thread-safe");
-
-	}
-	*/
-/*
-	namespace nsca {
-		DEFINE_PATH(SECTION, NSCA_SECTION);
-		//DESCRIBE_SETTING(SECTION, "NSCA SECTION", "Section for NSCA passive check module.");
-
-		DEFINE_SETTING_I(INTERVAL, NSCA_SECTION, "interval", 60);
-		//DESCRIBE_SETTING(INTERVAL, "COMMAND TIMEOUT", "Time in seconds between each report back to the server (cant as of yet be set individually so this is for all \"checks\")");
-
-		DEFINE_SETTING_S(HOSTNAME, NSCA_SECTION, "hostname", "");
-		//DESCRIBE_SETTING_ADVANCED(HOSTNAME, "LOCAL HOSTNAME", "The host name of this host if set to blank (default) the windows name of the computer will be used.");
-
-		DEFINE_PATH(SERVER_SECTION, NSCA_SERVER_SECTION);
-		//DESCRIBE_SETTING(SERVER_SECTION, "NSCA SERVER SECTION", "Configure the NSCA server to report to");
-
-		DEFINE_SETTING_S(SERVER_HOST, NSCA_SERVER_SECTION, "host", "unknown-host");
-		//DESCRIBE_SETTING(SERVER_HOST, "NSCA SERVER", "The NSCA/Nagios(?) server to report results to.");
-
-		DEFINE_SETTING_I(SERVER_PORT, NSCA_SERVER_SECTION, "port", 5667);
-		//DESCRIBE_SETTING(SERVER_PORT, "NSCA PORT", "The NSCA server port");
-
-		DEFINE_SETTING_I(ENCRYPTION, NSCA_SERVER_SECTION, "encryption method", 1);
-		//DESCRIBE_SETTING(ENCRYPTION, "NSCA ENCRYPTION", "Number corresponding to the various encryption algorithms (see the wiki). Has to be the same as the server or it wont work at all.");
-
-		DEFINE_SETTING_S(PASSWORD, NSCA_SERVER_SECTION, "password", "");
-		//DESCRIBE_SETTING(PASSWORD, "NSCA PASSWORD", "The password to use. Again has to be the same as the server or it wont work at all.");
-
-		DEFINE_SETTING_I(THREADS, NSCA_SECTION, "debug threads", 1);
-		//DESCRIBE_SETTING_ADVANCED(THREADS, "DEBUG OPTION (THREADS)", "Number of threads to run, no reason to change this really (unless you want to stress test something)");
-
-		DEFINE_SETTING_B(CACHE_HOST, NSCA_SECTION, "cache hostname", false);
-		//DESCRIBE_SETTING_ADVANCED(CACHE_HOST, "CACHE HOSTNAME", "???");
-
-		DEFINE_PATH(CMD_SECTION, NSCA_CMD_SECTION);
-		//DESCRIBE_SETTING(CMD_SECTION, "NSCA COMMAND SECTION", "Commands to check and report to the NSCA server");
-
-		DEFINE_SETTING_S(REPORT_MODE, NSCA_SERVER_SECTION, "report", "all");
-		//DESCRIBE_SETTING(REPORT_MODE, "REPORT MODE", "What to report to the server (any of the following: all, critical, warning, unknown, ok)");
-
-		DEFINE_SETTING_S(TIME_DELTA_DEFAULT, NSCA_SECTION, "delay", "0");
-		//DESCRIBE_SETTING(TIME_DELTA_DEFAULT, "TODO", "TODO");
-
-		DEFINE_SETTING_I(PAYLOAD_LENGTH, NSCA_SECTION, "payload length", 512);
-		//DESCRIBE_SETTING_ADVANCED(PAYLOAD_LENGTH, "PAYLOAD LENGTH", "Length of payload to/from the NSCA agent. This is a hard specific value so you have to \"configure\" (read recompile) your NSCA server to use the same value for it to work.");
-
-		DEFINE_SETTING_I(READ_TIMEOUT, NSCA_SERVER_SECTION, GENERIC_KEY_SOCK_READ_TIMEOUT, 30);
-		//DESCRIBE_SETTING(READ_TIMEOUT, "SOCKET TIMEOUT", "Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out.");
-
-	}
-
-	namespace scheduler {
-		DEFINE_PATH(SECTION, SCHEDULER_SECTION);
-		//DESCRIBE_SETTING(SECTION, "SCHEDULER SECTION", "Section for the Scheduler module.");
-
-		DEFINE_PATH(SCHEDULES_SECTION, SCHEDULER_SECTION_SCH);
-		//DESCRIBE_SETTING(SCHEDULES_SECTION, "SCHEDULES SECTION", "Section for defining schedules for the Scheduler module.");
-
-		DEFINE_PATH(DEFAULT_SCHEDULE_SECTION, SCHEDULER_SECTION_DEF);
-		//DESCRIBE_SETTING(DEFAULT_SCHEDULE_SECTION, "DEFAULT SCHEDULER SECTION", "Default settings for all scheduled commands");
-
-		DEFINE_SETTING_I(THREADS, SCHEDULER_SECTION, "debug threads", 1);
-		//DESCRIBE_SETTING_ADVANCED(THREADS, "THREADS", "Number of threads to use int he thread pool (increase if you have many scheduled items)");
-
-		DEFINE_SETTING_S(INTERVAL, SCHEDULER_SECTION_FAKE, "interval", "5m");
-		//DESCRIBE_SETTING(INTERVAL, "SCHEDULE INTERVAL", "Time in seconds between each check");
-
-		DEFINE_SETTING_S(COMMAND, SCHEDULER_SECTION_FAKE, "command", "check_ok");
-		//DESCRIBE_SETTING(COMMAND, "SCHEDULE COMMAND", "Command to run");
-
-		DEFINE_SETTING_S(CHANNEL, SCHEDULER_SECTION_FAKE, "channel", "NSCA");
-		//DESCRIBE_SETTING(CHANNEL, "SCHEDULE CHANNEL", "Channel to send results on");
-
-		DEFINE_SETTING_S(REPORT_MODE, SCHEDULER_SECTION_FAKE, "report", "all");
-		//DESCRIBE_SETTING(REPORT_MODE, "REPORT MODE", "What to report to the server (any of the following: all, critical, warning, unknown, ok)");
-
-		DEFINE_SETTING_S(INTERVAL_D, SCHEDULER_SECTION_DEF, "interval", "5m");
-		//DESCRIBE_SETTING(INTERVAL_D, "SCHEDULE INTERVAL", "Time in seconds between each check");
-
-		DEFINE_SETTING_S(COMMAND_D, SCHEDULER_SECTION_DEF, "command", "check_ok");
-		//DESCRIBE_SETTING(COMMAND_D, "SCHEDULE COMMAND", "Command to run");
-
-		DEFINE_SETTING_S(CHANNEL_D, SCHEDULER_SECTION_DEF, "channel", "NSCA");
-		//DESCRIBE_SETTING(CHANNEL_D, "SCHEDULE CHANNEL", "Channel to send results on");
-
-		DEFINE_SETTING_S(REPORT_MODE_D, SCHEDULER_SECTION_DEF, "report", "all");
-		//DESCRIBE_SETTING(REPORT_MODE_D, "REPORT MODE", "What to report to the server (any of the following: all, critical, warning, unknown, ok)");
-
-	}
-*/
-/*
-	namespace task_scheduler {
-		DEFINE_PATH(SECTION, TASK_SCHED_SECTION);
-		DESCRIBE_SETTING_ADVANCED(SECTION, "TASK SCHEDULER", "???");
-
-		DEFINE_SETTING_S(SYNTAX, TASK_SCHED_SECTION, "syntax", "%title% last run: %most-recent-run-time% (%exit-code%)");
-		DESCRIBE_SETTING_ADVANCED(SYNTAX, "SYNTAX", "Set this to use a specific syntax string for all commands (that don't specify one)");
-	}
-
-	namespace lua {
-		DEFINE_PATH(SECTION, LUA_SECTION);
-		DESCRIBE_SETTING_ADVANCED(SECTION, "LUA SECTION", "A list of LUA script to load at startup. In difference to \"external checks\" all LUA scripts are loaded at startup. Names have no meaning since the script (on boot) submit which commands are available and tie that to various functions.");
-	}
-	*/
-/*
-	namespace log {
-		DEFINE_PATH(SECTION, LOG_SECTION);
-		//DESCRIBE_SETTING_ADVANCED(SECTION, "LOG SECTION", "Configure loggning properties.");
-
-		DEFINE_SETTING_S(FILENAME, LOG_SECTION, "file", "nsclient.log");
-		//DESCRIBE_SETTING_ADVANCED(FILENAME, "SYNTAX", "The file to write log data to. If no directory is used this is relative to the NSClient++ binary.");
-
-		DEFINE_SETTING_S(ROOT, LOG_SECTION, "root", "auto");
-		//DESCRIBE_SETTING_ADVANCED(ROOT, "TODO", "TODO");
-
-		DEFINE_SETTING_S(DATEMASK, LOG_SECTION, "date format", "%Y-%m-%d %H:%M:%S");
-		//DESCRIBE_SETTING_ADVANCED(DATEMASK, "DATEMASK", "The date format used when logging to a file.");
-
-		DEFINE_SETTING_S(LOG_MASK, LOG_SECTION, "log mask", "normal");
-		//DESCRIBE_SETTING_ADVANCED(LOG_MASK, "LOG MASK", "The log mask information, error, warning, critical, debug");
-
-		DEFINE_SETTING_B(DEBUG_LOG, LOG_SECTION, "debug", false);
-		//DESCRIBE_SETTING_ADVANCED(DEBUG_LOG, "DEBUG LOGGING", "Enable debug logging can help track down errors and find problems but will impact overall perfoamnce negativly.");
-	}
-	*/
 }
Index: include/swap_bytes.hpp
===================================================================
--- include/swap_bytes.hpp	(revision 1f24a1c79160f2b961fa3ae999ec1919f2e99ee1)
+++ include/swap_bytes.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -2,4 +2,5 @@
 
 #include <boost/static_assert.hpp>
+#include <boost/type_traits/is_arithmetic.hpp>
 
 namespace swap_bytes {
Index: libs/plugin_api/CMakeLists.txt
===================================================================
--- libs/plugin_api/CMakeLists.txt	(revision 7515d0058365db80503affde983ab5298cff7ef1)
+++ libs/plugin_api/CMakeLists.txt	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -12,9 +12,14 @@
 	${NSCP_INCLUDEDIR}/b64/b64.c
 	${NSCP_INCLUDEDIR}/utils.cpp
+	
+	${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.cpp
 	${NSCP_INCLUDEDIR}/nscapi/nscapi_helper.cpp
+	${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_impl.cpp
 	${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_wrapper.cpp
-	${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.cpp
+	${NSCP_INCLUDEDIR}/nscapi/nscapi_protobuf_functions.cpp
+	${NSCP_INCLUDEDIR}/nscapi/nscapi_protobuf_types.cpp
+	${NSCP_INCLUDEDIR}/nscapi/nscapi_targets.cpp
+	
 	${NSCP_INCLUDEDIR}/settings/client/settings_client.cpp
-	${NSCP_INCLUDEDIR}/nscapi/targets.cpp
 )
 	
@@ -26,11 +31,16 @@
 		${NSCP_INCLUDEDIR}/utils.h
 		${NSCP_INCLUDEDIR}/NSCAPI.h
+		
+		${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.hpp
 		${NSCP_INCLUDEDIR}/nscapi/nscapi_helper.hpp
-		${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_wrapper.hpp	
-		${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.hpp
+		${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_impl.hpp
+		${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_wrapper.hpp
+		${NSCP_INCLUDEDIR}/nscapi/nscapi_protobuf_functions.hpp
+		${NSCP_INCLUDEDIR}/nscapi/nscapi_protobuf_types.hpp
+		${NSCP_INCLUDEDIR}/nscapi/nscapi_targets.hpp
+
 		${NSCP_INCLUDEDIR}/settings/client/settings_client.hpp
 		${NSCP_INCLUDEDIR}/nscapi/settings_proxy.hpp
 		${NSCP_INCLUDEDIR}/nscapi/macros.hpp
-		${NSCP_INCLUDEDIR}/nscapi/targets.hpp
 
 	)
Index: modules/CauseCrashes/CauseCrashes.cpp
===================================================================
--- modules/CauseCrashes/CauseCrashes.cpp	(revision c74d7b64aa43946ade65cdc7f4e22c5738113174)
+++ modules/CauseCrashes/CauseCrashes.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -21,4 +21,6 @@
 #include "stdafx.h"
 #include "CauseCrashes.h"
+
+#include <strEx.h>
 
 CauseCrashes::CauseCrashes() {
Index: modules/CauseCrashes/CauseCrashes.h
===================================================================
--- modules/CauseCrashes/CauseCrashes.h	(revision c74d7b64aa43946ade65cdc7f4e22c5738113174)
+++ modules/CauseCrashes/CauseCrashes.h	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -19,7 +19,6 @@
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
+#pragma once
 NSC_WRAPPERS_MAIN();
-//#include <config.h>
-#include <strEx.h>
 
 class CauseCrashes : public nscapi::impl::simple_command_handler, public nscapi::impl::simple_plugin {
@@ -30,7 +29,4 @@
 	virtual ~CauseCrashes();
 	// Module calls
-	bool loadModule();
-	bool loadModuleEx(std::wstring alias, NSCAPI::moduleLoadMode mode);
-	bool unloadModule();
 
 
@@ -46,4 +42,7 @@
 	}
 
+	bool loadModule();
+	bool loadModuleEx(std::wstring alias, NSCAPI::moduleLoadMode mode);
+	bool unloadModule();
 	bool hasCommandHandler();
 	bool hasMessageHandler();
Index: modules/CheckEventLog/CheckEventLog.cpp
===================================================================
--- modules/CheckEventLog/CheckEventLog.cpp	(revision 72eea1f23cecafb8201ac66e2ff2607a5482b2d0)
+++ modules/CheckEventLog/CheckEventLog.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -38,5 +38,5 @@
 #include "filter.hpp"
 
-#include <nscapi/functions.hpp>
+#include <nscapi/nscapi_protobuf_functions.hpp>
 
 #include <parsers/where/unary_fun.hpp>
Index: modules/CheckSystem/settings.hpp
===================================================================
--- modules/CheckSystem/settings.hpp	(revision 7ec3dd1fd472743bd1d0420af09e8f962665441f)
+++ modules/CheckSystem/settings.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -10,61 +10,10 @@
 		DESCRIBE_SETTING(SECTION, "SYSTEM", "Section for system checks and system settings.");
 
-		DEFINE_SETTING_S(PROC_ENUM, CHECK_SYSTEM_SECTION, "process enumeration method", "auto");
-		DESCRIBE_SETTING_ADVANCED(PROC_ENUM, "COMMAND TIMEOUT", "Set the PROCESS enumeration method (auto, TOOLHELP or PSAPI)");
-		const std::wstring PROC_ENUM_PSAPI = _T("PSAPI");
-		const std::wstring PROC_ENUM_TH = _T("TOOLHELP");
-
-		DEFINE_SETTING_S(CPU_METHOD, CHECK_SYSTEM_SECTION, "method", "PDH_AUTO");
-		DESCRIBE_SETTING_ADVANCED(CPU_METHOD, "CPU METHOD", "Set this to false to disable auto detect (counters.defs) PDH language and OS version.");
-		const std::wstring CPU_METHOD_PDH_MANUAL = _T("PDH_MANUAL");
-		const std::wstring CPU_METHOD_PDH_AUTO = _T("PDH_AUTO");
-		const std::wstring CPU_METHOD_PDH_NO_INDEX = _T("PDH_NO_INDEX");
-
-		DEFINE_SETTING_S(BUFFER_SIZE, CHECK_SYSTEM_SECTION, "buffer size", "1h");
-		DESCRIBE_SETTING(BUFFER_SIZE, "BUFFER SIZE", "	The time to store CPU load data.");
-
-		DEFINE_SETTING_I(INTERVALL, CHECK_SYSTEM_SECTION, "interval", 10);
-		DESCRIBE_SETTING_ADVANCED(INTERVALL, "CHECK INTERVAL", "Time between checks in 1/10 of seconds.");
-
-		DEFINE_SETTING_S(FORCE_LANGUAGE, CHECK_SYSTEM_SECTION, "locale", "auto");
-		DESCRIBE_SETTING_ADVANCED(FORCE_LANGUAGE, "FORCE LOCALE", "Set this to a locale ID if you want to force auto-detection of counters from that locale.");
-
-		DEFINE_PATH(COUNTERS_SECTION, CHECK_SYSTEM_COUNTERS_SECTION);
-		DESCRIBE_SETTING_ADVANCED(COUNTERS_SECTION, "PDH COUNTERS", "Section to define PDH counters to use");
-
-		DEFINE_SETTING_S(PDH_MEM_CMT_LIM, CHECK_SYSTEM_COUNTERS_SECTION, "memory commit limit", "\\Memory\\Commit Limit");
-		DESCRIBE_SETTING_ADVANCED(PDH_MEM_CMT_LIM, "PDH COUNTER", "Counter to use to check upper memory limit.");
-
-		DEFINE_SETTING_S(PDH_MEM_CMT_BYT, CHECK_SYSTEM_COUNTERS_SECTION, "memory commit byte", "\\Memory\\Committed Bytes");
-		DESCRIBE_SETTING_ADVANCED(PDH_MEM_CMT_BYT, "PDH COUNTER", "Counter to use to check current memory usage.");
-
-		DEFINE_SETTING_S(PDH_SYSUP, CHECK_SYSTEM_COUNTERS_SECTION, "system uptime", "\\System\\System Up Time");
-		DESCRIBE_SETTING_ADVANCED(PDH_SYSUP, "PDH COUNTER", "Counter to use to check the uptime of the system.");
-
-		DEFINE_SETTING_S(PDH_CPU, CHECK_SYSTEM_COUNTERS_SECTION, "processor time", "\\Processor(_total)\\% Processor Time");
-		DESCRIBE_SETTING_ADVANCED(PDH_CPU, "PDH COUNTER", "Counter to use for CPU load.");
-
-		//DEFINE_PATH(SERVICES_SECTION, CHECK_SYSTEM_SERVICES_SECTION);
-		//DESCRIBE_SETTING_ADVANCED(SERVICES_SECTION, "SERVICE CHECKS", "Section to define service checks to use");
-
-		//DEFINE_SETTING_S(SVC_BOOT_START, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_BOOT_START", "ignored");
-		//DESCRIBE_SETTING_ADVANCED(SVC_BOOT_START, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
-
-		//DEFINE_SETTING_S(SVC_SYSTEM_START, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_SYSTEM_START", "ignored");
-		//DESCRIBE_SETTING_ADVANCED(SVC_SYSTEM_START, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
-
-		//DEFINE_SETTING_S(SVC_AUTO_START, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_AUTO_START", "started");
-		//DESCRIBE_SETTING_ADVANCED(SVC_AUTO_START, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
-
-		//DEFINE_SETTING_S(SVC_DEMAND_START, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_DEMAND_START", "ignored");
-		//DESCRIBE_SETTING_ADVANCED(SVC_DEMAND_START, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
-
-		//DEFINE_SETTING_S(SVC_DISABLED, CHECK_SYSTEM_SERVICES_SECTION, "SERVICE_DISABLED", "stopped");
-		//DESCRIBE_SETTING_ADVANCED(SVC_DISABLED, "SERVICE_BOOT_START SERVICE CHECK", "Set how to handle services set to SERVICE_BOOT_START state when checking all services");
+		const std::wstring PDH_SUBSYSTEM_FAST = _T("fast");
+		const std::wstring PDH_SUBSYSTEM_THREAD_SAFE = _T("thread-safe");
 
 		DEFINE_SETTING_S(PDH_SUBSYSTEM, CHECK_SYSTEM_SECTION, "pdh_subsystem", "fast");
 		DESCRIBE_SETTING_ADVANCED(PDH_SUBSYSTEM, "PDH_SUBSYSTEM", "TODO");
-		const std::wstring PDH_SUBSYSTEM_FAST = _T("fast");
-		const std::wstring PDH_SUBSYSTEM_THREAD_SAFE = _T("thread-safe");
+
 
 	}
Index: modules/CheckTaskSched/CheckTaskSched.cpp
===================================================================
--- modules/CheckTaskSched/CheckTaskSched.cpp	(revision a44cb15ff718e3bedc825dac2f253af777c9357b)
+++ modules/CheckTaskSched/CheckTaskSched.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -36,6 +36,6 @@
 
 #include <settings/client/settings_client.hpp>
-#include "settings.hpp"
-
+
+namespace sh = nscapi::settings_helper;
 
 bool CheckTaskSched::loadModule() {
@@ -47,6 +47,24 @@
 		register_command(_T("CheckTaskSched"), _T("Run a WMI query and check the resulting rows (the number of hits determine state)."));
 
-		SETTINGS_REG_PATH(task_scheduler::SECTION);
-		SETTINGS_REG_KEY_S(task_scheduler::SYNTAX);
+
+		sh::settings_registry settings(get_settings_proxy());
+		settings.set_alias(_T("check"), alias, _T("task schedule"));
+
+		settings.alias().add_path_to_settings()
+			(_T("TASK SCHEDULE"), _T("Section for system checks and system settings"))
+
+			;
+
+
+		settings.alias().add_key_to_settings()
+
+			(_T("default buffer length"), sh::wstring_key(&syntax, _T("%title% last run: %most-recent-run-time% (%exit-code%)")),
+			_T("SYNTAX"), _T("Set this to use a specific syntax string for all commands (that don't specify one)"))
+			;
+
+
+		settings.register_all();
+		settings.notify();
+
 	} catch (nscapi::nscapi_exception &e) {
 		NSC_LOG_ERROR_STD(_T("Failed to register command: ") + utf8::cvt<std::wstring>(e.what()));
@@ -59,5 +77,4 @@
 		return false;
 	}
-	syntax = SETTINGS_GET_STRING(task_scheduler::SYNTAX);
 	return true;
 }
Index: dules/CheckTaskSched/settings.hpp
===================================================================
--- modules/CheckTaskSched/settings.hpp	(revision 7ec3dd1fd472743bd1d0420af09e8f962665441f)
+++ 	(revision )
@@ -1,15 +1,0 @@
-#pragma once
-
-
-#include <settings/macros.h>
-
-namespace setting_keys {
-	namespace task_scheduler {
-		DEFINE_PATH(SECTION, TASK_SCHED_SECTION);
-		DESCRIBE_SETTING_ADVANCED(SECTION, "TASK SCHEDULER", "???");
-
-		DEFINE_SETTING_S(SYNTAX, TASK_SCHED_SECTION, "syntax", "%title% last run: %most-recent-run-time% (%exit-code%)");
-		DESCRIBE_SETTING_ADVANCED(SYNTAX, "SYNTAX", "Set this to use a specific syntax string for all commands (that don't specify one)");
-	}
-
-}
Index: modules/CheckTaskSched2/CheckTaskSched2.cpp
===================================================================
--- modules/CheckTaskSched2/CheckTaskSched2.cpp	(revision a44cb15ff718e3bedc825dac2f253af777c9357b)
+++ modules/CheckTaskSched2/CheckTaskSched2.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -36,5 +36,6 @@
 
 #include <settings/client/settings_client.hpp>
-#include "../CheckTaskSched/settings.hpp"
+
+namespace sh = nscapi::settings_helper;
 
 bool CheckTaskSched2::loadModule() {
@@ -46,6 +47,23 @@
 		register_command(_T("CheckTaskSched"), _T("Run a WMI query and check the resulting rows (the number of hits determine state)."));
 
-		SETTINGS_REG_PATH(task_scheduler::SECTION);
-		SETTINGS_REG_KEY_S(task_scheduler::SYNTAX);
+
+		sh::settings_registry settings(get_settings_proxy());
+		settings.set_alias(_T("check"), alias, _T("task schedule"));
+
+		settings.alias().add_path_to_settings()
+			(_T("TASK SCHEDULE"), _T("Section for system checks and system settings"))
+
+			;
+
+
+		settings.alias().add_key_to_settings()
+
+			(_T("default buffer length"), sh::wstring_key(&syntax, _T("%title% last run: %most-recent-run-time% (%exit-code%)")),
+			_T("SYNTAX"), _T("Set this to use a specific syntax string for all commands (that don't specify one)"))
+			;
+
+
+		settings.register_all();
+		settings.notify();
 	} catch (nscapi::nscapi_exception &e) {
 		NSC_LOG_ERROR_STD(_T("Failed to register command: ") + utf8::cvt<std::wstring>(e.what()));
@@ -58,5 +76,4 @@
 		return false;
 	}
-	syntax = SETTINGS_GET_STRING(task_scheduler::SYNTAX);
 	return true;
 }
Index: modules/DistributedClient/DistributedClient.cpp
===================================================================
--- modules/DistributedClient/DistributedClient.cpp	(revision 2906cdae39926ce06945c490bb120a499fef0846)
+++ modules/DistributedClient/DistributedClient.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -32,4 +32,5 @@
 
 #include <settings/client/settings_client.hpp>
+#include <nscapi/nscapi_protobuf_functions.hpp>
 
 namespace sh = nscapi::settings_helper;
Index: modules/DistributedClient/DistributedClient.h
===================================================================
--- modules/DistributedClient/DistributedClient.h	(revision 2906cdae39926ce06945c490bb120a499fef0846)
+++ modules/DistributedClient/DistributedClient.h	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -26,4 +26,5 @@
 #include <client/command_line_parser.hpp>
 #include <nscapi/targets.hpp>
+#include <nscapi/nscapi_protobuf_types.hpp>
 
 #include <nscp/packet.hpp>
@@ -102,5 +103,5 @@
 		int timeout;
 
-		connection_data(nscapi::functions::destination_container arguments, nscapi::functions::destination_container target) {
+		connection_data(nscapi::protobuf::types::destination_container arguments, nscapi::protobuf::types::destination_container target) {
 			arguments.import(target);
 			timeout = arguments.get_int_data("timeout", 30);
@@ -125,9 +126,9 @@
 		int exec(client::configuration::data_type data, const Plugin::ExecuteRequestMessage &request_message, std::string &reply);
 
-		virtual nscapi::functions::destination_container lookup_target(std::wstring &id) {
+		virtual nscapi::protobuf::types::destination_container lookup_target(std::wstring &id) {
 			nscapi::targets::optional_target_object opt = instance->targets.find_object(id);
 			if (opt)
 				return opt->to_destination_container();
-			nscapi::functions::destination_container ret;
+			nscapi::protobuf::types::destination_container ret;
 			return ret;
 		}
Index: modules/NRPEClient/NRPEClient.cpp
===================================================================
--- modules/NRPEClient/NRPEClient.cpp	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ modules/NRPEClient/NRPEClient.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -29,4 +29,5 @@
 
 #include <settings/client/settings_client.hpp>
+#include <nscapi/nscapi_protobuf_functions.hpp>
 
 namespace sh = nscapi::settings_helper;
Index: modules/NRPEClient/NRPEClient.h
===================================================================
--- modules/NRPEClient/NRPEClient.h	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ modules/NRPEClient/NRPEClient.h	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -25,4 +25,5 @@
 #include <client/command_line_parser.hpp>
 #include <nscapi/targets.hpp>
+#include <nscapi/nscapi_protobuf_types.hpp>
 
 #include <nrpe/packet.hpp>
@@ -109,5 +110,5 @@
 		bool use_ssl;
 
-		connection_data(nscapi::functions::destination_container arguments, nscapi::functions::destination_container target) {
+		connection_data(nscapi::protobuf::types::destination_container arguments, nscapi::protobuf::types::destination_container target) {
 			arguments.import(target);
 			cert = arguments.get_string_data("certificate");
@@ -145,9 +146,9 @@
 		int exec(client::configuration::data_type data, const Plugin::ExecuteRequestMessage &request_message, std::string &reply);
 
-		virtual nscapi::functions::destination_container lookup_target(std::wstring &id) {
+		virtual nscapi::protobuf::types::destination_container lookup_target(std::wstring &id) {
 			nscapi::targets::optional_target_object opt = instance->targets.find_object(id);
 			if (opt)
 				return opt->to_destination_container();
-			nscapi::functions::destination_container ret;
+			nscapi::protobuf::types::destination_container ret;
 			return ret;
 		}
Index: modules/NSCAClient/NSCAClient.cpp
===================================================================
--- modules/NSCAClient/NSCAClient.cpp	(revision c74d7b64aa43946ade65cdc7f4e22c5738113174)
+++ modules/NSCAClient/NSCAClient.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -30,4 +30,5 @@
 
 #include <settings/client/settings_client.hpp>
+#include <nscapi/nscapi_protobuf_functions.hpp>
 
 namespace sh = nscapi::settings_helper;
Index: modules/NSCAClient/NSCAClient.h
===================================================================
--- modules/NSCAClient/NSCAClient.h	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ modules/NSCAClient/NSCAClient.h	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -25,4 +25,5 @@
 #include <client/command_line_parser.hpp>
 #include <nscapi/targets.hpp>
+#include <nscapi/nscapi_protobuf_types.hpp>
 
 #include <nsca/nsca_packet.hpp>
@@ -90,5 +91,5 @@
 		int time_delta;
 
-		connection_data(nscapi::functions::destination_container recipient, nscapi::functions::destination_container target, nscapi::functions::destination_container sender) {
+		connection_data(nscapi::protobuf::types::destination_container recipient, nscapi::protobuf::types::destination_container target, nscapi::protobuf::types::destination_container sender) {
 			recipient.import(target);
 			timeout = recipient.get_int_data("timeout", 30);
@@ -133,9 +134,9 @@
 		int exec(client::configuration::data_type data, const Plugin::ExecuteRequestMessage &request_message, std::string &reply);
 
-		virtual nscapi::functions::destination_container lookup_target(std::wstring &id) {
-			nscapi::functions::destination_container ret;
+		virtual nscapi::protobuf::types::destination_container lookup_target(std::wstring &id) {
 			nscapi::targets::optional_target_object opt = instance->targets.find_object(id);
 			if (opt)
 				return opt->to_destination_container();
+			nscapi::protobuf::types::destination_container ret;
 			return ret;
 		}
Index: modules/NSCPClient/NSCPClient.cpp
===================================================================
--- modules/NSCPClient/NSCPClient.cpp	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ modules/NSCPClient/NSCPClient.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -31,4 +31,5 @@
 
 #include <settings/client/settings_client.hpp>
+#include <nscapi/nscapi_protobuf_functions.hpp>
 
 namespace sh = nscapi::settings_helper;
Index: modules/NSCPClient/NSCPClient.h
===================================================================
--- modules/NSCPClient/NSCPClient.h	(revision 2906cdae39926ce06945c490bb120a499fef0846)
+++ modules/NSCPClient/NSCPClient.h	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -26,4 +26,5 @@
 #include <client/command_line_parser.hpp>
 #include <nscapi/targets.hpp>
+#include <nscapi/nscapi_protobuf_types.hpp>
 
 #include <nscp/packet.hpp>
@@ -107,5 +108,5 @@
 		int timeout;
 
-		connection_data(nscapi::functions::destination_container arguments, nscapi::functions::destination_container target) {
+		connection_data(nscapi::protobuf::types::destination_container arguments, nscapi::protobuf::types::destination_container target) {
 			arguments.import(target);
 			cert = arguments.get_string_data("certificate");
@@ -141,9 +142,9 @@
 		int exec(client::configuration::data_type data, const Plugin::ExecuteRequestMessage &request_message, std::string &reply);
 
-		virtual nscapi::functions::destination_container lookup_target(std::wstring &id) {
+		virtual nscapi::protobuf::types::destination_container lookup_target(std::wstring &id) {
 			nscapi::targets::optional_target_object opt = instance->targets.find_object(id);
 			if (opt)
 				return opt->to_destination_container();
-			nscapi::functions::destination_container ret;
+			nscapi::protobuf::types::destination_container ret;
 			return ret;
 		}
Index: modules/NSCPServer/NSCPServer.cpp
===================================================================
--- modules/NSCPServer/NSCPServer.cpp	(revision 7515d0058365db80503affde983ab5298cff7ef1)
+++ modules/NSCPServer/NSCPServer.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -27,5 +27,4 @@
 
 #include <settings/client/settings_client.hpp>
-#include "settings.hpp"
 
 
Index: dules/NSCPServer/settings.hpp
===================================================================
--- modules/NSCPServer/settings.hpp	(revision 438998b60cb9d88ef9dad1e69d0407621384dd3b)
+++ 	(revision )
@@ -1,75 +1,0 @@
-#pragma once
-
-
-#include <settings/macros.h>
-
-namespace setting_keys {
-	// NSClient Setting headlines
-	namespace nrpe {
-		DEFINE_PATH(SECTION, NRPE_SECTION_PROTOCOL);
-		//DESCRIBE_SETTING(SECTION, "NRPE SECTION", "Section for NRPE (NRPEListener.dll) (check_nrpe) protocol options.");
-
-
-		DEFINE_PATH(CH_SECTION, NRPE_CLIENT_HANDLER_SECTION);
-		//DESCRIBE_SETTING(CH_SECTION, "CLIENT HANDLER SECTION", "...");
-
-		DEFINE_SETTING_S(ALLOWED_HOSTS, NRPE_SECTION_PROTOCOL, GENERIC_KEY_ALLOWED_HOSTS, "");
-		DESCRIBE_SETTING(ALLOWED_HOSTS, "ALLOWED HOST ADDRESSES", "This is a comma-delimited list of IP address of hosts that are allowed to talk to NSClient deamon. If you leave this blank the global version will be used instead.");
-
-		DEFINE_SETTING_I(PORT, NRPE_SECTION_PROTOCOL, "port", 5666);
-		//DESCRIBE_SETTING(PORT, "NSCLIENT PORT NUMBER", "This is the port the NSClientListener.dll will listen to.");
-
-		DEFINE_SETTING_S(BINDADDR, NRPE_SECTION_PROTOCOL, GENERIC_KEY_BIND_TO, "");
-		//DESCRIBE_SETTING(BINDADDR, "BIND TO ADDRESS", "Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname. Leaving this blank will bind to all avalible IP adresses.");
-
-		DEFINE_SETTING_I(READ_TIMEOUT, NRPE_SECTION_PROTOCOL, GENERIC_KEY_SOCK_READ_TIMEOUT, 30);
-		//DESCRIBE_SETTING(READ_TIMEOUT, "SOCKET TIMEOUT", "Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out.");
-
-		DEFINE_SETTING_I(LISTENQUE, NRPE_SECTION_PROTOCOL, GENERIC_KEY_SOCK_LISTENQUE, 0);
-		//DESCRIBE_SETTING_ADVANCED(LISTENQUE, "LISTEN QUEUE", "Number of sockets to queue before starting to refuse new incoming connections. This can be used to tweak the amount of simultaneous sockets that the server accepts.");
-
-		DEFINE_SETTING_I(THREAD_POOL, NRPE_SECTION_PROTOCOL, "thread pool", 10);
-		//DESCRIBE_SETTING_ADVANCED(THREAD_POOL, "THREAD POOL", "");
-
-
-
-		DEFINE_SETTING_B(CACHE_ALLOWED, NRPE_SECTION_PROTOCOL, GENERIC_KEY_SOCK_CACHE_ALLOWED, false);
-		DESCRIBE_SETTING_ADVANCED(CACHE_ALLOWED, "ALLOWED HOSTS CACHING", "Used to cache looked up hosts if you check dynamic/changing hosts set this to false.");
-
-		//DEFINE_SETTING_B(KEYUSE_SSL, NRPE_SECTION_PROTOCOL, GENERIC_KEY_USE_SSL, true);
-		//DESCRIBE_SETTING(KEYUSE_SSL, "USE SSL SOCKET", "This option controls if SSL should be used on the socket.");
-
-		//DEFINE_SETTING_I(PAYLOAD_LENGTH, NRPE_SECTION_PROTOCOL, "payload length", 1024);
-		//DESCRIBE_SETTING_ADVANCED(PAYLOAD_LENGTH, "PAYLOAD LENGTH", "Length of payload to/from the NRPE agent. This is a hard specific value so you have to \"configure\" (read recompile) your NRPE agent to use the same value for it to work.");
-
-		//DEFINE_SETTING_B(ALLOW_PERFDATA, NRPE_SECTION, "performance data", true);
-		//DESCRIBE_SETTING_ADVANCED(ALLOW_PERFDATA, "PERFORMANCE DATA", "Send performance data back to nagios (set this to 0 to remove all performance data).");
-
-		//DEFINE_SETTING_I(CMD_TIMEOUT, NRPE_SECTION, "command timeout", 60);
-		//DESCRIBE_SETTING(CMD_TIMEOUT, "COMMAND TIMEOUT", "This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off.");
-
-		DEFINE_SETTING_B(ALLOW_ARGS, NRPE_SECTION, "allow arguments", false);
-		//DESCRIBE_SETTING(ALLOW_ARGS, "COMMAND ARGUMENT PROCESSING", "This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed.");
-
-		DEFINE_SETTING_B(ALLOW_NASTY, NRPE_SECTION, "allow nasy characters", false);
-		//DESCRIBE_SETTING(ALLOW_NASTY, "COMMAND ALLOW NASTY META CHARS", "This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'\"\\[]{}) characters in arguments.");
-
-	}
-	namespace protocol_def {
-		DEFINE_SETTING_S(ALLOWED_HOSTS, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_ALLOWED_HOSTS, "");
-		DESCRIBE_SETTING(ALLOWED_HOSTS, "ALLOWED HOST ADDRESSES", "This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons. If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password). The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access");
-
-		DEFINE_SETTING_B(CACHE_ALLOWED, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_SOCK_CACHE_ALLOWED, false);
-		//DESCRIBE_SETTING_ADVANCED(CACHE_ALLOWED, "ALLOWED HOSTS CACHING", "Used to cache looked up hosts if you check dynamic/changing hosts set this to false.");
-
-		DEFINE_SETTING_S(MASTER_KEY, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_PWD_MASTER_KEY, "This is a secret key that you should change");
-		//DESCRIBE_SETTING(MASTER_KEY, "MASTER KEY", "The secret \"key\" used when (de)obfuscating passwords.");
-
-		DEFINE_SETTING_S(PWD, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_PWD, "");
-		//DESCRIBE_SETTING(PWD, "PASSWORD", "This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.");
-
-		DEFINE_SETTING_S(OBFUSCATED_PWD, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_OBFUSCATED_PWD, "");
-		//DESCRIBE_SETTING(OBFUSCATED_PWD, "OBFUSCATED PASSWORD", "This is the same as the password option but here you can store the password in an obfuscated manner. *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the password. Its just a bit harder to do it at first glance.");
-	}
-
-}
Index: modules/NSClientServer/NSClientServer.cpp
===================================================================
--- modules/NSClientServer/NSClientServer.cpp	(revision 81e420cb9daee9bffa44b5e77a4a0db140fe0036)
+++ modules/NSClientServer/NSClientServer.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -25,5 +25,4 @@
 #include <config.h>
 #include "handler_impl.hpp"
-#include "settings.hpp"
 #include <settings/client/settings_client.hpp>
 
@@ -33,13 +32,4 @@
 }
 NSClientListener::~NSClientListener() {
-}
-std::wstring getAllowedHosts() {
-	std::wstring ret = SETTINGS_GET_STRING(nsclient::ALLOWED_HOSTS);
-	if (ret.empty())
-		ret = SETTINGS_GET_STRING(protocol_def::ALLOWED_HOSTS);
-	return ret;
-}
-bool getCacheAllowedHosts() {
-	return SETTINGS_GET_INT_FALLBACK(nsclient::CACHE_ALLOWED, protocol_def::CACHE_ALLOWED);
 }
 
Index: modules/NSClientServer/handler_impl.cpp
===================================================================
--- modules/NSClientServer/handler_impl.cpp	(revision 2c95d22d076f9036200df70854be989bf79fb8ed)
+++ modules/NSClientServer/handler_impl.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -4,5 +4,4 @@
 #include <boost/lexical_cast.hpp>
 #include "handler_impl.hpp"
-#include "settings.hpp"
 
 
@@ -83,7 +82,7 @@
 		case REQ_CLIENTVERSION:
 			{
-				std::wstring v = SETTINGS_GET_STRING(nsclient::VERSION);
-				if (v == _T("auto"))
-					v = nscapi::plugin_singleton->get_core()->getApplicationName() + _T(" ") + nscapi::plugin_singleton->get_core()->getApplicationVersionString();
+				//std::wstring v = SETTINGS_GET_STRING(nsclient::VERSION);
+				//if (v == _T("auto"))
+				std::wstring v = nscapi::plugin_singleton->get_core()->getApplicationName() + _T(" ") + nscapi::plugin_singleton->get_core()->getApplicationVersionString();
 				return strEx::wstring_to_string(v);
 			}
Index: dules/NSClientServer/settings.hpp
===================================================================
--- modules/NSClientServer/settings.hpp	(revision b8c44b41f8b2873faf30a28fb12d7690a8e2f545)
+++ 	(revision )
@@ -1,62 +1,0 @@
-#pragma once
-
-
-#include <settings/macros.h>
-
-namespace setting_keys {
-	// NSClient Setting headlines
-	namespace nsclient {
-		DEFINE_PATH(SECTION, NSCLIENT_SECTION);
-		//DESCRIBE_SETTING(SECTION, "NSCLIENT SECTION", "Section for NSClient (NSClientListsner.dll) (check_nt) protocol options.");
-
-		DEFINE_SETTING_S(ALLOWED_HOSTS, NSCLIENT_SECTION, GENERIC_KEY_ALLOWED_HOSTS, "");
-		DESCRIBE_SETTING(ALLOWED_HOSTS, "ALLOWED HOST ADDRESSES", "This is a comma-delimited list of IP address of hosts that are allowed to talk to NSClient deamon. If you leave this blank the global version will be used instead.");
-
-		DEFINE_SETTING_I(PORT, NSCLIENT_SECTION, "port", 12489);
-		//DESCRIBE_SETTING(PORT, "NSCLIENT PORT NUMBER", "This is the port the NSClientListener.dll will listen to.");
-
-		DEFINE_SETTING_S(BINDADDR, NSCLIENT_SECTION, GENERIC_KEY_BIND_TO, "");
-		//DESCRIBE_SETTING(BINDADDR, "BIND TO ADDRESS", "Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname. Leaving this blank will bind to all avalible IP adresses.");
-
-		DEFINE_SETTING_I(READ_TIMEOUT, NSCLIENT_SECTION, GENERIC_KEY_SOCK_READ_TIMEOUT, 30);
-		//DESCRIBE_SETTING(READ_TIMEOUT, "SOCKET TIMEOUT", "Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out.");
-
-		DEFINE_SETTING_I(LISTENQUE, NSCLIENT_SECTION, GENERIC_KEY_SOCK_LISTENQUE, 0);
-		//DESCRIBE_SETTING_ADVANCED(LISTENQUE, "LISTEN QUEUE", "Number of sockets to queue before starting to refuse new incoming connections. This can be used to tweak the amount of simultaneous sockets that the server accepts.");
-
-		DEFINE_SETTING_S(VERSION, NSCLIENT_SECTION, "version", "auto");
-		//DESCRIBE_SETTING(VERSION, "VERSION", "The version number to return for the CLIENTVERSION check (useful to \"simulate\" an old/different version of the client, auto will be generated from the compiled version string inside NSClient++");
-
-		DEFINE_SETTING_B(CACHE_ALLOWED, NSCLIENT_SECTION, GENERIC_KEY_SOCK_CACHE_ALLOWED, false);
-		//DESCRIBE_SETTING_ADVANCED(CACHE_ALLOWED, "ALLOWED HOSTS CACHING", "Used to cache looked up hosts if you check dynamic/changing hosts set this to false.");
-
-		DEFINE_SETTING_S(MASTER_KEY, NSCLIENT_SECTION, GENERIC_KEY_PWD_MASTER_KEY, "This is a secret key that you should change");
-		//DESCRIBE_SETTING(MASTER_KEY, "MASTER KEY", "The secret \"key\" used when (de)obfuscating passwords.");
-
-		DEFINE_SETTING_S(PWD, NSCLIENT_SECTION, GENERIC_KEY_PWD, "");
-		//DESCRIBE_SETTING(PWD, "PASSWORD", "This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.");
-
-		DEFINE_SETTING_S(OBFUSCATED_PWD, NSCLIENT_SECTION, GENERIC_KEY_OBFUSCATED_PWD, "");
-		//DESCRIBE_SETTING(OBFUSCATED_PWD, "OBFUSCATED PASSWORD", "This is the same as the password option but here you can store the password in an obfuscated manner. *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the password. Its just a bit harder to do it at first glance.");
-
-	}
-
-	namespace protocol_def {
-		DEFINE_SETTING_S(ALLOWED_HOSTS, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_ALLOWED_HOSTS, "");
-		DESCRIBE_SETTING(ALLOWED_HOSTS, "ALLOWED HOST ADDRESSES", "This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons. If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password). The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access");
-
-		DEFINE_SETTING_B(CACHE_ALLOWED, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_SOCK_CACHE_ALLOWED, false);
-		//DESCRIBE_SETTING_ADVANCED(CACHE_ALLOWED, "ALLOWED HOSTS CACHING", "Used to cache looked up hosts if you check dynamic/changing hosts set this to false.");
-
-		DEFINE_SETTING_S(MASTER_KEY, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_PWD_MASTER_KEY, "This is a secret key that you should change");
-		//DESCRIBE_SETTING(MASTER_KEY, "MASTER KEY", "The secret \"key\" used when (de)obfuscating passwords.");
-
-		DEFINE_SETTING_S(PWD, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_PWD, "");
-		//DESCRIBE_SETTING(PWD, "PASSWORD", "This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.");
-
-		DEFINE_SETTING_S(OBFUSCATED_PWD, DEFAULT_PROTOCOL_SECTION, GENERIC_KEY_OBFUSCATED_PWD, "");
-		//DESCRIBE_SETTING(OBFUSCATED_PWD, "OBFUSCATED PASSWORD", "This is the same as the password option but here you can store the password in an obfuscated manner. *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the password. Its just a bit harder to do it at first glance.");
-	}
-
-
-}
Index: modules/PythonScript/PythonScript.cpp
===================================================================
--- modules/PythonScript/PythonScript.cpp	(revision 76540c3258457ff0a673332e8da29bcce161e942)
+++ modules/PythonScript/PythonScript.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -440,5 +440,5 @@
 		std::wstring src, cmd, msg, perf;
 		int code = nscapi::functions::parse_simple_submit_request(request, src, cmd, msg, perf);
-		int ret = inst->handle_simple_message(chnl, to_string(src), to_string(cmd), code, msg, perf);
+		int ret = inst->handle_simple_message(chnl, utf8::cvt<std::string>(src), utf8::cvt<std::string>(cmd), code, msg, perf);
 		nscapi::functions::create_simple_submit_response(channel, cmd, ret, _T(""), response);
 		return ret;
Index: modules/SMTPClient/SMTPClient.cpp
===================================================================
--- modules/SMTPClient/SMTPClient.cpp	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ modules/SMTPClient/SMTPClient.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -30,4 +30,5 @@
 
 #include <settings/client/settings_client.hpp>
+#include <nscapi/nscapi_protobuf_functions.hpp>
 
 #include "smtp.hpp"
Index: modules/SMTPClient/SMTPClient.h
===================================================================
--- modules/SMTPClient/SMTPClient.h	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ modules/SMTPClient/SMTPClient.h	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -24,4 +24,5 @@
 #include <client/command_line_parser.hpp>
 #include <nscapi/targets.hpp>
+#include <nscapi/nscapi_protobuf_types.hpp>
 
 NSC_WRAPPERS_MAIN();
@@ -81,5 +82,5 @@
 		int timeout;
 
-		connection_data(nscapi::functions::destination_container arguments, nscapi::functions::destination_container target) {
+		connection_data(nscapi::protobuf::types::destination_container arguments, nscapi::protobuf::types::destination_container target) {
 			arguments.import(target);
 			recipient_str = arguments.get_string_data("recipient");
@@ -113,9 +114,9 @@
 		int exec(client::configuration::data_type data, const Plugin::ExecuteRequestMessage &request_message, std::string &reply);
 
-		virtual nscapi::functions::destination_container lookup_target(std::wstring &id) {
+		virtual nscapi::protobuf::types::destination_container lookup_target(std::wstring &id) {
 			nscapi::targets::optional_target_object opt = instance->targets.find_object(id);
 			if (opt)
 				return opt->to_destination_container();
-			nscapi::functions::destination_container ret;
+			nscapi::protobuf::types::destination_container ret;
 			return ret;
 		}
Index: modules/SyslogClient/SyslogClient.cpp
===================================================================
--- modules/SyslogClient/SyslogClient.cpp	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ modules/SyslogClient/SyslogClient.cpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -31,4 +31,5 @@
 
 #include <settings/client/settings_client.hpp>
+#include <nscapi/nscapi_protobuf_functions.hpp>
 
 namespace sh = nscapi::settings_helper;
Index: modules/SyslogClient/SyslogClient.h
===================================================================
--- modules/SyslogClient/SyslogClient.h	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ modules/SyslogClient/SyslogClient.h	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -25,4 +25,5 @@
 #include <client/command_line_parser.hpp>
 #include <nscapi/targets.hpp>
+#include <nscapi/nscapi_protobuf_types.hpp>
 
 NSC_WRAPPERS_MAIN();
@@ -105,18 +106,18 @@
 		std::string ok_severity, warn_severity, crit_severity, unknown_severity;
 
-		connection_data(nscapi::functions::destination_container recipient, nscapi::functions::destination_container target) {
-			recipient.import(target);
-			severity = recipient.data["severity"];
-			facility = recipient.data["facility"];
-			tag_syntax = recipient.data["tag template"];
-			message_syntax = recipient.data["message template"];
-
-			ok_severity = recipient.data["ok severity"];
-			warn_severity = recipient.data["warning severity"];
-			crit_severity = recipient.data["critical severity"];
-			unknown_severity = recipient.data["unknown severity"];
-
-			host = recipient.address.host;
-			port = recipient.address.get_port(514);
+		connection_data(nscapi::protobuf::types::destination_container arguments, nscapi::protobuf::types::destination_container target) {
+			arguments.import(target);
+			severity = arguments.data["severity"];
+			facility = arguments.data["facility"];
+			tag_syntax = arguments.data["tag template"];
+			message_syntax = arguments.data["message template"];
+
+			ok_severity = arguments.data["ok severity"];
+			warn_severity = arguments.data["warning severity"];
+			crit_severity = arguments.data["critical severity"];
+			unknown_severity = arguments.data["unknown severity"];
+
+			host = arguments.address.host;
+			port = arguments.address.get_port(514);
 		}
 
@@ -142,9 +143,9 @@
 		int exec(client::configuration::data_type data, const Plugin::ExecuteRequestMessage &request_message, std::string &reply);
 
-		virtual nscapi::functions::destination_container lookup_target(std::wstring &id) {
+		virtual nscapi::protobuf::types::destination_container lookup_target(std::wstring &id) {
 			nscapi::targets::optional_target_object opt = instance->targets.find_object(id);
 			if (opt)
 				return opt->to_destination_container();
-			nscapi::functions::destination_container ret;
+			nscapi::protobuf::types::destination_container ret;
 			return ret;
 		}
Index: scripts/python/test_python.py
===================================================================
--- scripts/python/test_python.py	(revision 0f7b655a31dd64a43d2c0518f62f8990d843f4f4)
+++ scripts/python/test_python.py	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -76,5 +76,5 @@
 		conf.set_string(base_path, 'threads', '0')
 
-		default_path = '%s/default'%base_path
+		default_path = '%s/python_test'%base_path
 		conf.set_string(default_path, 'channel', 'py_stress_test')
 		conf.set_string(default_path, 'alias', 'stress')
Index: version.hpp
===================================================================
--- version.hpp	(revision c74d7b64aa43946ade65cdc7f4e22c5738113174)
+++ version.hpp	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -1,6 +1,6 @@
 #ifndef VERSION_HPP
 #define VERSION_HPP
-#define PRODUCTVER     0,4,0,137
-#define STRPRODUCTVER  "0,4,0,137"
-#define STRPRODUCTDATE "2012-02-20"
+#define PRODUCTVER     0,4,0,140
+#define STRPRODUCTVER  "0,4,0,140"
+#define STRPRODUCTDATE "2012-02-22"
 #endif // VERSION_HPP
Index: version.txt
===================================================================
--- version.txt	(revision c74d7b64aa43946ade65cdc7f4e22c5738113174)
+++ version.txt	(revision 84cdb9bf7198880dba607fda52d79ff29184ab55)
@@ -1,3 +1,3 @@
 version=0.4.0
-build=137
-date=2012-02-20
+build=140
+date=2012-02-22
