anchor.diff:  %% @hidden
   update_session1(Type, Charge, Reserve, Now, ServiceId, ChargingKey, SessionId,
   		[#bucket{units = Type, remain_amount = Remain,
  -		reservations = Reservations} = B | T], Acc, Charged, Reserved)
  +		attributes = Attributes} = B | T], Acc, Charged, Reserved)
   		when ((Charge > Charged) or (Reserve > Reserved)), Remain > 0 ->
  +	#{reservations := Reservations} = Attributes,
   	NewCharge = Charge - Charged,
   	NewReserve = Reserve - Reserved,
  -	F = fun({_, _, _, ServiceId1, ChargingKey1, SessionId1})
  -					when ServiceId1 =:= ServiceId,
  +	F = fun({SessionId1, #{service_id := ServiceId1,
  +					charging_key := ChargingKey1}}) when ServiceId1 =:= ServiceId,
   					ChargingKey1 =:= ChargingKey, SessionId1 == SessionId ->
   				true;
   			({_, _, _, _, _, _}) ->
   				false
   	end,
  -	case lists:partition(F, Reservations) of
  -		{[{_, DebitedAmount, 0, ServiceId, ChargingKey, _}], NewReservations}
  +	case lists:partition(F, maps:to_list(Reservations)) of
  +		{[{_, #{debit := DebitedAmount, reserve := 0, service_id := ServiceId,
  +				charging_key := ChargingKey}}], NewReservations}
   				when Remain >= (NewCharge + NewReserve) ->
   			NewRemain = Remain - (NewReserve + NewCharge),
  -			NewReservation = {Now, DebitedAmount + NewCharge, NewReserve,
  -					ServiceId, ChargingKey, SessionId},
  +			ReservationList = [{SessionId, #{ts => Now,
  +					debit => DebitedAmount + NewCharge, reserve => NewReserve,
  +					service_id => ServiceId,
  +					charging_key => ChargingKey}} | NewReservations],
  +			NewAttributes = Attributes#{reservations
  +					=> maps:from_list(ReservationList)},
   			NewAcc = [B#bucket{remain_amount = NewRemain,
   					last_modified = {Now, erlang:unique_integer([positive])},
  -					reservations = [NewReservation | NewReservations]} | Acc],
  +					attributes = NewAttributes} | Acc],
   			update_session1(Type, Charge, Reserve, Now, ServiceId, ChargingKey,
   					SessionId, T, NewAcc, Charged + NewCharge, Reserved + NewReserve);
  -		{[{_, DebitedAmount, 0, ServiceId, ChargingKey, _}], NewReservations}
  -					when Remain >= NewCharge ->
  +		{[{_, #{debit := DebitedAmount, reserve := 0, service_id := ServiceId,
  +				charging_key := ChargingKey}}], NewReservations}
  +				when Remain >= NewCharge ->
   			NewReserved = Remain - NewCharge,
  -			NewReservation = {Now, DebitedAmount + NewCharge, NewReserved,
  -					ServiceId, ChargingKey, SessionId},
  +			ReservationList = [{SessionId, #{ts => Now,
  +					debit => DebitedAmount + NewCharge, reserve => NewReserved,
  +					service_id => ServiceId,
  +					charging_key => ChargingKey}} | NewReservations],
  +			NewAttributes = Attributes#{reservations
  +					=> maps:from_list(ReservationList)},
   			NewAcc = [B#bucket{remain_amount = 0,
   					last_modified = {Now, erlang:unique_integer([positive])},
  -					reservations = [NewReservation | NewReservations]} | Acc],
  +					attributes = NewAttributes} | Acc],
   			update_session1(Type, Charge, Reserve, Now, ServiceId, ChargingKey,
   					SessionId, T, NewAcc, Charged + NewCharge, Reserved + NewReserved);
  -		{[{_, DebitedAmount, 0, ServiceId, ChargingKey, _}], NewReservations}
  -					when NewCharge > 0 ->
  -			NewReservation = {Now, DebitedAmount + Remain, 0,
  -					ServiceId, ChargingKey, SessionId},
  +		{[{_, #{debit := DebitedAmount, reserve := 0, service_id := ServiceId,
  +				charging_key := ChargingKey}}], NewReservations}
  +				when NewCharge > 0 ->
  +			ReservationList = [{SessionId, #{ts => Now,
  +					debit => DebitedAmount + Remain, reserve => 0,
  +					service_id => ServiceId,
  +					charging_key => ChargingKey}} | NewReservations],
  +			NewAttributes = Attributes#{reservations
  +					=> maps:from_list(ReservationList)},
   			NewAcc = [B#bucket{remain_amount = 0,
   					last_modified = {Now, erlang:unique_integer([positive])},
  -					reservations = [NewReservation | NewReservations]} | Acc],
  +					attributes = NewAttributes} | Acc],
   			update_session1(Type, Charge, Reserve, Now, ServiceId, ChargingKey,
   					SessionId, T, NewAcc, Charged + Remain, Reserved);
  -		{[{_, DebitedAmount, ReservedAmount, ServiceId, ChargingKey, _}], NewReservations}
  -					when NewCharge =:= 0, Remain >= NewReserve ->
  -			NewReservation = {Now, DebitedAmount, ReservedAmount + NewReserve,
  -					ServiceId, ChargingKey, SessionId},
  +		{[{_, #{debit := DebitedAmount, reserve := ReservedAmount,
  +				service_id := ServiceId, charging_key := ChargingKey}}],
  +				NewReservations} when NewCharge =:= 0, Remain >= NewReserve ->
  +			ReservationList = [{SessionId, #{ts => Now, debit => DebitedAmount,
  +					reserve => ReservedAmount + NewReserve, service_id => ServiceId,
  +					charging_key => ChargingKey}} | NewReservations],
  +			NewAttributes = Attributes#{reservations
  +					=> maps:from_list(ReservationList)},
   			NewAcc = [B#bucket{remain_amount = Remain - NewReserve,
   					last_modified = {Now, erlang:unique_integer([positive])},
  -					reservations = [NewReservation | NewReservations]} | Acc],
  +					attributes = NewAttributes} | Acc],
   			update_session1(Type, Charge, Reserve, Now, ServiceId, ChargingKey,
   					SessionId, T, NewAcc, Charged, Reserved + NewReserve);
  -		{[{_, DebitedAmount, ReservedAmount, ServiceId, ChargingKey, _}], NewReservations}
  -					when NewCharge =:= 0 ->
  -			NewReservation = {Now, DebitedAmount, ReservedAmount + Remain,
  -					ServiceId, ChargingKey, SessionId},
  +		{[{_, #{debit := DebitedAmount, reserve := ReservedAmount,
  +				service_id := ServiceId, charging_key := ChargingKey}}],
  +				NewReservations} when NewCharge =:= 0 ->
  +			ReservationList = [{SessionId, #{ts => Now, debit => DebitedAmount,
  +					reserve => ReservedAmount + Remain, service_id => ServiceId,
  +					charging_key => ChargingKey}} | NewReservations],
  +			NewAttributes = Attributes#{reservations
  +					=> maps:from_list(ReservationList)},
   			NewAcc = [B#bucket{remain_amount = 0,
   					last_modified = {Now, erlang:unique_integer([positive])},
  -					reservations = [NewReservation | NewReservations]} | Acc],
  +					attributes = NewAttributes} | Acc],
   			update_session1(Type, Charge, Reserve, Now, ServiceId, ChargingKey,
   					SessionId, T, NewAcc, Charged, Reserved + Remain);
   		{[], _} ->
  
positive.code: 							ChargingKey, SessionId, Buckets3),
  					Rated3 = rated(Debits, Rated2),
  					Now = erlang:system_time(millisecond),
  					NewReservation = {Now, UnitsCharged, 0,
  							ServiceId, ChargingKey, SessionId},
  					LM = make_lm(),
  					Buckets5 = [#bucket{id = make_id(LM), last_modified = LM,
  							start_date = Now,
  							remain_amount = PriceCharged - PriceCharge,
  							reservations = [NewReservation],
  							units = cents, product = [ProductId]} | Buckets4],
  					charge3(Service, ServiceId, Product, Buckets5, final, DebitAmount, {Units, TotalUnits},
  							ReserveAmount, ReserveAmount, SessionId, Rated3, ChargingKey, Buckets)
  			end
  
negative.code: 			ServiceId, ChargingKey, SessionId, T, Charged, Acc);
  charge_session(Type, Charge, Now, ServiceId, ChargingKey, SessionId,
  		[#bucket{units = Type, remain_amount = Remain,
  		attributes = Attributes} = B | T], Charged, Acc) when Charge > 0 ->
  	#{reservations := Reservations} = Attributes,
  	case maps:take(SessionId, Reservations) of
  		{#{debit := DebitedAmount, reserve := ReservedAmount,
  				service_id := ServiceId, charging_key := ChargingKey},
  				NewReservations1} when ReservedAmount >= Charge ->
  			NewDebitedAmount = DebitedAmount + Charge,
  			NewReservedAmount = ReservedAmount - Charge,
  			NewReservations2 = NewReservations1#{SessionId => #{ts => Now,
  					debit => NewDebitedAmount, reserve => NewReservedAmount,
  					service_id => ServiceId, charging_key => ChargingKey}},
  			NewAcc = [B#bucket{attributes = Attributes#{reservations => NewReservations2},
  					last_modified = {Now, erlang:unique_integer([positive])}} | Acc],
  			charge_session(Type, 0, Now, ServiceId, ChargingKey, SessionId,
  					T, Charged + Charge, NewAcc);
  		{#{debit := DebitedAmount, reserve := ReservedAmount,
  				service_id := ServiceId, charging_key := ChargingKey}, NewReservations1}
  				when ReservedAmount < Charge, Remain >= (Charge - ReservedAmount) ->
  			NewDebitedAmount = DebitedAmount + Charge,
  			NewReservations2 = NewReservations1#{SessionId => #{ts => Now,
  					debit => NewDebitedAmount, reserve => 0,
  					service_id => ServiceId, charging_key => ChargingKey}},
  			NewAcc = [B#bucket{remain_amount = Remain - (Charge - ReservedAmount),
  					last_modified = {Now, erlang:unique_integer([positive])},
  					attributes = Attributes#{reservations => NewReservations2}} | Acc],
  			charge_session(Type, 0, Now, ServiceId, ChargingKey, SessionId,
  					T, Charged + Charge, NewAcc);
  		{#{debit := DebitedAmount, reserve := ReservedAmount,
  				service_id := ServiceId, charging_key := ChargingKey}, NewReservations1}
  				when ReservedAmount < Charge, Remain >= 0,
  				Remain < (Charge - ReservedAmount) ->
  			NewDebitedAmount = DebitedAmount + (Remain + ReservedAmount),
  			NewReservations2 = NewReservations1#{SessionId => #{ts => Now,
  			debit => NewDebitedAmount, reserve => 0, service_id => ServiceId,
  			charging_key => ChargingKey}},
  			NewAcc = [B#bucket{remain_amount = 0,
  					last_modified = {Now, erlang:unique_integer([positive])},
  					attributes = Attributes#{reservations => NewReservations2}} | Acc],
  			charge_session(Type, Charge - ReservedAmount - Remain,
  					Now, ServiceId, ChargingKey, SessionId,
  					T, Charged + ReservedAmount + Remain, NewAcc);
  