<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>t/merle_t01.t</filename>
    </added>
    <added>
      <filename>t/merle_t02.t</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -8,8 +8,12 @@ docs:
 
 
 compile:
+	@mkdir -p ebin
 	@erl -make
 
 clean:
 	rm -f ebin/*.beam
 	rm -f erl_crash.dump
+
+test: all
+	prove -v t/*.t</diff>
      <filename>Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -24,256 +24,61 @@
 %% @author Joseph Williams &lt;joe@joetify.com&gt;
 %% @copyright 2008 Joseph Williams
 %% @version pre 0.1
-%% @doc an erlang memcached client.
+%% @seealso http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt
+%% @doc An Erlang memcached client.
 %%
 %% This code is available as Open Source Software under the MIT license.
 %%
 %% Updates at http://github.com/joewilliams/merle/
 
 -module(merle).
+-behaviour(gen_server).
 
 -author(&quot;Joseph Williams &lt;joe@joetify.com&gt;&quot;).
 -version(&quot;Version: pre 0.1&quot;).
 
--behaviour(gen_server).
-
 -define(SERVER, ?MODULE).
-
--define(TCP_OPTS, [binary, {packet, raw}, {nodelay, true}, 
-	{reuseaddr, true}, {active, true}]).
+-define(TIMEOUT, 5000).
+-define(TCP_OPTS, [
+    binary, {packet, raw}, {nodelay, true},{reuseaddr, true}, {active, true}
+]).
 
 %% gen_server API
--export([start_link/2, stats/0, stats/1, version/0,
-  get/1, delete/2, set/4, add/4, replace/4, cas/5, quit/0]).
-
-%% direct API
--export([stats/2, stats/3, version/2,
-  get/3, delete/4, set/6, add/6, replace/6, cas/7]).
+-export([
+    start_link/2, stats/0, stats/1, version/0, get/1, delete/2, set/4, add/4,
+    replace/4, cas/5
+]).
 
 %% gen_server callbacks
--export([init/1, handle_call/3, handle_cast/2, handle_info/2,
-	terminate/2, code_change/3]).
+-export([
+    init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
+    code_change/3
+]).
 
 -record(state, {socket}).
 
-%%====================================================================
-%% API
-%%====================================================================
-%%--------------------------------------------------------------------
-%% Function: start_link() -&gt; {ok,Pid} | ignore | {error,Error}
-%% Description: Starts the server
-%%--------------------------------------------------------------------
-start_link(Host, Port) -&gt;
-    gen_server:start_link({local, ?SERVER}, ?MODULE, [Host, Port], []).
-
-%%====================================================================
-%% gen_server callbacks
-%%====================================================================
-
-%%--------------------------------------------------------------------
-%% Function: init(Args) -&gt; {ok, State} |
-%%                         {ok, State, Timeout} |
-%%                         ignore               |
-%%                         {stop, Reason}
-%% Description: Initiates the server
-%%--------------------------------------------------------------------
-init([Host, Port]) -&gt;
-	{ok, Socket} = gen_tcp:connect(Host, Port, ?TCP_OPTS),
-  	{ok, #state{socket = Socket}}.
-
-%%--------------------------------------------------------------------
-%% Function: %% handle_call(Request, From, State) -&gt; {reply, Reply, State} |
-%%                                      {reply, Reply, State, Timeout} |
-%%                                      {noreply, State} |
-%%                                      {noreply, State, Timeout} |
-%%                                      {stop, Reason, Reply, State} |
-%%                                      {stop, Reason, State}
-%% Description: Handling call messages
-%%--------------------------------------------------------------------
-
-%%
-%% Infromational Commands
-%%	
-
-handle_call({stats}, _From, #state{socket = Socket} = S) -&gt;
-    Reply = send_generic_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;stats&quot;&gt;&gt;])),
-    {reply, Reply, S#state{socket = Socket}};
-
-handle_call({stats, {Args}}, _From, #state{socket = Socket} = S) -&gt;
-    Reply = send_generic_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;stats &quot;&gt;&gt;, Args])),
-    {reply, Reply, S#state{socket = Socket}};
-
-handle_call({version}, _From, #state{socket = Socket} = S) -&gt;
-    Reply = send_generic_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;version&quot;&gt;&gt;])),
-    {reply, Reply, S#state{socket = Socket}};
-
-%%    
-%% Retrieval Command
-%%
-    
-handle_call({getkey, {Key}}, _From, #state{socket = Socket} = S) -&gt;
-    Reply = send_get_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;get &quot;&gt;&gt;, Key])),
-    {reply, Reply, S#state{socket = Socket}};
-
-%%
-%% Deletion Command
-%%
-
-handle_call({delete, {Key, Time}}, _From, #state{socket = Socket} = S) -&gt;
-    Reply = send_generic_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;delete &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Time])),
-    {reply, Reply, S#state{socket = Socket}};
-
-%%	
-%% Storage Commands
-%%
-
-handle_call({set, {Key, Flag, ExpTime, Value}}, _From, #state{socket = Socket} = S) -&gt;
-	Bin = term_to_binary(Value),
-	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;set &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, 
-    	ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes]), Bin),
-    {reply, Reply, S#state{socket = Socket}};
-    
-handle_call({add, {Key, Flag, ExpTime, Value}}, _From, #state{socket = Socket} = S) -&gt;
-	Bin = term_to_binary(Value),
-	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;add &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, 
-    	ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes]), Bin),
-    {reply, Reply, S#state{socket = Socket}};
-
-handle_call({replace, {Key, Flag, ExpTime, Value}}, _From, #state{socket = Socket} = S) -&gt;
-	Bin = term_to_binary(Value),
-	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;replace &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, 
-    	ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes]), Bin),
-    {reply, Reply, S#state{socket = Socket}};
-    
-handle_call({append, {Key, Value}}, _From, #state{socket = Socket} = S) -&gt;
-	Bin = term_to_binary(Value),
-	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;append &quot;&gt;&gt;, Key, &lt;&lt;&quot; 0 0 &quot;&gt;&gt;, Bytes]), Bin),
-    {reply, Reply, S#state{socket = Socket}};
-
-handle_call({prepend, {Key, Value}}, _From, #state{socket = Socket} = S) -&gt;
-	Bin = term_to_binary(Value),
-	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;prepend &quot;&gt;&gt;, Key, &lt;&lt;&quot; 0 0 &quot;&gt;&gt;, Bytes]), Bin),
-    {reply, Reply, S#state{socket = Socket}};
-
-handle_call({cas, {Key, Flag, ExpTime, CasUniq, Value}}, _From, #state{socket = Socket} = S) -&gt;
-	Bin = term_to_binary(Value),
-	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;cas &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, 
-    	ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes, &lt;&lt;&quot; &quot;&gt;&gt;, CasUniq]), Bin),
-    {reply, Reply, S#state{socket = Socket}};
-
-%%
-%% Exit
-%%
-    
-handle_call({quit}, _From, #state{socket = Socket} = _) -&gt;
-	gen_tcp:close(Socket),
-	{reply, quit, {}}.
-	
-
-%%--------------------------------------------------------------------
-%% Function: handle_cast(Msg, State) -&gt; {noreply, State} |
-%%                                      {noreply, State, Timeout} |
-%%                                      {stop, Reason, State}
-%% Description: Handling cast messages
-%%--------------------------------------------------------------------
-handle_cast(_Msg, State) -&gt;
-    {noreply, State}.
-
-%%--------------------------------------------------------------------
-%% Function: handle_info(Info, State) -&gt; {noreply, State} |
-%%                                       {noreply, State, Timeout} |
-%%                                       {stop, Reason, State}
-%% Description: Handling all non call/cast messages
-%%--------------------------------------------------------------------
-handle_info(_Info, State) -&gt;
-    {noreply, State}.
-
-%%--------------------------------------------------------------------
-%% Function: terminate(Reason, State) -&gt; void()
-%% Description: This function is called by a gen_server when it is about to
-%% terminate. It should be the opposite of Module:init/1 and do any necessary
-%% cleaning up. When it returns, the gen_server terminates with Reason.
-%% The return value is ignored.
-%%--------------------------------------------------------------------
-terminate(_Reason, _State) -&gt;
-    ok.
-
-%%--------------------------------------------------------------------
-%% Func: code_change(OldVsn, State, Extra) -&gt; {ok, NewState}
-%% Description: Convert process state when code is changed
-%%--------------------------------------------------------------------
-code_change(_OldVsn, State, _Extra) -&gt;
-    {ok, State}.
-
-%%--------------------------------------------------------------------
-%%% gen_server API functions
-%%--------------------------------------------------------------------
-
-%% Command descriptions savagely ripped from:
-%% http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt
-
-%%
-%% Infromational Commands
-%%	
-
 %% @doc retrieve memcached stats using gen_server
 stats() -&gt;
 	gen_server:call(?SERVER, {stats}).
 
-%% @doc retrieve memcached stats directly
-stats(Host, Port) -&gt;
-    Reply = send_generic_cmd(Host, Port, iolist_to_binary([&lt;&lt;&quot;stats&quot;&gt;&gt;])),
-    Reply.
-
 %% @doc retrieve memcached stats based on args using gen_server
 stats(Args) -&gt;
-	gen_server:call(?SERVER, {stats,{Args}}).
-
-%% @doc retrieve memcached stats based on args directly
-stats(Host, Port, Args) -&gt;
-    Reply = send_generic_cmd(Host, Port, iolist_to_binary([&lt;&lt;&quot;stats &quot;&gt;&gt;, Args])),
-    Reply.
+	gen_server:call(?SERVER, {stats, {Args}}).
 
 %% @doc retrieve memcached version using gen_server
 version() -&gt;
 	gen_server:call(?SERVER, {version}).
 
-%% @doc retrieve memcached stats based on args directly
-version(Host, Port) -&gt;
-    Reply = send_generic_cmd(Host, Port, iolist_to_binary([&lt;&lt;&quot;version&quot;&gt;&gt;])),
-    Reply.
-
-%%    
-%% Retrieval Command
-%%
-
 %% @doc retrieve value based off of key using gen_server
 get(Key) -&gt;
-	gen_server:call(?SERVER, {getkey,{Key}}).
-
-%% @doc retrieve value based off of key directly
-get(Host, Port, Key) -&gt;
-	Reply = send_get_cmd(Host, Port, iolist_to_binary([&lt;&lt;&quot;get &quot;&gt;&gt;, Key])),
-	Reply.
-
-%%
-%% Deletion Command
-%%	
+	case gen_server:call(?SERVER, {getkey,{Key}}) of
+	    [&quot;END&quot;] -&gt; undefined;
+	    [X] -&gt; X
+	end.
 
 %% @doc delete a key and specify time using gen_server
 delete(Key, Time) -&gt;
 	gen_server:call(?SERVER, {delete, {Key, Time}}).
-
-%% @doc delete a key and specify time directly
-delete(Host, Port, Key, Time) -&gt;
-	Reply = send_generic_cmd(Host, Port, iolist_to_binary([&lt;&lt;&quot;delete &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Time])),
-	Reply.
 	
 %% Time is the amount of time in seconds
 %% the client wishes the server to refuse 
@@ -299,63 +104,139 @@ delete(Host, Port, Key, Time) -&gt;
 
 %% @doc &quot;store this value&quot; using gen_server
 set(Key, Flag, ExpTime, Value) -&gt;
-	gen_server:call(?SERVER, {set, {Key, Flag, ExpTime, Value}}).
+	case gen_server:call(?SERVER, {set, {Key, Flag, ExpTime, Value}}) of
+	    [&quot;STORED&quot;] -&gt; ok;
+	    X -&gt; X
+	end.
 
-%% @doc &quot;store this value&quot; directly
-set(Host, Port, Key, Flag, ExpTime, Value) -&gt;
-	Bin = term_to_binary(Value),
-	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Host, Port, iolist_to_binary([&lt;&lt;&quot;set &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, 
-    	ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes]), Bin),
-    Reply.
-    
-%% @doc &quot;store this value, but only if the server *doesn't* already hold Value for this key&quot; using gen_server
+%% @doc Store a key/value pair.
 add(Key, Flag, ExpTime, Value) -&gt;
 	gen_server:call(?SERVER, {add, {Key, Flag, ExpTime, Value}}).
 
-%% @doc &quot;store this value, but only if the server *doesn't* already hold Value for this key&quot; directly
-add(Host, Port, Key, Flag, ExpTime, Value) -&gt;
-	Bin = term_to_binary(Value),
-	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Host, Port, iolist_to_binary([&lt;&lt;&quot;add &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, 
-    	ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes]), Bin),
-    Reply.
-    
-%% @doc &quot;store this value, but only if the server *does* already hold Value for this key&quot; using gen_server
+%% @doc Replace an existing key/value pair.
 replace(Key, Flag, ExpTime, Value) -&gt;
 	gen_server:call(?SERVER, {replace, {Key, Flag, ExpTime, Value}}).
 
-%% @doc &quot;store this value, but only if the server *does* already hold Value for this key&quot; directly
-replace(Host, Port, Key, Flag, ExpTime, Value) -&gt;
-	Bin = term_to_binary(Value),
-	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Host, Port, iolist_to_binary([&lt;&lt;&quot;replace &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, 
-    	ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes]), Bin),
-    Reply.
-    
-%% @doc &quot;store this Vvlue but only if no one else has updated since I last fetched it&quot; using gen_server
+%% @doc Store a key/value pair if possible.
 cas(Key, Flag, ExpTime, CasUniq, Value) -&gt;
 	gen_server:call(?SERVER, {cas, {Key, Flag, ExpTime, CasUniq, Value}}).
 
-%% @doc &quot;store this Vvlue but only if no one else has updated since I last fetched it&quot; directly
-cas(Host, Port, Key, Flag, ExpTime, CasUniq, Value) -&gt;
+%% @private
+start_link(Host, Port) -&gt;
+    gen_server:start_link({local, ?SERVER}, ?MODULE, [Host, Port], []).
+
+%% @private
+init([Host, Port]) -&gt;
+    gen_tcp:connect(Host, Port, ?TCP_OPTS).
+
+%% @private
+handle_call({stats}, _From, Socket) -&gt;
+    Reply = send_generic_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;stats&quot;&gt;&gt;])),
+    {reply, Reply, Socket};
+
+handle_call({stats, {Args}}, _From, Socket) -&gt;
+    Reply = send_generic_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;stats &quot;&gt;&gt;, Args])),
+    {reply, Reply, Socket};
+
+handle_call({version}, _From, Socket) -&gt;
+    Reply = send_generic_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;version&quot;&gt;&gt;])),
+    {reply, Reply, Socket};
+
+handle_call({getkey, {Key}}, _From, Socket) -&gt;
+    Reply = send_get_cmd(Socket, iolist_to_binary([&lt;&lt;&quot;get &quot;&gt;&gt;, Key])),
+    {reply, Reply, Socket};
+
+handle_call({delete, {Key, Time}}, _From, Socket) -&gt;
+    Reply = send_generic_cmd(
+        Socket,
+        iolist_to_binary([&lt;&lt;&quot;delete &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Time])
+    ),
+    {reply, Reply, Socket};
+
+handle_call({set, {Key, Flag, ExpTime, Value}}, _From, Socket) -&gt;
+	Bin = term_to_binary(Value),
+	Bytes = integer_to_list(size(Bin)),
+    Reply = send_storage_cmd(
+        Socket,
+        iolist_to_binary([
+            &lt;&lt;&quot;set &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes
+        ]),
+        Bin
+    ),
+    {reply, Reply, Socket};
+    
+handle_call({add, {Key, Flag, ExpTime, Value}}, _From, Socket) -&gt;
 	Bin = term_to_binary(Value),
 	Bytes = integer_to_list(size(Bin)),
-    Reply = send_storage_cmd(Host, Port, iolist_to_binary([&lt;&lt;&quot;cas &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, 
-    	ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes, &lt;&lt;&quot; &quot;&gt;&gt;, CasUniq]), Bin),
-    Reply.
+    Reply = send_storage_cmd(
+        Socket,
+        iolist_to_binary([
+            &lt;&lt;&quot;add &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes
+        ]),
+        Bin
+    ),
+    {reply, Reply, Socket};
+
+handle_call({replace, {Key, Flag, ExpTime, Value}}, _From, Socket) -&gt;
+	Bin = term_to_binary(Value),
+	Bytes = integer_to_list(size(Bin)),
+    Reply = send_storage_cmd(
+        Socket,
+        iolist_to_binary([
+            &lt;&lt;&quot;replace &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;,
+            Bytes
+        ]),
+    	Bin
+    ),
+    {reply, Reply, Socket};
+    
+handle_call({append, {Key, Value}}, _From, Socket) -&gt;
+	Bin = term_to_binary(Value),
+	Bytes = integer_to_list(size(Bin)),
+    Reply = send_storage_cmd(
+        Socket,
+        iolist_to_binary([&lt;&lt;&quot;append &quot;&gt;&gt;, Key, &lt;&lt;&quot; 0 0 &quot;&gt;&gt;, Bytes]),
+        Bin
+    ),
+    {reply, Reply, Socket};
+
+handle_call({prepend, {Key, Value}}, _From, Socket) -&gt;
+	Bin = term_to_binary(Value),
+	Bytes = integer_to_list(size(Bin)),
+    Reply = send_storage_cmd(
+        Socket,
+        iolist_to_binary([&lt;&lt;&quot;prepend &quot;&gt;&gt;, Key, &lt;&lt;&quot; 0 0 &quot;&gt;&gt;, Bytes]),
+        Bin
+    ),
+    {reply, Reply, Socket};
+
+handle_call({cas, {Key, Flag, ExpTime, CasUniq, Value}}, _From, Socket) -&gt;
+	Bin = term_to_binary(Value),
+	Bytes = integer_to_list(size(Bin)),
+    Reply = send_storage_cmd(
+        Socket,
+        iolist_to_binary([
+            &lt;&lt;&quot;cas &quot;&gt;&gt;, Key, &lt;&lt;&quot; &quot;&gt;&gt;, Flag, &lt;&lt;&quot; &quot;&gt;&gt;, ExpTime, &lt;&lt;&quot; &quot;&gt;&gt;, Bytes,
+            &lt;&lt;&quot; &quot;&gt;&gt;, CasUniq
+        ]),
+        Bin
+    ),
+    {reply, Reply, Socket}.
+	
+%% @private
+handle_cast(_Msg, State) -&gt; {noreply, State}.
 
-%%
-%% Exit
-%%	
+%% @private
+handle_info(_Info, State) -&gt; {noreply, State}.
 
-%% @doc quit() close the socket using gen_server
-quit() -&gt;
-	gen_server:call(?SERVER, {quit}).
-	
-%%--------------------------------------------------------------------
-%%% Internal functions
-%%--------------------------------------------------------------------
+%% @private
+code_change(_OldVsn, State, _Extra) -&gt; {ok, State}.
+
+%% @private
+%% @doc Closes the socket
+terminate(_Reason, #state{socket = Socket}) -&gt;
+    gen_tcp:close(Socket),
+    ok.
 
 %% @private
 %% @doc send_generic_cmd/2 function for simple informational and deletion commands
@@ -365,31 +246,12 @@ send_generic_cmd(Socket, Cmd) -&gt;
 	Reply.
 
 %% @private
-%% @doc send_generic_cmd/3 function for simple informational and deletion commands sent directly to memcached
-send_generic_cmd(Host, Port, Cmd) -&gt;
-	{ok, Socket} = gen_tcp:connect(Host, Port, ?TCP_OPTS),
-    gen_tcp:send(Socket, &lt;&lt;Cmd/binary, &quot;\r\n&quot;&gt;&gt;),
-	Reply = recv_simple_reply(),
-	gen_tcp:close(Socket),
-	Reply.	
-
-%% @private
 %% @doc send_storage_cmd/3 funtion for storage commands
 send_storage_cmd(Socket, Cmd, Value) -&gt;
     gen_tcp:send(Socket, &lt;&lt;Cmd/binary, &quot;\r\n&quot;&gt;&gt;),
     gen_tcp:send(Socket, &lt;&lt;Value/binary, &quot;\r\n&quot;&gt;&gt;),
     Reply = recv_simple_reply(),
-   	Reply.
-
-%% @private
-%% @doc send_storage_cmd/4 funtion for storage commands sent directly to memcached
-send_storage_cmd(Host, Port, Cmd, Value) -&gt;
-	{ok, Socket} = gen_tcp:connect(Host, Port, ?TCP_OPTS),
-    gen_tcp:send(Socket, &lt;&lt;Cmd/binary, &quot;\r\n&quot;&gt;&gt;),
-    gen_tcp:send(Socket, &lt;&lt;Value/binary, &quot;\r\n&quot;&gt;&gt;),
-    Reply = recv_simple_reply(),
-	gen_tcp:close(Socket),
-   	Reply.   	
+   	Reply.	
 
 %% @private
 %% @doc send_get_cmd/2 function for retreival commands
@@ -399,21 +261,12 @@ send_get_cmd(Socket, Cmd) -&gt;
 	Reply.
 
 %% @private
-%% @doc send_get_cmd/3 function for retreival commands sent directly to memcached
-send_get_cmd(Host, Port, Cmd) -&gt;
-	{ok, Socket} = gen_tcp:connect(Host, Port, ?TCP_OPTS),
-    gen_tcp:send(Socket, &lt;&lt;Cmd/binary, &quot;\r\n&quot;&gt;&gt;),
-	Reply = recv_complex_reply(Socket),
-	gen_tcp:close(Socket),
-	Reply.
-
-%% @private
 %% @doc receive function for simple responses (not containing VALUEs)
 recv_simple_reply() -&gt;
 	receive
 	  	{tcp,_,Data} -&gt;
         	string:tokens(binary_to_list(Data), &quot;\r\n&quot;)
-    after 5000 -&gt;
+    after ?TIMEOUT -&gt;
    		timeout
     end.
     
@@ -421,9 +274,9 @@ recv_simple_reply() -&gt;
 %% @doc receive function for respones containing VALUEs
 recv_complex_reply(Socket) -&gt;
 	receive
+	    %% NKG: Does this need a wilecard?
 		%% For receiving get responses where the key does not exist
-		{tcp, Socket, &lt;&lt;&quot;END\r\n&quot;&gt;&gt;} -&gt;
-			[&quot;END&quot;];
+		{tcp, Socket, &lt;&lt;&quot;END\r\n&quot;&gt;&gt;} -&gt; [&quot;END&quot;];
 		%% For receiving get responses containing data	
 		{tcp, Socket, Data} -&gt;
 			%% Reply format &lt;&lt;&quot;VALUE SOMEKEY FLAG BYTES\r\nSOMEVALUE\r\nEND\r\n&quot;&gt;&gt;
@@ -432,22 +285,20 @@ recv_complex_reply(Socket) -&gt;
   			Bin = list_to_binary(ListBin),
   			Reply = get_data(Socket, Bin, Bytes, length(ListBin)),
   			[Reply]
-    after 5000 -&gt;
-   		timeout
+    after ?TIMEOUT -&gt; timeout
     end.
 
 %% @private
-%% @doc recieve loop to get all data   
-get_data(Socket, Bin, Bytes, Len) -&gt;
-	if
-	Len &lt; Bytes + 7 -&gt;
-		receive
-			{tcp, Socket, Data} -&gt;
-				Combined = &lt;&lt;Bin/binary, Data/binary&gt;&gt;,
-		 		get_data(Socket, Combined, Bytes, size(Combined))
-		after 5000 -&gt;
-	   		timeout
-	    end;
-	true -&gt;
-		binary_to_term(Bin)
-	end.
+%% @doc recieve loop to get all data
+%% @todo 
+get_data(Socket, Bin, Bytes, Len) when Len &lt; Bytes + 7-&gt;
+    receive
+        %% NKG: Does this need a wildcard?
+        {tcp, Socket, Data} -&gt;
+            Combined = &lt;&lt;Bin/binary, Data/binary&gt;&gt;,
+            get_data(Socket, Combined, Bytes, size(Combined));
+        _ -&gt; error
+        after ?TIMEOUT -&gt; timeout
+    end;
+get_data(_, Bin, _, _) -&gt;
+    binary_to_term(Bin).</diff>
      <filename>src/merle.erl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d75570b65b86147fbc50f4fe0f4a2901dc9033bb</id>
    </parent>
  </parents>
  <author>
    <name>Nick Gerakines</name>
    <email>nick@gerakines.net</email>
  </author>
  <url>http://github.com/joewilliams/merle/commit/8a13cc2b832c190f0526272b18acfe6d0bc5e7af</url>
  <id>8a13cc2b832c190f0526272b18acfe6d0bc5e7af</id>
  <committed-date>2009-01-18T19:51:37-08:00</committed-date>
  <authored-date>2009-01-18T19:51:37-08:00</authored-date>
  <message>First round of tweaks to merle. Removed a grip of redundant code, modified documentation and added etap-friendly test suite.</message>
  <tree>f3c26f34604cb7ca0500cb01eea0420a7a0dcbe4</tree>
  <committer>
    <name>Nick Gerakines</name>
    <email>nick@gerakines.net</email>
  </committer>
</commit>
