anchor.diff:      assoc(Sql, [], Context).
   
   assoc(Sql, Parameters, Context) ->
  -    case get_connection(Context) of
  -        none -> [];
  -        C ->
  -            try
  +    F = fun(C) when C =:= none -> [];
  +	   (C) ->
                   {ok, Result} = pgsql:assoc(C, Sql, Parameters),
                   Result
  -            after
  -                return_connection(C, Context)
  -            end
  -    end.
  +	end,
  +    with_connection(F, Context).
   
   
   assoc_props(Sql, Context) ->
       assoc_props(Sql, [], Context).
   
   assoc_props(Sql, Parameters, Context) ->
  -    case get_connection(Context) of
  -        none -> [];
  -        C ->
  -            try
  +    F = fun(C) when C =:= none -> [];
  +	   (C) ->
                   {ok, Result} = pgsql:assoc(C, Sql, Parameters),
                   merge_props(Result)
  -            after
  -                return_connection(C, Context)
  -            end
  -    end.
  +	end,
  +    with_connection(F, Context).
   
   
   q(Sql, Context) ->
       q(Sql, [], Context).
   
   q(Sql, Parameters, Context) ->
  -    case get_connection(Context) of
  -        none -> [];
  -        C ->
  -            try
  +    F = fun(C) when C =:= none -> [];
  +	   (C) ->
                   case pgsql:equery(C, Sql, Parameters) of
                       {ok, _Affected, _Cols, Rows} -> Rows;
                       {ok, _Cols, Rows} -> Rows;
                       {ok, Rows} -> Rows
                   end
  -            after
  -                return_connection(C, Context)
  -            end
  -    end.
  +	end,
  +    with_connection(F, Context).
   
   q1(Sql, Context) ->
       q1(Sql, [], Context).
   
   q1(Sql, Parameters, Context) ->
  -    case get_connection(Context) of
  -        none -> undefined;
  -        C ->
  -            try
  +    F = fun(C) when C =:= none -> undefined;
  +	   (C) ->
                   case pgsql:equery1(C, Sql, Parameters) of
                       {ok, Value} -> Value;
                       {error, noresult} -> undefined
                   end
  -            after
  -                return_connection(C, Context)
  -            end
  -    end.
  +	end,
  +    with_connection(F, Context).
  +	
   
   q_row(Sql, Context) ->
       q_row(Sql, [], Context).
  
positive.code:         false -> Sql
      end,
  
      C = get_connection(Context),
      try
          Id = case pgsql:equery1(C, FinalSql, Parameters) of
                  {ok, IdVal} -> IdVal;
                  {error, noresult} -> undefined
               end,
           {ok, Id}
      after
          return_connection(C, Context)
      end.
  
  %% @doc Update a row in a table, merging the props list with any new props values
  %% @spec update(Table, Id, Parameters, Context) -> {ok, RowsUpdated}
  
negative.code:                  ++ " where id = $1",
          {ok, RowsUpdated} = pgsql:equery1(C, Sql, [Id | Params]),
          {ok, RowsUpdated}
      end,
      with_connection(F, Context).
  
  
  %% @doc Delete a row from a table, the row must have a column with the name 'id'
  