{application, amqp,
  [{description, "AMQP client operations"},
-  {vsn, "3"},
+  {vsn, "4"},
   {modules, [amqp_app, amqp_bot_sup, amqp_bot_connection, amqp_bot_listener]},
   {registered, [amqp_bot_connection]},
   {applications, [core]},
 
-{"3",
- [{"2",
-   [{update, amqp_bot_listener}]
+{"4",
+ [{"3",
+   [{update, amqp_bot_connection},
+    {update, amqp_bot_sup, supervisor}]
   }],
- [{"2",
-   [{update, amqp_bot_listener}]
+ [{"3",
+   [{update, amqp_bot_connection},
+    {update, amqp_bot_sup, supervisor}]
   }]
 }.
 
-{release, {"erlbot", "13"},
+{release, {"erlbot", "14"},
  {erts, "5.8.3"},
  [{kernel, "2.14.5"},
   {stdlib, "1.17.5"},
   {sasl, "2.1.10"},
   {rabbit_common, "0.0.0"},
   {amqp_client, "0.0.0"},
-  {core, "2"},
-  {amqp, "3"},
-  {irc, "12"}]
+  {core, "3"},
+  {amqp, "4"},
+  {irc, "13"}]
 }.
 
 {application, core,
  [{description, "IRC bot core functionality"},
-  {vsn, "2"},
-  {modules, [core_app, core_sup, config]},
+  {vsn, "3"},
+  {modules, [core_app, core_sup, config, rate_limit]},
   {registered, [config]},
   {applications, []}, % also depends on kernel, stdlib
   {mod, {core_app, none}}
 
-{"2",
- [{"1", [{load_module, config}]}],
- [{"1", [{load_module, config}]}]}.
+{"3",
+ [{"2", [{add_module, rate_limit}]}],
+ [{"2", [{delete_module, rate_limit}]}]}.
 
 {application, irc,
  [{description, "IRC protocol application"},
-  {vsn, "12"},
+  {vsn, "13"},
   {modules, [irc_util, irc_app, irc_sup, irc_net_sup, irc_conn,
              irc_object_sup, irc_amqp_listener, irc_command]},
   {registered, [irc_sup, irc_dummy]},
 
-{"12",
- [{"11",
-   [{update, irc_command},
-    {update, irc_amqp_listener}
+{"13",
+ [{"12",
+   [{update, irc_amqp_listener},
+    {update, irc_object_sup},
+    {update, irc_conn, {advanced, ok}}
    ]}],
- [{"11",
-   [{update, irc_command},
-    {update, irc_amqp_listener}
+ [{"12",
+   [{update, irc_amqp_listener},
+    {update, irc_object_sup},
+    {update, irc_conn, {advanced, ok}}
    ]}]
 }.
 
 -module(irc_conn).
 -behavior(gen_server).
--vsn(5).
+-vsn(6).
 
 -define(RECONNECT_TIME, 30000).
 -define(PING_PERIOD, timer:seconds(30)).
 terminate(_Reason, _State) ->
     ok.
 
-code_change(4, OldState, ok) ->
-    NewState = list_to_tuple(tuple_to_list(OldState) ++ [none]),
-    error_logger:info_msg("Updating irc state from ~p to ~p~n", [OldState, NewState]),
-    {ok, NewState};
-
-code_change({down, 4}, State, ok) ->
-    TimerRef = State#irc_state.ping_timer,
-    timer:cancel(TimerRef),
-    {ok, list_to_tuple(lists:sublist(tuple_to_list(State), 9))};
+code_change(5, State, ok) ->
+    #irc_state{instance = Instance,
+               object_sup = ObjectSup} = State,
+    RoutingKey = get_routing_key(Instance),
+    irc_object_sup:delete_amqp_listener(ObjectSup, RoutingKey),
+    % TODO: test that the message is handled *after* the code change.
+    gen_server:cast(self(), create_object_sup),
+    {ok, State};
+
+code_change({down, 5}, State, ok) ->
+    % Since there's no actual state change, the exact same instructions are fine.
+    code_change(5, State, ok);
 
 code_change(_OldVsn, _State, _Extra) ->
        {error, unsupported}.