if(!Package['iron:router']) return;

var RouteController = Package['iron:router'].RouteController;
var Router = Package['iron:router'].Router;

var currentSubscriptions = [];
Meteor.subscribe = function(subscription) {
  currentSubscriptions.push(arguments);
};

//assuming, no runtime routes will be added
Meteor.startup(function() {
  // this is trick to run the processRoutes at the 
  // end of all Meteor.startup callbacks
  Meteor.startup(processRoutes);
});

function processRoutes() {
  Router.routes.forEach(function(route) {
    route.options = route.options || {};
    if(route.options.fastRender) {
      handleRoute(route);
    } else if(
        route.findControllerConstructor && route.findControllerConstructor().prototype.fastRender ||
        route.findController && route.findController().prototype.fastRender /* for IR 0.9 */
    ) {
      handleRoute(route);
    }
  });

  // getting global waitOns
  var globalWaitOns = [];
  if(Router._globalHooks && Router._globalHooks.waitOn && Router._globalHooks.waitOn.length > 0) {
    Router._globalHooks.waitOn.forEach(function(waitOn) {
      globalWaitOns.push(waitOn.hook);
    });
  }
  
  FastRender.onAllRoutes(function(path) {
    var self = this;
    
    currentSubscriptions = [];
    globalWaitOns.forEach(function(waitOn) {
      waitOn.call({path: path});
    });
    
    currentSubscriptions.forEach(function(args) {
      self.subscribe.apply(self, args);
    });
  });
};

function handleRoute(route) {
  var subscriptionFunctions = [];
  
  // get potential subscription handlers from the route options
  ['waitOn', 'subscriptions'].forEach(function(funcName) {
    var handler = ( route.options[funcName] ||
                    route.findControllerConstructor && route.findControllerConstructor().prototype[funcName] ||
                    route.findController && route.findController().prototype[funcName] /* for IR 0.9 */ );
    if(typeof handler == 'function') {
      subscriptionFunctions.push(handler);
    } else if (handler instanceof Array) {
      handler.forEach(function(func) {
        if(typeof func == 'function') {
          subscriptionFunctions.push(func);
        }
      });
    }
  });

  FastRender.route(getPath(route), onRoute);

  function onRoute(params, path) {
    var self = this;
    var context = {
      params: params,
      path: path
    };

    //reset subscriptions;
    currentSubscriptions = [];
    subscriptionFunctions.forEach(function(func) {
      func.call(context);
    });

    // if there is a controller, try to initiate it and invoke potential 
    // methods which could give us subscriptions
    var controller = route.options.controller;
    if(controller && controller.prototype) {
      if(typeof controller.prototype.lookupOption == 'function') {
        // for IR 1.0
        // it is possible to create a controller invoke methods on it
        var controllerInstance = new controller();
        controllerInstance.params = params;
        controllerInstance.path = path;

        ['waitOn', 'subscriptions'].forEach(function(funcName) {
          if(controllerInstance[funcName]) {
            controllerInstance[funcName].call(controllerInstance);
          }
        });
      } else {
        // IR 0.9
        // hard to create a controller instance
        // so this is the option we can take
        var waitOn = controller.prototype.waitOn;
        if(waitOn) {
          waitOn.call(context);
        }
      }
    }

    currentSubscriptions.forEach(function(args) {
      self.subscribe.apply(self, args);
    });
  }
}

function getPath(route) {
  if(route._path) {
    // for IR 1.0
    return route._path;
  } else {
    // for IR 0.9
    var name = (route.name == "/")? "" : name;
    return route.options.path || ("/" + name);
  }
}

@@ -657,119 +657,87 @@
     
-route.findControllerConstructor && route.findControllerConstructor().prototype.fastRender %7C%7C%0A        route.find
+getController(route) && %0A        getController(route).prototype && %0A        get
 Cont
@@ -746,33 +746,14 @@
 ller
- && 
+(
 route
-.findController(
 ).pr
@@ -770,33 +770,16 @@
 stRender
- /* for IR 0.9 */
 %0A    ) %7B
@@ -1588,18 +1588,16 @@
 andler =
- (
  route.o
@@ -1616,229 +1616,8 @@
 ame%5D
- %7C%7C%0A                    route.findControllerConstructor && route.findControllerConstructor().prototype%5BfuncName%5D %7C%7C%0A                    route.findController && route.findController().prototype%5BfuncName%5D /* for IR 0.9 */ )
 ;%0A  
@@ -2356,23 +2356,12 @@
 r = 
-route.options.c
+getC
 ontr
@@ -2365,16 +2365,23 @@
 ntroller
+(route)
 ;%0A    if
@@ -3483,16 +3483,248 @@
  + name);%0A  %7D%0A%7D%0A
+%0Afunction getController (route) %7B%0A  if(route.findControllerConstructor) %7B%0A    // for IR 1.0%0A    return route.findControllerConstructor();%0A  %7D else if(route.findController) %7B%0A    // for IR 0.9%0A    return route.findController();%0A  %7D%0A%7D

refactor code and use controller only when needed