anchor.diff:    % Run maintenance
     timer:send_interval(timer:seconds(20), {ping_bees}),
     timer:send_interval(timer:minutes(10), {garbage_collection}),
  +  
  +  timer:send_interval(timer:minutes(2), {clean_up_apps}),
     {ok, #state{}}.
   
   %%--------------------------------------------------------------------
  
positive.code:   active_apps = [],     % Active applications (that have their socket handled via proxy_handler)
    dead_apps = []        % Apps that have been killed and or are dead
  }).
  -define (SERVER, ?MODULE).
  
  %%====================================================================
  
negative.code:   update_app_configuration(ConfigProplist, #app{}, State).
  
  % Clean up applications
  clean_up() ->
    Apps = apps:all(),
    lists:map(fun(App) -> 
      Bees = bees:find_all_by_name(App#app.name),
      RunningBackends = lists:filter(fun(B) -> B#bee.status =:= ready end, Bees),
      Proplist = [{num_backends, erlang:length(RunningBackends)}],
      clean_up_instances(Bees, App, Proplist) 
    end, Apps).
    
  % Clean up the instances
  clean_up_instances([], _, Proplist) -> Proplist;
  clean_up_instances([Backend|Rest], App, Proplist) -> 
    clean_up_instance(Backend, App, Proplist),
    clean_up_instances(Rest, App, Proplist).
  
  % Cleanup a single instance
  clean_up_instance(Backend, App, Proplist) ->
    % If the instance of the application has been used before
    case Backend#bee.lastresp_time of
      0 -> Proplist;
      _Time ->  clean_up_on_app_timeout(Backend, App, Proplist)
    end.
    
  % If the instance is not busy, the timeout has been exceeded and there are other application instances running
  clean_up_on_app_timeout(#bee{lastresp_time=LastReq} = Backend, #app{timeout=Timeout,sticky=Sticky} = App, Proplist) ->
    _NumBackends = proplists:get_value(num_backends, Proplist),
  	TimeDiff = date_util:time_difference_from_now(LastReq),
    % ?LOG(info, "clean_up_on_app_timeout: ~p > ~p, ~p > ~p", [NumBackends, Min, TimeDiff, Timeout]),
    if
      % stop_instance(Backend, App, From)
      % NumBackends > Min andalso 
      TimeDiff > Timeout andalso Sticky =/= true -> node_manager:request_to_terminate_bee(Backend);
      true -> clean_up_on_busy_and_stale_status(Backend, App, Proplist)
    end.
      
  % If the instance is busy, but hasn't served a request in a long time, kill it
  clean_up_on_busy_and_stale_status(#bee{status = Status, lastresp_time = LastReq} = Backend, #app{timeout = Timeout} = App, Proplist) ->
  	TimeDiff = date_util:time_difference_from_now(LastReq),
    % ?LOG(info, "clean_up_on_busy_and_stale_status: ~p > ~p + ~p", [TimeDiff, Timeout, ?TIME_BUFFER]),
    if
      Status =:= busy andalso TimeDiff > Timeout + ?TIME_BUFFER -> 
  			node_manager:request_to_terminate_bee(Backend);
      true -> clean_up_on_long_running_instance(Backend, App, Proplist)
    end.
  
  % If the application has been running for a while, kill it
  clean_up_on_long_running_instance(#bee{start_time = StartTime} = Backend, _App, Proplist) ->
  	TimeDiff = date_util:time_difference_from_now(StartTime),
    % ?LOG(info, "clean_up_on_long_running_instance: ~p > ~p", [TimeDiff, ?RUN_INSTANCE_TIME_PERIOD]),
    if
      TimeDiff > ?RUN_INSTANCE_TIME_PERIOD -> node_manager:request_to_terminate_bee(Backend);
      true -> Proplist
    end.
  
  load_static_configs() ->
  