anchor.diff:  		{{_, _, _}, {_, _, _}} = Timestamp, Address, Direction, Flag,
   		DebitAmounts, ReserveAmounts, SessionAttributes)
   		when ((Protocol == radius) or (Protocol == diameter)),
  -		(is_integer(ChargingKey) or (ChargingKey == undefined)), 
  +		(is_integer(ChargingKey) or (ChargingKey == undefined)),
   		(is_list(ServiceNetwork) or (ServiceNetwork == undefined)),
   		is_binary(SubscriberID),
   		(is_list(Address) or (Address == undefined)),
  
positive.code: 		reservations = Reservations} = B | T],
  		Acc, Charged, Reserved) ->
  	case lists:keytake(SessionId, 4, Reservations) of
  % charge and reserve (done)
  		{value, {_, DebitedAmount, ReservedAmount, _}, NewReservations}
  				when ReservedAmount >= Charge, Remain >= Reserve ->
  erlang:display({?MODULE, ?LINE, Type, Charge, Reserve, DebitedAmount, ReservedAmount}),
  			NewReservedAmount = (ReservedAmount - Charge) + Reserve,
  			NewReservation = {Now, DebitedAmount + Charge, NewReservedAmount, SessionId},
  			NewRemain = Remain - Reserve,
  			NewBuckets = lists:reverse(Acc) ++ [B#bucket{remain_amount = NewRemain,
  					last_modified = {Now, erlang:unique_integer([positive])},
  					reservations = [NewReservation | NewReservations]} | T],
  erlang:display({?MODULE, ?LINE, Charged + Charge, Reserved + Reserve, NewBuckets}),
  			{Charged + Charge, Reserved + Reserve, NewBuckets};
  % charge and reserve (done)
  		{value, {_, DebitedAmount, ReservedAmount, _}, NewReservations}
  				when ReservedAmount =< Charge,
  				Remain >= ((Charge - ReservedAmount) + Reserve) ->
  erlang:display({?MODULE, ?LINE, Type, Charge, Reserve, DebitedAmount, ReservedAmount}),
  			NewReservation = {Now, DebitedAmount + Charge, Reserve, SessionId},
  			NewRemain = Remain - (Charge - ReservedAmount) - Reserve,
  			NewBuckets = lists:reverse(Acc) ++ [B#bucket{remain_amount = NewRemain,
  					last_modified = {Now, erlang:unique_integer([positive])},
  					reservations = [NewReservation | NewReservations]} | T],
  			{Charged + Charge, Reserved + Reserve, NewBuckets};
  % (partial) charge only
  		{value, {_, DebitedAmount, ReservedAmount, _}, NewReservations}
  				when Remain >= 0, (Remain + ReservedAmount) =< Charge ->
  erlang:display({?MODULE, ?LINE, Type, Charge, Reserve, DebitedAmount, ReservedAmount}),
  			NewDebitedAmount = DebitedAmount + Remain + ReservedAmount,
  			NewReservation = {Now, NewDebitedAmount, 0, SessionId},
  			NewAcc = [B#bucket{remain_amount = 0,
  
negative.code: 					reservations = [NewReservation | NewReservations]} | Acc],
  			update_session(Type, 0, Reserve - Remain, Now, SessionId,
  					T, NewAcc, Charged + Charge, Reserved + Remain);
  		{value, {_, DebitedAmount, ReservedAmount, _}, NewReservations}
  				when Charge > ReservedAmount, Remain >= (Charge - ReservedAmount),
  				Reserve > (Remain + (Charge - ReservedAmount)) ->
  			NewDebitedAmount = DebitedAmount + Charge,
  			NewReserve = Remain - (Charge - ReservedAmount),
  			NewReservation = {Now, NewDebitedAmount, NewReserve, SessionId},
  