Update RequireJS to 1.0.2
Update RequireJS to 1.0.2

--- a/js/ext/require.js
+++ b/js/ext/require.js
@@ -1,34 +1,32 @@
 /*
- RequireJS 0.26.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
+ RequireJS 1.0.2 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
  Available via the MIT or new BSD license.
  see: http://github.com/jrburke/requirejs for details
 */
 var requirejs,require,define;
-(function(){function M(a){return $.call(a)==="[object Function]"}function E(a){return $.call(a)==="[object Array]"}function V(a,c,g){for(var e in c)if(!(e in J)&&(!(e in a)||g))a[e]=c[e];return d}function R(a,c,d){a=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+a);if(d)a.originalError=d;return a}function aa(a,c,d){var e,x,j;for(e=0;j=c[e];e++){j=typeof j==="string"?{name:j}:j;x=j.location;if(d&&(!x||x.indexOf("/")!==0&&x.indexOf(":")===-1))x=d+"/"+(x||j.name);a[j.name]={name:j.name,location:x||
-j.name,main:(j.main||"main").replace(fa,"").replace(ba,"")}}}function W(a,d){a.holdReady?a.holdReady(d):d?a.readyWait+=1:a.ready(!0)}function ga(a){function c(b,h){var n,o;if(b&&b.charAt(0)==="."&&h){p.pkgs[h]?h=[h]:(h=h.split("/"),h=h.slice(0,h.length-1));n=b=h.concat(b.split("/"));var a;for(o=0;a=n[o];o++)if(a===".")n.splice(o,1),o-=1;else if(a==="..")if(o===1&&(n[2]===".."||n[0]===".."))break;else o>0&&(n.splice(o-1,2),o-=2);o=p.pkgs[n=b[0]];b=b.join("/");o&&b===n+"/"+o.main&&(b=n)}return b}function g(b,
-h){var n=b?b.indexOf("!"):-1,o=null,a=h?h.name:null,ha=b,g,l;n!==-1&&(o=b.substring(0,n),b=b.substring(n+1,b.length));o&&(o=c(o,a));b&&(g=o?(n=m[o])?n.normalize?n.normalize(b,function(b){return c(b,a)}):c(b,a):"__$p"+a+"@"+(b||""):c(b,a),l=E[g],l||(l=d.toModuleUrl?d.toModuleUrl(f,g,h):f.nameToUrl(g,null,h),E[g]=l));return{prefix:o,name:g,parentMap:h,url:l,originalName:ha,fullName:o?o+"!"+(g||""):g}}function e(){var b=!0,h=p.priorityWait,n,a;if(h){for(a=0;n=h[a];a++)if(!s[n]){b=!1;break}b&&delete p.priorityWait}return b}
-function x(b){return function(h){b.exports=h}}function j(b,h,n){return function(){var a=[].concat(ia.call(arguments,0)),d;if(n&&M(d=a[a.length-1]))d.__requireJsBuild=!0;a.push(h);return b.apply(null,a)}}function q(b,h){var a=j(f.require,b,h);V(a,{nameToUrl:j(f.nameToUrl,b),toUrl:j(f.toUrl,b),defined:j(f.requireDefined,b),specified:j(f.requireSpecified,b),ready:d.ready,isBrowser:d.isBrowser});if(d.paths)a.paths=d.paths;return a}function v(b){var h=b.prefix,a=b.fullName;y[a]||a in m||(h&&!K[h]&&(K[h]=
-void 0,(S[h]||(S[h]=[])).push(b),(t[h]||(t[h]=[])).push({onDep:function(b){if(b===h){var a,n,d,c,f,e,j=S[h];if(j)for(d=0;a=j[d];d++)if(b=a.fullName,a=g(a.originalName,a.parentMap),a=a.fullName,n=t[b]||[],c=t[a],a!==b){b in y&&(delete y[b],y[a]=!0);t[a]=c?c.concat(n):n;delete t[b];for(c=0;c<n.length;c++){e=n[c].depArray;for(f=0;f<e.length;f++)e[f]===b&&(e[f]=a)}}delete S[h]}}}),v(g(h))),f.paused.push(b))}function w(b){var h,a,c;h=b.callback;var k=b.fullName,e=[],j=b.depArray;if(h&&M(h)){if(j)for(h=
-0;h<j.length;h++)e.push(b.deps[j[h]]);if(p.catchError.define)try{a=d.execCb(k,b.callback,e,m[k])}catch(l){c=l}else a=d.execCb(k,b.callback,e,m[k]);if(k)b.cjsModule&&b.cjsModule.exports!==void 0?a=m[k]=b.cjsModule.exports:a===void 0&&b.usingExports?a=m[k]:m[k]=a}else k&&(a=m[k]=h);if(F[b.waitId])delete F[b.waitId],b.isDone=!0,f.waitCount-=1,f.waitCount===0&&(I=[]);if(c)return a=(k?g(k).url:"")||c.fileName||c.sourceURL,c=R("defineerror",'Error evaluating module "'+k+'" at location "'+a+'":\n'+c+"\nfileName:"+
-a+"\nlineNumber: "+(c.lineNumber||c.line),c),c.moduleName=k,d.onError(c);if(k&&(c=t[k])){for(h=0;h<c.length;h++)c[h].onDep(k,a);delete t[k]}}function z(b,a,c,d){var b=g(b,d),k=b.name,e=b.fullName,j={},l={waitId:k||ja+Q++,depCount:0,depMax:0,prefix:b.prefix,name:k,fullName:e,deps:{},depArray:a,callback:c,onDep:function(b,a){b in l.deps||(l.deps[b]=a,l.depCount+=1,l.depCount===l.depMax&&w(l))}},i,r;if(e){if(e in m||s[e]===!0||e==="jquery"&&p.jQuery&&p.jQuery!==c().fn.jquery)return;y[e]=!0;s[e]=!0;e===
-"jquery"&&c&&T(c())}for(c=0;c<a.length;c++)if(i=a[c])i=g(i,k?b:d),r=i.fullName,a[c]=r,r==="require"?l.deps[r]=q(b):r==="exports"?(l.deps[r]=m[e]={},l.usingExports=!0):r==="module"?(l.cjsModule=i=l.deps[r]={id:k,uri:k?f.nameToUrl(k,null,d):void 0,exports:m[e]},i.setExports=x(i)):r in m&&!(r in F)?l.deps[r]=m[r]:j[r]||(l.depMax+=1,v(i),(t[r]||(t[r]=[])).push(l),j[r]=!0);l.depCount===l.depMax?w(l):(F[l.waitId]=l,I.push(l),f.waitCount+=1)}function u(b){z.apply(null,b);s[b[0]]=!0}function C(b,a){if(!b.isDone){var c=
-b.fullName,d=b.depArray,f,e;if(c){if(a[c])return m[c];a[c]=!0}for(e=0;e<d.length;e++)if((f=d[e])&&!b.deps[f]&&F[f])b.onDep(f,C(F[f],a));return c?m[c]:void 0}}function A(){var b=p.waitSeconds*1E3,a=b&&f.startTime+b<(new Date).getTime(),b="",c=!1,g=!1,k;if(!(f.pausedCount>0)){if(p.priorityWait)if(e())G();else return;for(k in s)if(!(k in J)&&(c=!0,!s[k]))if(a)b+=k+" ";else{g=!0;break}if(c||f.waitCount){if(a&&b)return k=R("timeout","Load timeout for modules: "+b),k.requireType="timeout",k.requireModules=
-b,d.onError(k);if(g||f.scriptCount){if((B||ca)&&!X)X=setTimeout(function(){X=0;A()},50)}else{if(f.waitCount){for(H=0;b=I[H];H++)C(b,{});Y<5&&(Y+=1,A())}Y=0;d.checkReadyState()}}}}function D(b,a){var c=a.name,e=a.fullName,g;if(!(e in m||e in s))K[b]||(K[b]=m[b]),s[e]||(s[e]=!1),g=function(g){if(d.onPluginLoad)d.onPluginLoad(f,b,c,g);w({prefix:a.prefix,name:a.name,fullName:a.fullName,callback:function(){return g}});s[e]=!0},g.fromText=function(b,a){var c=N;f.loaded[b]=!1;f.scriptCount+=1;c&&(N=!1);
-d.exec(a);c&&(N=!0);f.completeLoad(b)},K[b].load(c,q(a.parentMap,!0),g,p)}function L(b){b.prefix&&b.name&&b.name.indexOf("__$p")===0&&m[b.prefix]&&(b=g(b.originalName,b.parentMap));var a=b.prefix,c=b.fullName,e=f.urlFetched;!y[c]&&!s[c]&&(y[c]=!0,a?m[a]?D(a,b):(O[a]||(O[a]=[],(t[a]||(t[a]=[])).push({onDep:function(b){if(b===a){for(var c,d=O[a],b=0;b<d.length;b++)c=d[b],D(a,g(c.originalName,c.parentMap));delete O[a]}}})),O[a].push(b)):e[b.url]||(d.load(f,c,b.url),e[b.url]=!0))}var f,G,p={waitSeconds:7,
-baseUrl:i.baseUrl||"./",paths:{},pkgs:{},catchError:{}},P=[],y={require:!0,exports:!0,module:!0},E={},m={},s={},F={},I=[],Q=0,t={},K={},O={},Z=0,S={};T=function(b){if(!f.jQuery&&(b=b||(typeof jQuery!=="undefined"?jQuery:null))&&!(p.jQuery&&b.fn.jquery!==p.jQuery)&&("holdReady"in b||"readyWait"in b))if(f.jQuery=b,u(["jquery",[],function(){return jQuery}]),f.scriptCount)W(b,!0),f.jQueryIncremented=!0};G=function(){var b,a,c;Z+=1;if(f.scriptCount<=0)f.scriptCount=0;for(;P.length;)if(b=P.shift(),b[0]===
-null)return d.onError(R("mismatch","Mismatched anonymous define() module: "+b[b.length-1]));else u(b);if(!p.priorityWait||e())for(;f.paused.length;){c=f.paused;f.pausedCount+=c.length;f.paused=[];for(a=0;b=c[a];a++)L(b);f.startTime=(new Date).getTime();f.pausedCount-=c.length}Z===1&&A();Z-=1};f={contextName:a,config:p,defQueue:P,waiting:F,waitCount:0,specified:y,loaded:s,urlMap:E,scriptCount:0,urlFetched:{},defined:m,paused:[],pausedCount:0,plugins:K,managerCallbacks:t,makeModuleMap:g,normalize:c,
-configure:function(b){var a,c,e;b.baseUrl&&b.baseUrl.charAt(b.baseUrl.length-1)!=="/"&&(b.baseUrl+="/");a=p.paths;e=p.pkgs;V(p,b,!0);if(b.paths){for(c in b.paths)c in J||(a[c]=b.paths[c]);p.paths=a}if((a=b.packagePaths)||b.packages){if(a)for(c in a)c in J||aa(e,a[c],c);b.packages&&aa(e,b.packages);p.pkgs=e}if(b.priority)c=f.requireWait,f.requireWait=!1,f.takeGlobalQueue(),G(),f.require(b.priority),G(),f.requireWait=c,p.priorityWait=b.priority;if(b.deps||b.callback)f.require(b.deps||[],b.callback);
-b.ready&&d.ready(b.ready)},requireDefined:function(b,a){return g(b,a).fullName in m},requireSpecified:function(b,a){return g(b,a).fullName in y},require:function(b,c,e){if(typeof b==="string"){if(d.get)return d.get(f,b,c);c=g(b,c);b=c.fullName;return!(b in m)?d.onError(R("notloaded","Module name '"+c.fullName+"' has not been loaded yet for context: "+a)):m[b]}z(null,b,c,e);if(!f.requireWait)for(;!f.scriptCount&&f.paused.length;)f.takeGlobalQueue(),G();return f.require},takeGlobalQueue:function(){U.length&&
-(ka.apply(f.defQueue,[f.defQueue.length-1,0].concat(U)),U=[])},completeLoad:function(b){var a;for(f.takeGlobalQueue();P.length;)if(a=P.shift(),a[0]===null){a[0]=b;break}else if(a[0]===b)break;else u(a),a=null;a?u(a):u([b,[],b==="jquery"&&typeof jQuery!=="undefined"?function(){return jQuery}:null]);s[b]=!0;T();d.isAsync&&(f.scriptCount-=1);G();d.isAsync||(f.scriptCount-=1)},toUrl:function(b,a){var c=b.lastIndexOf("."),d=null;c!==-1&&(d=b.substring(c,b.length),b=b.substring(0,c));return f.nameToUrl(b,
-d,a)},nameToUrl:function(b,a,e){var g,j,i,m,l=f.config,b=c(b,e&&e.fullName);if(d.jsExtRegExp.test(b))a=b+(a?a:"");else{g=l.paths;j=l.pkgs;e=b.split("/");for(m=e.length;m>0;m--)if(i=e.slice(0,m).join("/"),g[i]){e.splice(0,m,g[i]);break}else if(i=j[i]){b=b===i.name?i.location+"/"+i.main:i.location;e.splice(0,m,b);break}a=e.join("/")+(a||".js");a=(a.charAt(0)==="/"||a.match(/^\w+:/)?"":l.baseUrl)+a}return l.urlArgs?a+((a.indexOf("?")===-1?"?":"&")+l.urlArgs):a}};f.jQueryCheck=T;f.resume=G;return f}function la(){var a,
-c,d;if(C&&C.readyState==="interactive")return C;a=document.getElementsByTagName("script");for(c=a.length-1;c>-1&&(d=a[c]);c--)if(d.readyState==="interactive")return C=d;return null}var ma=/(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg,na=/require\(\s*["']([^'"\s]+)["']\s*\)/g,fa=/^\.\//,ba=/\.js$/,$=Object.prototype.toString,q=Array.prototype,ia=q.slice,ka=q.splice,B=!!(typeof window!=="undefined"&&navigator&&document),ca=!B&&typeof importScripts!=="undefined",oa=B&&navigator.platform==="PLAYSTATION 3"?/^complete$/:
-/^(complete|loaded)$/,da=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",ja="_r@@",J={},z={},U=[],C=null,Y=0,N=!1,d,q={},I,i,u,L,v,A,D,H,Q,ea,w,T,X;if(typeof define==="undefined"){if(typeof requirejs!=="undefined")if(M(requirejs))return;else q=requirejs,requirejs=void 0;typeof require!=="undefined"&&!M(require)&&(q=require,require=void 0);d=requirejs=function(a,c,d){var e="_",i;!E(a)&&typeof a!=="string"&&(i=a,E(c)?(a=c,c=d):a=[]);if(i&&i.context)e=i.context;d=z[e]||(z[e]=ga(e));i&&
-d.configure(i);return d.require(a,c)};d.config=function(a){return d(a)};typeof require==="undefined"&&(require=d);d.toUrl=function(a){return z._.toUrl(a)};d.version="0.26.0";d.isArray=E;d.isFunction=M;d.mixin=V;d.jsExtRegExp=/^\/|:|\?|\.js$/;i=d.s={contexts:z,skipAsync:{},isPageLoaded:!B,readyCalls:[]};if(d.isAsync=d.isBrowser=B)if(u=i.head=document.getElementsByTagName("head")[0],L=document.getElementsByTagName("base")[0])u=i.head=L.parentNode;d.onError=function(a){throw a;};d.load=function(a,c,
-g){var e=a.loaded;e[c]||(e[c]=!1);a.scriptCount+=1;d.attach(g,a,c);if(a.jQuery&&!a.jQueryIncremented)W(a.jQuery,!0),a.jQueryIncremented=!0};define=d.def=function(a,c,g){var e,i;typeof a!=="string"&&(g=c,c=a,a=null);d.isArray(c)||(g=c,c=[]);!a&&!c.length&&d.isFunction(g)&&g.length&&(g.toString().replace(ma,"").replace(na,function(a,d){c.push(d)}),c=(g.length===1?["require"]:["require","exports","module"]).concat(c));if(N&&(e=I||la()))a||(a=e.getAttribute("data-requiremodule")),i=z[e.getAttribute("data-requirecontext")];
-(i?i.defQueue:U).push([a,c,g])};define.amd={multiversion:!0,plugins:!0,jQuery:!0};d.exec=function(a){return eval(a)};d.execCb=function(a,c,d,e){return c.apply(e,d)};d.onScriptLoad=function(a){var c=a.currentTarget||a.srcElement,g;if(a.type==="load"||oa.test(c.readyState))C=null,a=c.getAttribute("data-requirecontext"),g=c.getAttribute("data-requiremodule"),z[a].completeLoad(g),c.detachEvent&&!da?c.detachEvent("onreadystatechange",d.onScriptLoad):c.removeEventListener("load",d.onScriptLoad,!1)};d.attach=
-function(a,c,g,e,q){var j;if(B)return e=e||d.onScriptLoad,j=c&&c.config&&c.config.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),j.type=q||"text/javascript",j.charset="utf-8",j.async=!i.skipAsync[a],c&&j.setAttribute("data-requirecontext",c.contextName),j.setAttribute("data-requiremodule",g),j.attachEvent&&!da?(N=!0,j.attachEvent("onreadystatechange",e)):j.addEventListener("load",e,!1),j.src=a,I=j,L?u.insertBefore(j,L):u.appendChild(j),
-I=null,j;else if(ca)e=c.loaded,e[g]=!1,importScripts(a),c.completeLoad(g);return null};if(B){v=document.getElementsByTagName("script");for(H=v.length-1;H>-1&&(A=v[H]);H--){if(!u)u=A.parentNode;if(D=A.getAttribute("data-main")){if(!q.baseUrl)v=D.split("/"),A=v.pop(),v=v.length?v.join("/")+"/":"./",q.baseUrl=v,D=A.replace(ba,"");q.deps=q.deps?q.deps.concat(D):[D];break}}}i.baseUrl=q.baseUrl;d.pageLoaded=function(){if(!i.isPageLoaded){i.isPageLoaded=!0;Q&&clearInterval(Q);if(ea)document.readyState="complete";
-d.callReady()}};d.checkReadyState=function(){var a=i.contexts,c;for(c in a)if(!(c in J)&&a[c].waitCount)return;i.isDone=!0;d.callReady()};d.callReady=function(){var a=i.readyCalls,c,d,e;if(i.isPageLoaded&&i.isDone){if(a.length){i.readyCalls=[];for(c=0;d=a[c];c++)d()}a=i.contexts;for(e in a)if(!(e in J)&&(c=a[e],c.jQueryIncremented))W(c.jQuery,!1),c.jQueryIncremented=!1}};d.ready=function(a){i.isPageLoaded&&i.isDone?a():i.readyCalls.push(a);return d};if(B){if(document.addEventListener){if(document.addEventListener("DOMContentLoaded",
-d.pageLoaded,!1),window.addEventListener("load",d.pageLoaded,!1),!document.readyState)ea=!0,document.readyState="loading"}else window.attachEvent&&(window.attachEvent("onload",d.pageLoaded),self===self.top&&(Q=setInterval(function(){try{document.body&&(document.documentElement.doScroll("left"),d.pageLoaded())}catch(a){}},30)));document.readyState==="complete"&&d.pageLoaded()}d(q);if(d.isAsync&&typeof setTimeout!=="undefined")w=i.contexts[q.context||"_"],w.requireWait=!0,setTimeout(function(){w.requireWait=
-!1;w.takeGlobalQueue();w.jQueryCheck();w.scriptCount||w.resume();d.checkReadyState()},0)}})();
+(function(){function J(a){return M.call(a)==="[object Function]"}function E(a){return M.call(a)==="[object Array]"}function Z(a,c,h){for(var k in c)if(!(k in K)&&(!(k in a)||h))a[k]=c[k];return d}function N(a,c,d){a=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+a);if(d)a.originalError=d;return a}function $(a,c,d){var k,j,q;for(k=0;q=c[k];k++){q=typeof q==="string"?{name:q}:q;j=q.location;if(d&&(!j||j.indexOf("/")!==0&&j.indexOf(":")===-1))j=d+"/"+(j||q.name);a[q.name]={name:q.name,location:j||
+q.name,main:(q.main||"main").replace(ea,"").replace(aa,"")}}}function V(a,c){a.holdReady?a.holdReady(c):c?a.readyWait+=1:a.ready(!0)}function fa(a){function c(b,l){var f,a;if(b&&b.charAt(0)===".")if(l){p.pkgs[l]?l=[l]:(l=l.split("/"),l=l.slice(0,l.length-1));f=b=l.concat(b.split("/"));var c;for(a=0;c=f[a];a++)if(c===".")f.splice(a,1),a-=1;else if(c==="..")if(a===1&&(f[2]===".."||f[0]===".."))break;else a>0&&(f.splice(a-1,2),a-=2);a=p.pkgs[f=b[0]];b=b.join("/");a&&b===f+"/"+a.main&&(b=f)}else b.indexOf("./")===
+0&&(b=b.substring(2));return b}function h(b,l){var f=b?b.indexOf("!"):-1,a=null,d=l?l.name:null,i=b,e,h;f!==-1&&(a=b.substring(0,f),b=b.substring(f+1,b.length));a&&(a=c(a,d));b&&(a?e=(f=m[a])&&f.normalize?f.normalize(b,function(b){return c(b,d)}):c(b,d):(e=c(b,d),h=E[e],h||(h=g.nameToUrl(e,null,l),E[e]=h)));return{prefix:a,name:e,parentMap:l,url:h,originalName:i,fullName:a?a+"!"+(e||""):e}}function k(){var b=!0,l=p.priorityWait,f,a;if(l){for(a=0;f=l[a];a++)if(!s[f]){b=!1;break}b&&delete p.priorityWait}return b}
+function j(b,l,f){return function(){var a=ga.call(arguments,0),c;if(f&&J(c=a[a.length-1]))c.__requireJsBuild=!0;a.push(l);return b.apply(null,a)}}function q(b,l){var a=j(g.require,b,l);Z(a,{nameToUrl:j(g.nameToUrl,b),toUrl:j(g.toUrl,b),defined:j(g.requireDefined,b),specified:j(g.requireSpecified,b),isBrowser:d.isBrowser});return a}function o(b){var l,a,c,C=b.callback,i=b.map,e=i.fullName,ba=b.deps;c=b.listeners;if(C&&J(C)){if(p.catchError.define)try{a=d.execCb(e,b.callback,ba,m[e])}catch(k){l=k}else a=
+d.execCb(e,b.callback,ba,m[e]);if(e)(C=b.cjsModule)&&C.exports!==void 0&&C.exports!==m[e]?a=m[e]=b.cjsModule.exports:a===void 0&&b.usingExports?a=m[e]:(m[e]=a,F[e]&&(Q[e]=!0))}else e&&(a=m[e]=C,F[e]&&(Q[e]=!0));if(D[b.id])delete D[b.id],b.isDone=!0,g.waitCount-=1,g.waitCount===0&&(I=[]);delete R[e];if(d.onResourceLoad&&!b.placeholder)d.onResourceLoad(g,i,b.depArray);if(l)return a=(e?h(e).url:"")||l.fileName||l.sourceURL,c=l.moduleTree,l=N("defineerror",'Error evaluating module "'+e+'" at location "'+
+a+'":\n'+l+"\nfileName:"+a+"\nlineNumber: "+(l.lineNumber||l.line),l),l.moduleName=e,l.moduleTree=c,d.onError(l);for(l=0;C=c[l];l++)C(a)}function r(b,a){return function(f){b.depDone[a]||(b.depDone[a]=!0,b.deps[a]=f,b.depCount-=1,b.depCount||o(b))}}function u(b,a){var f=a.map,c=f.fullName,h=f.name,i=L[b]||(L[b]=m[b]),e;if(!a.loading)a.loading=!0,e=function(b){a.callback=function(){return b};o(a);s[a.id]=!0;w()},e.fromText=function(b,a){var l=O;s[b]=!1;g.scriptCount+=1;g.fake[b]=!0;l&&(O=!1);d.exec(a);
+l&&(O=!0);g.completeLoad(b)},c in m?e(m[c]):i.load(h,q(f.parentMap,!0),e,p)}function v(b){D[b.id]||(D[b.id]=b,I.push(b),g.waitCount+=1)}function B(b){this.listeners.push(b)}function t(b,a){var f=b.fullName,c=b.prefix,d=c?L[c]||(L[c]=m[c]):null,i,e;f&&(i=R[f]);if(!i&&(e=!0,i={id:(c&&!d?M++ +"__p@:":"")+(f||"__r@"+M++),map:b,depCount:0,depDone:[],depCallbacks:[],deps:[],listeners:[],add:B},y[i.id]=!0,f&&(!c||L[c])))R[f]=i;c&&!d?(f=t(h(c),!0),f.add(function(){var a=h(b.originalName,b.parentMap),a=t(a,
+!0);i.placeholder=!0;a.add(function(b){i.callback=function(){return b};o(i)})})):e&&a&&(s[i.id]=!1,g.paused.push(i),v(i));return i}function x(b,a,f,c){var b=h(b,c),d=b.name,i=b.fullName,e=t(b),k=e.id,j=e.deps,n;if(i){if(i in m||s[k]===!0||i==="jquery"&&p.jQuery&&p.jQuery!==f().fn.jquery)return;y[k]=!0;s[k]=!0;i==="jquery"&&f&&S(f())}e.depArray=a;e.callback=f;for(f=0;f<a.length;f++)if(k=a[f])k=h(k,d?b:c),n=k.fullName,a[f]=n,n==="require"?j[f]=q(b):n==="exports"?(j[f]=m[i]={},e.usingExports=!0):n===
+"module"?e.cjsModule=j[f]={id:d,uri:d?g.nameToUrl(d,null,c):void 0,exports:m[i]}:n in m&&!(n in D)&&(!(i in F)||i in F&&Q[n])?j[f]=m[n]:(i in F&&(F[n]=!0,delete m[n],T[k.url]=!1),e.depCount+=1,e.depCallbacks[f]=r(e,f),t(k,!0).add(e.depCallbacks[f]));e.depCount?v(e):o(e)}function n(b){x.apply(null,b)}function z(b,a){if(!b.isDone){var c=b.map.fullName,d=b.depArray,g,i,e,k;if(c){if(a[c])return m[c];a[c]=!0}if(d)for(g=0;g<d.length;g++)if(i=d[g])if((e=h(i).prefix)&&(k=D[e])&&z(k,a),(e=D[i])&&!e.isDone&&
+s[i])i=z(e,a),b.depCallbacks[g](i);return c?m[c]:void 0}}function A(){var b=p.waitSeconds*1E3,a=b&&g.startTime+b<(new Date).getTime(),b="",c=!1,h=!1,j;if(!(g.pausedCount>0)){if(p.priorityWait)if(k())w();else return;for(j in s)if(!(j in K)&&(c=!0,!s[j]))if(a)b+=j+" ";else{h=!0;break}if(c||g.waitCount){if(a&&b)return j=N("timeout","Load timeout for modules: "+b),j.requireType="timeout",j.requireModules=b,d.onError(j);if(h||g.scriptCount){if((G||ca)&&!W)W=setTimeout(function(){W=0;A()},50)}else{if(g.waitCount){for(H=
+0;b=I[H];H++)z(b,{});g.paused.length&&w();X<5&&(X+=1,A())}X=0;d.checkReadyState()}}}}var g,w,p={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},catchError:{}},P=[],y={require:!0,exports:!0,module:!0},E={},m={},s={},D={},I=[],T={},M=0,R={},L={},F={},Q={},Y=0;S=function(b){if(!g.jQuery&&(b=b||(typeof jQuery!=="undefined"?jQuery:null))&&!(p.jQuery&&b.fn.jquery!==p.jQuery)&&("holdReady"in b||"readyWait"in b))if(g.jQuery=b,n(["jquery",[],function(){return jQuery}]),g.scriptCount)V(b,!0),g.jQueryIncremented=
+!0};w=function(){var b,a,c,h,j,i;Y+=1;if(g.scriptCount<=0)g.scriptCount=0;for(;P.length;)if(b=P.shift(),b[0]===null)return d.onError(N("mismatch","Mismatched anonymous define() module: "+b[b.length-1]));else n(b);if(!p.priorityWait||k())for(;g.paused.length;){j=g.paused;g.pausedCount+=j.length;g.paused=[];for(h=0;b=j[h];h++)a=b.map,c=a.url,i=a.fullName,a.prefix?u(a.prefix,b):!T[c]&&!s[i]&&(d.load(g,i,c),c.indexOf("empty:")!==0&&(T[c]=!0));g.startTime=(new Date).getTime();g.pausedCount-=j.length}Y===
+1&&A();Y-=1};g={contextName:a,config:p,defQueue:P,waiting:D,waitCount:0,specified:y,loaded:s,urlMap:E,urlFetched:T,scriptCount:0,defined:m,paused:[],pausedCount:0,plugins:L,needFullExec:F,fake:{},fullExec:Q,managerCallbacks:R,makeModuleMap:h,normalize:c,configure:function(b){var a,c,d;b.baseUrl&&b.baseUrl.charAt(b.baseUrl.length-1)!=="/"&&(b.baseUrl+="/");a=p.paths;d=p.pkgs;Z(p,b,!0);if(b.paths){for(c in b.paths)c in K||(a[c]=b.paths[c]);p.paths=a}if((a=b.packagePaths)||b.packages){if(a)for(c in a)c in
+K||$(d,a[c],c);b.packages&&$(d,b.packages);p.pkgs=d}if(b.priority)c=g.requireWait,g.requireWait=!1,g.takeGlobalQueue(),w(),g.require(b.priority),w(),g.requireWait=c,p.priorityWait=b.priority;if(b.deps||b.callback)g.require(b.deps||[],b.callback)},requireDefined:function(b,a){return h(b,a).fullName in m},requireSpecified:function(b,a){return h(b,a).fullName in y},require:function(b,c,f){if(typeof b==="string"){if(J(c))return d.onError(N("requireargs","Invalid require call"));if(d.get)return d.get(g,
+b,c);c=h(b,c);b=c.fullName;return!(b in m)?d.onError(N("notloaded","Module name '"+c.fullName+"' has not been loaded yet for context: "+a)):m[b]}(b&&b.length||c)&&x(null,b,c,f);if(!g.requireWait)for(;!g.scriptCount&&g.paused.length;)g.takeGlobalQueue(),w();return g.require},takeGlobalQueue:function(){U.length&&(ha.apply(g.defQueue,[g.defQueue.length-1,0].concat(U)),U=[])},completeLoad:function(b){var a;for(g.takeGlobalQueue();P.length;)if(a=P.shift(),a[0]===null){a[0]=b;break}else if(a[0]===b)break;
+else n(a),a=null;a?n(a):n([b,[],b==="jquery"&&typeof jQuery!=="undefined"?function(){return jQuery}:null]);S();d.isAsync&&(g.scriptCount-=1);w();d.isAsync||(g.scriptCount-=1)},toUrl:function(a,c){var d=a.lastIndexOf("."),h=null;d!==-1&&(h=a.substring(d,a.length),a=a.substring(0,d));return g.nameToUrl(a,h,c)},nameToUrl:function(a,h,f){var j,k,i,e,m=g.config,a=c(a,f&&f.fullName);if(d.jsExtRegExp.test(a))h=a+(h?h:"");else{j=m.paths;k=m.pkgs;f=a.split("/");for(e=f.length;e>0;e--)if(i=f.slice(0,e).join("/"),
+j[i]){f.splice(0,e,j[i]);break}else if(i=k[i]){a=a===i.name?i.location+"/"+i.main:i.location;f.splice(0,e,a);break}h=f.join("/")+(h||".js");h=(h.charAt(0)==="/"||h.match(/^\w+:/)?"":m.baseUrl)+h}return m.urlArgs?h+((h.indexOf("?")===-1?"?":"&")+m.urlArgs):h}};g.jQueryCheck=S;g.resume=w;return g}function ia(){var a,c,d;if(n&&n.readyState==="interactive")return n;a=document.getElementsByTagName("script");for(c=a.length-1;c>-1&&(d=a[c]);c--)if(d.readyState==="interactive")return n=d;return null}var ja=
+/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ka=/require\(\s*["']([^'"\s]+)["']\s*\)/g,ea=/^\.\//,aa=/\.js$/,M=Object.prototype.toString,r=Array.prototype,ga=r.slice,ha=r.splice,G=!!(typeof window!=="undefined"&&navigator&&document),ca=!G&&typeof importScripts!=="undefined",la=G&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,da=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",K={},t={},U=[],n=null,X=0,O=!1,d,r={},I,v,x,y,u,z,A,H,B,S,W;if(typeof define==="undefined"){if(typeof requirejs!==
+"undefined")if(J(requirejs))return;else r=requirejs,requirejs=void 0;typeof require!=="undefined"&&!J(require)&&(r=require,require=void 0);d=requirejs=function(a,c,d){var k="_",j;!E(a)&&typeof a!=="string"&&(j=a,E(c)?(a=c,c=d):a=[]);if(j&&j.context)k=j.context;d=t[k]||(t[k]=fa(k));j&&d.configure(j);return d.require(a,c)};d.config=function(a){return d(a)};require||(require=d);d.toUrl=function(a){return t._.toUrl(a)};d.version="1.0.2";d.jsExtRegExp=/^\/|:|\?|\.js$/;v=d.s={contexts:t,skipAsync:{}};if(d.isAsync=
+d.isBrowser=G)if(x=v.head=document.getElementsByTagName("head")[0],y=document.getElementsByTagName("base")[0])x=v.head=y.parentNode;d.onError=function(a){throw a;};d.load=function(a,c,h){d.resourcesReady(!1);a.scriptCount+=1;d.attach(h,a,c);if(a.jQuery&&!a.jQueryIncremented)V(a.jQuery,!0),a.jQueryIncremented=!0};define=function(a,c,d){var k,j;typeof a!=="string"&&(d=c,c=a,a=null);E(c)||(d=c,c=[]);!c.length&&J(d)&&d.length&&(d.toString().replace(ja,"").replace(ka,function(a,d){c.push(d)}),c=(d.length===
+1?["require"]:["require","exports","module"]).concat(c));if(O&&(k=I||ia()))a||(a=k.getAttribute("data-requiremodule")),j=t[k.getAttribute("data-requirecontext")];(j?j.defQueue:U).push([a,c,d])};define.amd={multiversion:!0,plugins:!0,jQuery:!0};d.exec=function(a){return eval(a)};d.execCb=function(a,c,d,k){return c.apply(k,d)};d.addScriptToDom=function(a){I=a;y?x.insertBefore(a,y):x.appendChild(a);I=null};d.onScriptLoad=function(a){var c=a.currentTarget||a.srcElement,h;if(a.type==="load"||c&&la.test(c.readyState))n=
+null,a=c.getAttribute("data-requirecontext"),h=c.getAttribute("data-requiremodule"),t[a].completeLoad(h),c.detachEvent&&!da?c.detachEvent("onreadystatechange",d.onScriptLoad):c.removeEventListener("load",d.onScriptLoad,!1)};d.attach=function(a,c,h,k,j,n){var o;if(G)return k=k||d.onScriptLoad,o=c&&c.config&&c.config.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),o.type=j||"text/javascript",o.charset="utf-8",o.async=!v.skipAsync[a],c&&o.setAttribute("data-requirecontext",
+c.contextName),o.setAttribute("data-requiremodule",h),o.attachEvent&&!da?(O=!0,n?o.onreadystatechange=function(){if(o.readyState==="loaded")o.onreadystatechange=null,o.attachEvent("onreadystatechange",k),n(o)}:o.attachEvent("onreadystatechange",k)):o.addEventListener("load",k,!1),o.src=a,n||d.addScriptToDom(o),o;else ca&&(importScripts(a),c.completeLoad(h));return null};if(G){u=document.getElementsByTagName("script");for(H=u.length-1;H>-1&&(z=u[H]);H--){if(!x)x=z.parentNode;if(A=z.getAttribute("data-main")){if(!r.baseUrl)u=
+A.split("/"),z=u.pop(),u=u.length?u.join("/")+"/":"./",r.baseUrl=u,A=z.replace(aa,"");r.deps=r.deps?r.deps.concat(A):[A];break}}}d.checkReadyState=function(){var a=v.contexts,c;for(c in a)if(!(c in K)&&a[c].waitCount)return;d.resourcesReady(!0)};d.resourcesReady=function(a){var c,h;d.resourcesDone=a;if(d.resourcesDone)for(h in a=v.contexts,a)if(!(h in K)&&(c=a[h],c.jQueryIncremented))V(c.jQuery,!1),c.jQueryIncremented=!1};d.pageLoaded=function(){if(document.readyState!=="complete")document.readyState=
+"complete"};if(G&&document.addEventListener&&!document.readyState)document.readyState="loading",window.addEventListener("load",d.pageLoaded,!1);d(r);if(d.isAsync&&typeof setTimeout!=="undefined")B=v.contexts[r.context||"_"],B.requireWait=!0,setTimeout(function(){B.requireWait=!1;B.takeGlobalQueue();B.jQueryCheck();B.scriptCount||B.resume();d.checkReadyState()},0)}})();
 

--- a/lib/requirejs/r.js
+++ b/lib/requirejs/r.js
@@ -1,5 +1,5 @@
 /**
- * @license r.js 0.26.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
+ * @license r.js 1.0.2 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
  * Available via the MIT or new BSD license.
  * see: http://github.com/jrburke/requirejs for details
  */
@@ -20,7 +20,7 @@
 
     var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
         nodeDefine, exists, reqMain, loadedOptimizedLib,
-        version = '0.26.0',
+        version = '1.0.2',
         jsSuffixRegExp = /\.js$/,
         commandOption = '',
         //Used by jslib/rhino/args.js
@@ -101,11 +101,11 @@
     }
 
     /** vim: et:ts=4:sw=4:sts=4
- * @license RequireJS 0.26.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
+ * @license RequireJS 1.0.2 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
  * Available via the MIT or new BSD license.
  * see: http://github.com/jrburke/requirejs for details
  */
-/*jslint strict: false, plusplus: false */
+/*jslint strict: false, plusplus: false, sub: true */
 /*global window: false, navigator: false, document: false, importScripts: false,
   jQuery: false, clearInterval: false, setInterval: false, self: false,
   setTimeout: false, opera: false */
@@ -113,8 +113,8 @@
 
 (function () {
     //Change this version number for each release.
-    var version = "0.26.0",
-        commentRegExp = /(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg,
+    var version = "1.0.2",
+        commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
         cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
         currDirRegExp = /^\.\//,
         jsSuffixRegExp = /\.js$/,
@@ -133,17 +133,14 @@
         defContextName = "_",
         //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
         isOpera = typeof opera !== "undefined" && opera.toString() === "[object Opera]",
-        reqWaitIdPrefix = "_r@@",
         empty = {},
         contexts = {},
         globalDefQueue = [],
         interactiveScript = null,
-        isDone = false,
         checkLoadedDepth = 0,
         useInteractive = false,
         req, cfg = {}, currentlyAddingScript, s, head, baseElement, scripts, script,
-        src, subPath, mainScript, dataMain, i, scrollIntervalId, setReadyState, ctx,
-        jQueryCheck, checkLoadedTimeoutId;
+        src, subPath, mainScript, dataMain, i, ctx, jQueryCheck, checkLoadedTimeoutId;
 
     function isFunction(it) {
         return ostring.call(it) === "[object Function]";
@@ -274,7 +271,7 @@
         var context, resume,
             config = {
                 waitSeconds: 7,
-                baseUrl: s.baseUrl || "./",
+                baseUrl: "./",
                 paths: {},
                 pkgs: {},
                 catchError: {}
@@ -290,12 +287,15 @@
             loaded = {},
             waiting = {},
             waitAry = [],
-            waitIdCounter = 0,
+            urlFetched = {},
+            managerCounter = 0,
             managerCallbacks = {},
             plugins = {},
-            pluginsQueue = {},
-            resumeDepth = 0,
-            normalizedWaiting = {};
+            //Used to indicate which modules in a build scenario
+            //need to be full executed.
+            needFullExec = {},
+            fullExec = {},
+            resumeDepth = 0;
 
         /**
          * Trims the . and .. from an array of path segments.
@@ -370,6 +370,10 @@
                     if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
                         name = pkgName;
                     }
+                } else if (name.indexOf("./") === 0) {
+                    // No baseName, so this is ID is resolved relative
+                    // to baseUrl, pull off the leading dot.
+                    name = name.substring(2);
                 }
             }
             return name;
@@ -406,41 +410,26 @@
             if (name) {
                 if (prefix) {
                     pluginModule = defined[prefix];
-                    if (pluginModule) {
-                        //Plugin is loaded, use its normalize method, otherwise,
-                        //normalize name as usual.
-                        if (pluginModule.normalize) {
-                            normalizedName = pluginModule.normalize(name, function (name) {
-                                return normalize(name, parentName);
-                            });
-                        } else {
-                            normalizedName = normalize(name, parentName);
-                        }
+                    if (pluginModule && pluginModule.normalize) {
+                        //Plugin is loaded, use its normalize method.
+                        normalizedName = pluginModule.normalize(name, function (name) {
+                            return normalize(name, parentName);
+                        });
                     } else {
-                        //Plugin is not loaded yet, so do not normalize
-                        //the name, wait for plugin to load to see if
-                        //it has a normalize method. To avoid possible
-                        //ambiguity with relative names loaded from another
-                        //plugin, use the parent's name as part of this name.
-                        normalizedName = '__$p' + parentName + '@' + (name || '');
+                        normalizedName = normalize(name, parentName);
                     }
                 } else {
+                    //A regular module.
                     normalizedName = normalize(name, parentName);
-                }
-
-                url = urlMap[normalizedName];
-                if (!url) {
-                    //Calculate url for the module, if it has a name.
-                    if (req.toModuleUrl) {
-                        //Special logic required for a particular engine,
-                        //like Node.
-                        url = req.toModuleUrl(context, normalizedName, parentModuleMap);
-                    } else {
+
+                    url = urlMap[normalizedName];
+                    if (!url) {
+                        //Calculate url for the module, if it has a name.
                         url = context.nameToUrl(normalizedName, null, parentModuleMap);
+
+                        //Store the URL mapping for later.
+                        urlMap[normalizedName] = url;
                     }
-
-                    //Store the URL mapping for later.
-                    urlMap[normalizedName] = url;
                 }
             }
 
@@ -475,23 +464,12 @@
             return priorityDone;
         }
 
-        /**
-         * Helper function that creates a setExports function for a "module"
-         * CommonJS dependency. Do this here to avoid creating a closure that
-         * is part of a loop.
-         */
-        function makeSetExports(moduleObj) {
-            return function (exports) {
-                moduleObj.exports = exports;
-            };
-        }
-
         function makeContextModuleFunc(func, relModuleMap, enableBuildCallback) {
             return function () {
                 //A version of a require function that passes a moduleName
                 //value for items that may need to
                 //look up paths relative to the moduleName
-                var args = [].concat(aps.call(arguments, 0)), lastArg;
+                var args = aps.call(arguments, 0), lastArg;
                 if (enableBuildCallback &&
                     isFunction((lastArg = args[args.length - 1]))) {
                     lastArg.__requireJsBuild = true;
@@ -515,136 +493,31 @@
                 toUrl: makeContextModuleFunc(context.toUrl, relModuleMap),
                 defined: makeContextModuleFunc(context.requireDefined, relModuleMap),
                 specified: makeContextModuleFunc(context.requireSpecified, relModuleMap),
-                ready: req.ready,
                 isBrowser: req.isBrowser
             });
-            //Something used by node.
-            if (req.paths) {
-                modRequire.paths = req.paths;
-            }
             return modRequire;
-        }
-
-        /**
-         * Used to update the normalized name for plugin-based dependencies
-         * after a plugin loads, since it can have its own normalization structure.
-         * @param {String} pluginName the normalized plugin module name.
-         */
-        function updateNormalizedNames(pluginName) {
-
-            var oldFullName, oldModuleMap, moduleMap, fullName, callbacks,
-                i, j, k, depArray, existingCallbacks,
-                maps = normalizedWaiting[pluginName];
-
-            if (maps) {
-                for (i = 0; (oldModuleMap = maps[i]); i++) {
-                    oldFullName = oldModuleMap.fullName;
-                    moduleMap = makeModuleMap(oldModuleMap.originalName, oldModuleMap.parentMap);
-                    fullName = moduleMap.fullName;
-                    //Callbacks could be undefined if the same plugin!name was
-                    //required twice in a row, so use empty array in that case.
-                    callbacks = managerCallbacks[oldFullName] || [];
-                    existingCallbacks = managerCallbacks[fullName];
-
-                    if (fullName !== oldFullName) {
-                        //Update the specified object, but only if it is already
-                        //in there. In sync environments, it may not be yet.
-                        if (oldFullName in specified) {
-                            delete specified[oldFullName];
-                            specified[fullName] = true;
-                        }
-
-                        //Update managerCallbacks to use the correct normalized name.
-                        //If there are already callbacks for the normalized name,
-                        //just add to them.
-                        if (existingCallbacks) {
-                            managerCallbacks[fullName] = existingCallbacks.concat(callbacks);
-                        } else {
-                            managerCallbacks[fullName] = callbacks;
-                        }
-                        delete managerCallbacks[oldFullName];
-
-                        //In each manager callback, update the normalized name in the depArray.
-                        for (j = 0; j < callbacks.length; j++) {
-                            depArray = callbacks[j].depArray;
-                            for (k = 0; k < depArray.length; k++) {
-                                if (depArray[k] === oldFullName) {
-                                    depArray[k] = fullName;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            delete normalizedWaiting[pluginName];
         }
 
         /*
          * Queues a dependency for checking after the loader is out of a
          * "paused" state, for example while a script file is being loaded
          * in the browser, where it may have many modules defined in it.
-         *
-         * depName will be fully qualified, no relative . or .. path.
          */
-        function queueDependency(dep) {
-            //Make sure to load any plugin and associate the dependency
-            //with that plugin.
-            var prefix = dep.prefix,
-                fullName = dep.fullName;
-
-            //Do not bother if the depName is already in transit
-            if (specified[fullName] || fullName in defined) {
-                return;
-            }
-
-            if (prefix && !plugins[prefix]) {
-                //Queue up loading of the dependency, track it
-                //via context.plugins. Mark it as a plugin so
-                //that the build system will know to treat it
-                //special.
-                plugins[prefix] = undefined;
-
-                //Remember this dep that needs to have normaliztion done
-                //after the plugin loads.
-                (normalizedWaiting[prefix] || (normalizedWaiting[prefix] = []))
-                    .push(dep);
-
-                //Register an action to do once the plugin loads, to update
-                //all managerCallbacks to use a properly normalized module
-                //name.
-                (managerCallbacks[prefix] ||
-                (managerCallbacks[prefix] = [])).push({
-                    onDep: function (name, value) {
-                        if (name === prefix) {
-                            updateNormalizedNames(prefix);
-                        }
-                    }
-                });
-
-                queueDependency(makeModuleMap(prefix));
-            }
-
-            context.paused.push(dep);
+        function queueDependency(manager) {
+            context.paused.push(manager);
         }
 
         function execManager(manager) {
-            var i, ret, waitingCallbacks, err, errFile,
+            var i, ret, err, errFile, errModuleTree,
                 cb = manager.callback,
-                fullName = manager.fullName,
-                args = [],
-                ary = manager.depArray;
+                map = manager.map,
+                fullName = map.fullName,
+                args = manager.deps,
+                listeners = manager.listeners,
+                cjsModule;
 
             //Call the callback to define the module, if necessary.
             if (cb && isFunction(cb)) {
-                //Pull out the defined dependencies and pass the ordered
-                //values to the callback.
-                if (ary) {
-                    for (i = 0; i < ary.length; i++) {
-                        args.push(manager.deps[ary[i]]);
-                    }
-                }
-
                 if (config.catchError.define) {
                     try {
                         ret = req.execCb(fullName, manager.callback, args, defined[fullName]);
@@ -659,7 +532,11 @@
                     //If setting exports via "module" is in play,
                     //favor that over return value and exports. After that,
                     //favor a non-undefined return value over exports use.
-                    if (manager.cjsModule && manager.cjsModule.exports !== undefined) {
+                    cjsModule = manager.cjsModule;
+                    if (cjsModule &&
+                        cjsModule.exports !== undefined &&
+                        //Make sure it is not already the exports value
+                        cjsModule.exports !== defined[fullName]) {
                         ret = defined[fullName] = manager.cjsModule.exports;
                     } else if (ret === undefined && manager.usingExports) {
                         //exports already set the defined value.
@@ -667,21 +544,32 @@
                     } else {
                         //Use the return value from the function.
                         defined[fullName] = ret;
+                        //If this module needed full execution in a build
+                        //environment, mark that now.
+                        if (needFullExec[fullName]) {
+                            fullExec[fullName] = true;
+                        }
                     }
                 }
             } else if (fullName) {
                 //May just be an object definition for the module. Only
                 //worry about defining if have a module name.
                 ret = defined[fullName] = cb;
+
+                //If this module needed full execution in a build
+                //environment, mark that now.
+                if (needFullExec[fullName]) {
+                    fullExec[fullName] = true;
+                }
             }
 
             //Clean up waiting. Do this before error calls, and before
-            //calling back waitingCallbacks, so that bookkeeping is correct
+            //calling back listeners, so that bookkeeping is correct
             //in the event of an error and error is reported in correct order,
-            //since the waitingCallbacks will likely have errors if the
+            //since the listeners will likely have errors if the
             //onError function does not throw.
-            if (waiting[manager.waitId]) {
-                delete waiting[manager.waitId];
+            if (waiting[manager.id]) {
+                delete waiting[manager.id];
                 manager.isDone = true;
                 context.waitCount -= 1;
                 if (context.waitCount === 0) {
@@ -690,68 +578,241 @@
                 }
             }
 
+            //Do not need to track manager callback now that it is defined.
+            delete managerCallbacks[fullName];
+
+            //Allow instrumentation like the optimizer to know the order
+            //of modules executed and their dependencies.
+            if (req.onResourceLoad && !manager.placeholder) {
+                req.onResourceLoad(context, map, manager.depArray);
+            }
+
             if (err) {
                 errFile = (fullName ? makeModuleMap(fullName).url : '') ||
                            err.fileName || err.sourceURL;
+                errModuleTree = err.moduleTree;
                 err = makeError('defineerror', 'Error evaluating ' +
                                 'module "' + fullName + '" at location "' +
                                 errFile + '":\n' +
                                 err + '\nfileName:' + errFile +
                                 '\nlineNumber: ' + (err.lineNumber || err.line), err);
                 err.moduleName = fullName;
+                err.moduleTree = errModuleTree;
                 return req.onError(err);
             }
 
+            //Let listeners know of this manager's value.
+            for (i = 0; (cb = listeners[i]); i++) {
+                cb(ret);
+            }
+
+            return undefined;
+        }
+
+        /**
+         * Helper that creates a callack function that is called when a dependency
+         * is ready, and sets the i-th dependency for the manager as the
+         * value passed to the callback generated by this function.
+         */
+        function makeArgCallback(manager, i) {
+            return function (value) {
+                //Only do the work if it has not been done
+                //already for a dependency. Cycle breaking
+                //logic in forceExec could mean this function
+                //is called more than once for a given dependency.
+                if (!manager.depDone[i]) {
+                    manager.depDone[i] = true;
+                    manager.deps[i] = value;
+                    manager.depCount -= 1;
+                    if (!manager.depCount) {
+                        //All done, execute!
+                        execManager(manager);
+                    }
+                }
+            };
+        }
+
+        function callPlugin(pluginName, depManager) {
+            var map = depManager.map,
+                fullName = map.fullName,
+                name = map.name,
+                plugin = plugins[pluginName] ||
+                        (plugins[pluginName] = defined[pluginName]),
+                load;
+
+            //No need to continue if the manager is already
+            //in the process of loading.
+            if (depManager.loading) {
+                return;
+            }
+            depManager.loading = true;
+
+            load = function (ret) {
+                depManager.callback = function () {
+                    return ret;
+                };
+                execManager(depManager);
+
+                loaded[depManager.id] = true;
+
+                //The loading of this plugin
+                //might have placed other things
+                //in the paused queue. In particular,
+                //a loader plugin that depends on
+                //a different plugin loaded resource.
+                resume();
+            };
+
+            //Allow plugins to load other code without having to know the
+            //context or how to "complete" the load.
+            load.fromText = function (moduleName, text) {
+                /*jslint evil: true */
+                var hasInteractive = useInteractive;
+
+                //Indicate a the module is in process of loading.
+                loaded[moduleName] = false;
+                context.scriptCount += 1;
+
+                //Indicate this is not a "real" module, so do not track it
+                //for builds, it does not map to a real file.
+                context.fake[moduleName] = true;
+
+                //Turn off interactive script matching for IE for any define
+                //calls in the text, then turn it back on at the end.
+                if (hasInteractive) {
+                    useInteractive = false;
+                }
+
+                req.exec(text);
+
+                if (hasInteractive) {
+                    useInteractive = true;
+                }
+
+                //Support anonymous modules.
+                context.completeLoad(moduleName);
+            };
+
+            //No need to continue if the plugin value has already been
+            //defined by a build.
+            if (fullName in defined) {
+                load(defined[fullName]);
+            } else {
+                //Use parentName here since the plugin's name is not reliable,
+                //could be some weird string with no path that actually wants to
+                //reference the parentName's path.
+                plugin.load(name, makeRequire(map.parentMap, true), load, config);
+            }
+        }
+
+        /**
+         * Adds the manager to the waiting queue. Only fully
+         * resolved items should be in the waiting queue.
+         */
+        function addWait(manager) {
+            if (!waiting[manager.id]) {
+                waiting[manager.id] = manager;
+                waitAry.push(manager);
+                context.waitCount += 1;
+            }
+        }
+
+        /**
+         * Function added to every manager object. Created out here
+         * to avoid new function creation for each manager instance.
+         */
+        function managerAdd(cb) {
+            this.listeners.push(cb);
+        }
+
+        function getManager(map, shouldQueue) {
+            var fullName = map.fullName,
+                prefix = map.prefix,
+                plugin = prefix ? plugins[prefix] ||
+                                (plugins[prefix] = defined[prefix]) : null,
+                manager, created, pluginManager;
+
             if (fullName) {
-                //If anything was waiting for this module to be defined,
-                //notify them now.
-                waitingCallbacks = managerCallbacks[fullName];
-                if (waitingCallbacks) {
-                    for (i = 0; i < waitingCallbacks.length; i++) {
-                        waitingCallbacks[i].onDep(fullName, ret);
-                    }
-                    delete managerCallbacks[fullName];
-                }
-            }
-
-            return undefined;
+                manager = managerCallbacks[fullName];
+            }
+
+            if (!manager) {
+                created = true;
+                manager = {
+                    //ID is just the full name, but if it is a plugin resource
+                    //for a plugin that has not been loaded,
+                    //then add an ID counter to it.
+                    id: (prefix && !plugin ?
+                        (managerCounter++) + '__p@:' : '') +
+                        (fullName || '__r@' + (managerCounter++)),
+                    map: map,
+                    depCount: 0,
+                    depDone: [],
+                    depCallbacks: [],
+                    deps: [],
+                    listeners: [],
+                    add: managerAdd
+                };
+
+                specified[manager.id] = true;
+
+                //Only track the manager/reuse it if this is a non-plugin
+                //resource. Also only track plugin resources once
+                //the plugin has been loaded, and so the fullName is the
+                //true normalized value.
+                if (fullName && (!prefix || plugins[prefix])) {
+                    managerCallbacks[fullName] = manager;
+                }
+            }
+
+            //If there is a plugin needed, but it is not loaded,
+            //first load the plugin, then continue on.
+            if (prefix && !plugin) {
+                pluginManager = getManager(makeModuleMap(prefix), true);
+                pluginManager.add(function (plugin) {
+                    //Create a new manager for the normalized
+                    //resource ID and have it call this manager when
+                    //done.
+                    var newMap = makeModuleMap(map.originalName, map.parentMap),
+                        normalizedManager = getManager(newMap, true);
+
+                    //Indicate this manager is a placeholder for the real,
+                    //normalized thing. Important for when trying to map
+                    //modules and dependencies, for instance, in a build.
+                    manager.placeholder = true;
+
+                    normalizedManager.add(function (resource) {
+                        manager.callback = function () {
+                            return resource;
+                        };
+                        execManager(manager);
+                    });
+                });
+            } else if (created && shouldQueue) {
+                //Indicate the resource is not loaded yet if it is to be
+                //queued.
+                loaded[manager.id] = false;
+                queueDependency(manager);
+                addWait(manager);
+            }
+
+            return manager;
         }
 
         function main(inName, depArray, callback, relModuleMap) {
             var moduleMap = makeModuleMap(inName, relModuleMap),
                 name = moduleMap.name,
                 fullName = moduleMap.fullName,
-                uniques = {},
-                manager = {
-                    //Use a wait ID because some entries are anon
-                    //async require calls.
-                    waitId: name || reqWaitIdPrefix + (waitIdCounter++),
-                    depCount: 0,
-                    depMax: 0,
-                    prefix: moduleMap.prefix,
-                    name: name,
-                    fullName: fullName,
-                    deps: {},
-                    depArray: depArray,
-                    callback: callback,
-                    onDep: function (depName, value) {
-                        if (!(depName in manager.deps)) {
-                            manager.deps[depName] = value;
-                            manager.depCount += 1;
-                            if (manager.depCount === manager.depMax) {
-                                //All done, execute!
-                                execManager(manager);
-                            }
-                        }
-                    }
-                },
-                i, depArg, depName, cjsMod;
+                manager = getManager(moduleMap),
+                id = manager.id,
+                deps = manager.deps,
+                i, depArg, depName, depPrefix, cjsMod;
 
             if (fullName) {
                 //If module already defined for context, or already loaded,
                 //then leave. Also leave if jQuery is registering but it does
                 //not match the desired version number in the config.
-                if (fullName in defined || loaded[fullName] === true ||
+                if (fullName in defined || loaded[id] === true ||
                     (fullName === "jquery" && config.jQuery &&
                      config.jQuery !== callback().fn.jquery)) {
                     return;
@@ -761,14 +822,21 @@
                 //as part of a layer, where onScriptLoad is not fired
                 //for those cases. Do this after the inline define and
                 //dependency tracing is done.
-                specified[fullName] = true;
-                loaded[fullName] = true;
+                specified[id] = true;
+                loaded[id] = true;
 
                 //If module is jQuery set up delaying its dom ready listeners.
                 if (fullName === "jquery" && callback) {
                     jQueryCheck(callback());
                 }
             }
+
+            //Attach real depArray and callback to the manager. Do this
+            //only if the module has not been defined already, so do this after
+            //the fullName checks above. IE can call main() more than once
+            //for a module.
+            manager.depArray = depArray;
+            manager.callback = callback;
 
             //Add the dependencies to the deps field, and register for callbacks
             //on the dependencies.
@@ -781,6 +849,7 @@
                     //Split the dependency name into plugin and name parts
                     depArg = makeModuleMap(depArg, (name ? moduleMap : relModuleMap));
                     depName = depArg.fullName;
+                    depPrefix = depArg.prefix;
 
                     //Fix the name in depArray to be just the name, since
                     //that is how it will be called back later.
@@ -788,46 +857,54 @@
 
                     //Fast path CommonJS standard dependencies.
                     if (depName === "require") {
-                        manager.deps[depName] = makeRequire(moduleMap);
+                        deps[i] = makeRequire(moduleMap);
                     } else if (depName === "exports") {
                         //CommonJS module spec 1.1
-                        manager.deps[depName] = defined[fullName] = {};
+                        deps[i] = defined[fullName] = {};
                         manager.usingExports = true;
                     } else if (depName === "module") {
                         //CommonJS module spec 1.1
-                        manager.cjsModule = cjsMod = manager.deps[depName] = {
+                        manager.cjsModule = cjsMod = deps[i] = {
                             id: name,
                             uri: name ? context.nameToUrl(name, null, relModuleMap) : undefined,
                             exports: defined[fullName]
                         };
-                        cjsMod.setExports = makeSetExports(cjsMod);
-                    } else if (depName in defined && !(depName in waiting)) {
-                        //Module already defined, no need to wait for it.
-                        manager.deps[depName] = defined[depName];
-                    } else if (!uniques[depName]) {
-
-                        //A dynamic dependency.
-                        manager.depMax += 1;
-
-                        queueDependency(depArg);
-
-                        //Register to get notification when dependency loads.
-                        (managerCallbacks[depName] ||
-                        (managerCallbacks[depName] = [])).push(manager);
-
-                        uniques[depName] = true;
+                    } else if (depName in defined && !(depName in waiting) &&
+                               (!(fullName in needFullExec) ||
+                                (fullName in needFullExec && fullExec[depName]))) {
+                        //Module already defined, and not in a build situation
+                        //where the module is a something that needs full
+                        //execution and this dependency has not been fully
+                        //executed. See r.js's requirePatch.js for more info
+                        //on fullExec.
+                        deps[i] = defined[depName];
+                    } else {
+                        //Mark this dependency as needing full exec if
+                        //the current module needs full exec.
+                        if (fullName in needFullExec) {
+                            needFullExec[depName] = true;
+                            //Reset state so fully executed code will get
+                            //picked up correctly.
+                            delete defined[depName];
+                            urlFetched[depArg.url] = false;
+                        }
+
+                        //Either a resource that is not loaded yet, or a plugin
+                        //resource for either a plugin that has not
+                        //loaded yet.
+                        manager.depCount += 1;
+                        manager.depCallbacks[i] = makeArgCallback(manager, i);
+                        getManager(depArg, true).add(manager.depCallbacks[i]);
                     }
                 }
             }
 
             //Do not bother tracking the manager if it is all done.
-            if (manager.depCount === manager.depMax) {
+            if (!manager.depCount) {
                 //All done, execute!
                 execManager(manager);
             } else {
-                waiting[manager.waitId] = manager;
-                waitAry.push(manager);
-                context.waitCount += 1;
+                addWait(manager);
             }
         }
 
@@ -837,10 +914,6 @@
          */
         function callDefMain(args) {
             main.apply(null, args);
-            //Mark the module loaded. Must do it here in addition
-            //to doing it in define in case a script does
-            //not call define
-            loaded[args[0]] = true;
         }
 
         /**
@@ -889,9 +962,10 @@
                 return undefined;
             }
 
-            var fullName = manager.fullName,
+            var fullName = manager.map.fullName,
                 depArray = manager.depArray,
-                depName, i;
+                i, depName, depManager, prefix, prefixManager, value;
+
             if (fullName) {
                 if (traced[fullName]) {
                     return defined[fullName];
@@ -900,14 +974,24 @@
                 traced[fullName] = true;
             }
 
-            //forceExec all of its dependencies.
-            for (i = 0; i < depArray.length; i++) {
-                //Some array members may be null, like if a trailing comma
-                //IE, so do the explicit [i] access and check if it has a value.
-                depName = depArray[i];
-                if (depName) {
-                    if (!manager.deps[depName] && waiting[depName]) {
-                        manager.onDep(depName, forceExec(waiting[depName], traced));
+            //Trace through the dependencies.
+            if (depArray) {
+                for (i = 0; i < depArray.length; i++) {
+                    //Some array members may be null, like if a trailing comma
+                    //IE, so do the explicit [i] access and check if it has a value.
+                    depName = depArray[i];
+                    if (depName) {
+                        //First, make sure if it is a plugin resource that the
+                        //plugin is not blocked.
+                        prefix = makeModuleMap(depName).prefix;
+                        if (prefix && (prefixManager = waiting[prefix])) {
+                            forceExec(prefixManager, traced);
+                        }
+                        depManager = waiting[depName];
+                        if (depManager && !depManager.isDone && loaded[depName]) {
+                            value = forceExec(depManager, traced);
+                            manager.depCallbacks[i](value);
+                        }
                     }
                 }
             }
@@ -1001,6 +1085,11 @@
                     forceExec(manager, {});
                 }
 
+                //If anything got placed in the paused queue, run it down.
+                if (context.paused.length) {
+                    resume();
+                }
+
                 //Only allow this recursion to a certain depth. Only
                 //triggered by errors in calling a module in which its
                 //modules waiting on it cannot finish loading, or some circular
@@ -1022,136 +1111,11 @@
             return undefined;
         }
 
-        function callPlugin(pluginName, dep) {
-            var name = dep.name,
-                fullName = dep.fullName,
-                load;
-
-            //Do not bother if plugin is already defined or being loaded.
-            if (fullName in defined || fullName in loaded) {
-                return;
-            }
-
-            if (!plugins[pluginName]) {
-                plugins[pluginName] = defined[pluginName];
-            }
-
-            //Only set loaded to false for tracking if it has not already been set.
-            if (!loaded[fullName]) {
-                loaded[fullName] = false;
-            }
-
-            load = function (ret) {
-                //Allow the build process to register plugin-loaded dependencies.
-                if (req.onPluginLoad) {
-                    req.onPluginLoad(context, pluginName, name, ret);
-                }
-
-                execManager({
-                    prefix: dep.prefix,
-                    name: dep.name,
-                    fullName: dep.fullName,
-                    callback: function () {
-                        return ret;
-                    }
-                });
-                loaded[fullName] = true;
-            };
-
-            //Allow plugins to load other code without having to know the
-            //context or how to "complete" the load.
-            load.fromText = function (moduleName, text) {
-                /*jslint evil: true */
-                var hasInteractive = useInteractive;
-
-                //Indicate a the module is in process of loading.
-                context.loaded[moduleName] = false;
-                context.scriptCount += 1;
-
-                //Turn off interactive script matching for IE for any define
-                //calls in the text, then turn it back on at the end.
-                if (hasInteractive) {
-                    useInteractive = false;
-                }
-
-                req.exec(text);
-
-                if (hasInteractive) {
-                    useInteractive = true;
-                }
-
-                //Support anonymous modules.
-                context.completeLoad(moduleName);
-            };
-
-            //Use parentName here since the plugin's name is not reliable,
-            //could be some weird string with no path that actually wants to
-            //reference the parentName's path.
-            plugins[pluginName].load(name, makeRequire(dep.parentMap, true), load, config);
-        }
-
-        function loadPaused(dep) {
-            //Renormalize dependency if its name was waiting on a plugin
-            //to load, which as since loaded.
-            if (dep.prefix && dep.name && dep.name.indexOf('__$p') === 0 && defined[dep.prefix]) {
-                dep = makeModuleMap(dep.originalName, dep.parentMap);
-            }
-
-            var pluginName = dep.prefix,
-                fullName = dep.fullName,
-                urlFetched = context.urlFetched;
-
-            //Do not bother if the dependency has already been specified.
-            if (specified[fullName] || loaded[fullName]) {
-                return;
-            } else {
-                specified[fullName] = true;
-            }
-
-            if (pluginName) {
-                //If plugin not loaded, wait for it.
-                //set up callback list. if no list, then register
-                //managerCallback for that plugin.
-                if (defined[pluginName]) {
-                    callPlugin(pluginName, dep);
-                } else {
-                    if (!pluginsQueue[pluginName]) {
-                        pluginsQueue[pluginName] = [];
-                        (managerCallbacks[pluginName] ||
-                        (managerCallbacks[pluginName] = [])).push({
-                            onDep: function (name, value) {
-                                if (name === pluginName) {
-                                    var i, oldModuleMap, ary = pluginsQueue[pluginName];
-
-                                    //Now update all queued plugin actions.
-                                    for (i = 0; i < ary.length; i++) {
-                                        oldModuleMap = ary[i];
-                                        //Update the moduleMap since the
-                                        //module name may be normalized
-                                        //differently now.
-                                        callPlugin(pluginName,
-                                                   makeModuleMap(oldModuleMap.originalName, oldModuleMap.parentMap));
-                                    }
-                                    delete pluginsQueue[pluginName];
-                                }
-                            }
-                        });
-                    }
-                    pluginsQueue[pluginName].push(dep);
-                }
-            } else {
-                if (!urlFetched[dep.url]) {
-                    req.load(context, fullName, dep.url);
-                    urlFetched[dep.url] = true;
-                }
-            }
-        }
-
         /**
          * Resumes tracing of dependencies and then checks if everything is loaded.
          */
         resume = function () {
-            var args, i, p;
+            var manager, map, url, i, p, args, fullName;
 
             resumeDepth += 1;
 
@@ -1182,9 +1146,33 @@
                     //Reset paused list
                     context.paused = [];
 
-                    for (i = 0; (args = p[i]); i++) {
-                        loadPaused(args);
+                    for (i = 0; (manager = p[i]); i++) {
+                        map = manager.map;
+                        url = map.url;
+                        fullName = map.fullName;
+
+                        //If the manager is for a plugin managed resource,
+                        //ask the plugin to load it now.
+                        if (map.prefix) {
+                            callPlugin(map.prefix, manager);
+                        } else {
+                            //Regular dependency.
+                            if (!urlFetched[url] && !loaded[fullName]) {
+                                req.load(context, fullName, url);
+
+                                //Mark the URL as fetched, but only if it is
+                                //not an empty: URL, used by the optimizer.
+                                //In that case we need to be sure to call
+                                //load() for each module that is mapped to
+                                //empty: so that dependencies are satisfied
+                                //correctly.
+                                if (url.indexOf('empty:') !== 0) {
+                                    urlFetched[url] = true;
+                                }
+                            }
+                        }
                     }
+
                     //Move the start time for timeout forward.
                     context.startTime = (new Date()).getTime();
                     context.pausedCount -= p.length;
@@ -1216,12 +1204,15 @@
             specified: specified,
             loaded: loaded,
             urlMap: urlMap,
+            urlFetched: urlFetched,
             scriptCount: 0,
-            urlFetched: {},
             defined: defined,
             paused: [],
             pausedCount: 0,
             plugins: plugins,
+            needFullExec: needFullExec,
+            fake: {},
+            fullExec: fullExec,
             managerCallbacks: managerCallbacks,
             makeModuleMap: makeModuleMap,
             normalize: normalize,
@@ -1287,7 +1278,6 @@
                     //Allow tracing some require calls to allow the fetching
                     //of the priority config.
                     context.requireWait = false;
-
                     //But first, call resume to register any defined modules that may
                     //be in a data-main built file before the priority config
                     //call. Also grab any waiting define calls for this context.
@@ -1314,12 +1304,6 @@
                 if (cfg.deps || cfg.callback) {
                     context.require(cfg.deps || [], cfg.callback);
                 }
-
-                //Set up ready callback, if asked. Useful when require is defined as a
-                //config object before require.js is loaded.
-                if (cfg.ready) {
-                    req.ready(cfg.ready);
-                }
             },
 
             requireDefined: function (moduleName, relModuleMap) {
@@ -1333,6 +1317,11 @@
             require: function (deps, callback, relModuleMap) {
                 var moduleName, fullName, moduleMap;
                 if (typeof deps === "string") {
+                    if (isFunction(callback)) {
+                        //Invalid call
+                        return req.onError(makeError("requireargs", "Invalid require call"));
+                    }
+
                     //Synchronous access to one module. If require.get is
                     //available (as in the Node adapter), prefer that.
                     //In this case deps is the moduleName and callback is
@@ -1359,7 +1348,11 @@
                     return defined[fullName];
                 }
 
-                main(null, deps, callback, relModuleMap);
+                //Call main but only if there are dependencies or
+                //a callback to call.
+                if (deps && deps.length || callback) {
+                    main(null, deps, callback, relModuleMap);
+                }
 
                 //If the require call does not trigger anything new to load,
                 //then resume the dependency processing.
@@ -1429,11 +1422,6 @@
                                     return jQuery;
                                 } : null]);
                 }
-
-                //Mark the script as loaded. Note that this can be different from a
-                //moduleName that maps to a define call. This line is important
-                //for traditional browser scripts.
-                loaded[moduleName] = true;
 
                 //If a global jQuery is defined, check for it. Need to do it here
                 //instead of main() since stock jQuery does not register as
@@ -1595,7 +1583,7 @@
     /**
      * Export require as a global, but only if it does not already exist.
      */
-    if (typeof require === "undefined") {
+    if (!require) {
         require = req;
     }
 
@@ -1608,17 +1596,13 @@
     };
 
     req.version = version;
-    req.isArray = isArray;
-    req.isFunction = isFunction;
-    req.mixin = mixin;
+
     //Used to filter out dependencies that are already paths.
     req.jsExtRegExp = /^\/|:|\?|\.js$/;
     s = req.s = {
         contexts: contexts,
         //Stores a list of URLs that should not get async script tag treatment.
-        skipAsync: {},
-        isPageLoaded: !isBrowser,
-        readyCalls: []
+        skipAsync: {}
     };
 
     req.isAsync = req.isBrowser = isBrowser;
@@ -1652,14 +1636,7 @@
      * @param {Object} url the URL to the module.
      */
     req.load = function (context, moduleName, url) {
-        var loaded = context.loaded;
-
-        isDone = false;
-
-        //Only set loaded to false for tracking if it has not already been set.
-        if (!loaded[moduleName]) {
-            loaded[moduleName] = false;
-        }
+        req.resourcesReady(false);
 
         context.scriptCount += 1;
         req.attach(url, context, moduleName);
@@ -1696,7 +1673,7 @@
      * return a value to define the module corresponding to the first argument's
      * name.
      */
-    define = req.def = function (name, deps, callback) {
+    define = function (name, deps, callback) {
         var node, context;
 
         //Allow for anonymous functions
@@ -1708,14 +1685,14 @@
         }
 
         //This module may not have dependencies
-        if (!req.isArray(deps)) {
+        if (!isArray(deps)) {
             callback = deps;
             deps = [];
         }
 
         //If no name, and callback is a function, then figure out if it a
         //CommonJS thing with dependencies.
-        if (!name && !deps.length && req.isFunction(callback)) {
+        if (!deps.length && isFunction(callback)) {
             //Remove comments from the callback string,
             //look for require calls, and pull them into the dependencies,
             //but only if there are function args.
@@ -1783,6 +1760,25 @@
      */
     req.execCb = function (name, callback, args, exports) {
         return callback.apply(exports, args);
+    };
+
+
+    /**
+     * Adds a node to the DOM. Public function since used by the order plugin.
+     * This method should not normally be called by outside code.
+     */
+    req.addScriptToDom = function (node) {
+        //For some cache cases in IE 6-8, the script executes before the end
+        //of the appendChild execution, so to tie an anonymous define
+        //call to the module name (which is stored on the node), hold on
+        //to a reference to this node, but clear after the DOM insertion.
+        currentlyAddingScript = node;
+        if (baseElement) {
+            head.insertBefore(node, baseElement);
+        } else {
+            head.appendChild(node);
+        }
+        currentlyAddingScript = null;
     };
 
     /**
@@ -1800,7 +1796,7 @@
         var node = evt.currentTarget || evt.srcElement, contextName, moduleName,
             context;
 
-        if (evt.type === "load" || readyRegExp.test(node.readyState)) {
+        if (evt.type === "load" || (node && readyRegExp.test(node.readyState))) {
             //Reset interactive script so a script node is not held onto for
             //to long.
             interactiveScript = null;
@@ -1834,9 +1830,14 @@
      * @param {moduleName} the name of the module that is associated with the script.
      * @param {Function} [callback] optional callback, defaults to require.onScriptLoad
      * @param {String} [type] optional type, defaults to text/javascript
+     * @param {Function} [fetchOnlyFunction] optional function to indicate the script node
+     * should be set up to fetch the script but do not attach it to the DOM
+     * so that it can later be attached to execute it. This is a way for the
+     * order plugin to support ordered loading in IE. Once the script is fetched,
+     * but not executed, the fetchOnlyFunction will be called.
      */
-    req.attach = function (url, context, moduleName, callback, type) {
-        var node, loaded;
+    req.attach = function (url, context, moduleName, callback, type, fetchOnlyFunction) {
+        var node;
         if (isBrowser) {
             //In the browser so use a script tag
             callback = callback || req.onScriptLoad;
@@ -1877,23 +1878,36 @@
                 //However, IE reports the script as being in "interactive"
                 //readyState at the time of the define call.
                 useInteractive = true;
-                node.attachEvent("onreadystatechange", callback);
+
+
+                if (fetchOnlyFunction) {
+                    //Need to use old school onreadystate here since
+                    //when the event fires and the node is not attached
+                    //to the DOM, the evt.srcElement is null, so use
+                    //a closure to remember the node.
+                    node.onreadystatechange = function (evt) {
+                        //Script loaded but not executed.
+                        //Clear loaded handler, set the real one that
+                        //waits for script execution.
+                        if (node.readyState === 'loaded') {
+                            node.onreadystatechange = null;
+                            node.attachEvent("onreadystatechange", callback);
+                            fetchOnlyFunction(node);
+                        }
+                    };
+                } else {
+                    node.attachEvent("onreadystatechange", callback);
+                }
             } else {
                 node.addEventListener("load", callback, false);
             }
             node.src = url;
 
-            //For some cache cases in IE 6-8, the script executes before the end
-            //of the appendChild execution, so to tie an anonymous define
-            //call to the module name (which is stored on the node), hold on
-            //to a reference to this node, but clear after the DOM insertion.
-            currentlyAddingScript = node;
-            if (baseElement) {
-                head.insertBefore(node, baseElement);
-            } else {
-                head.appendChild(node);
-            }
-            currentlyAddingScript = null;
+            //Fetch only means waiting to attach to DOM after loaded.
+            if (!fetchOnlyFunction) {
+                req.addScriptToDom(node);
+            }
+
             return node;
         } else if (isWebWorker) {
             //In a web worker, use importScripts. This is not a very
@@ -1902,9 +1916,6 @@
             //are in play, the expectation that a build has been done so that
             //only one script needs to be loaded anyway. This may need to be
             //reevaluated if other use cases become common.
-            loaded = context.loaded;
-            loaded[moduleName] = false;
-
             importScripts(url);
 
             //Account for anonymous modules
@@ -1951,36 +1962,8 @@
         }
     }
 
-    //Set baseUrl based on config.
-    s.baseUrl = cfg.baseUrl;
-
-    //****** START page load functionality ****************
-    /**
-     * Sets the page as loaded and triggers check for all modules loaded.
-     */
-    req.pageLoaded = function () {
-        if (!s.isPageLoaded) {
-            s.isPageLoaded = true;
-            if (scrollIntervalId) {
-                clearInterval(scrollIntervalId);
-            }
-
-            //Part of a fix for FF < 3.6 where readyState was not set to
-            //complete so libraries like jQuery that check for readyState
-            //after page load where not getting initialized correctly.
-            //Original approach suggested by Andrea Giammarchi:
-            //http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html
-            //see other setReadyState reference for the rest of the fix.
-            if (setReadyState) {
-                document.readyState = "complete";
-            }
-
-            req.callReady();
-        }
-    };
-
     //See if there is nothing waiting across contexts, and if not, trigger
-    //callReady.
+    //resourcesReady.
     req.checkReadyState = function () {
         var contexts = s.contexts, prop;
         for (prop in contexts) {
@@ -1990,26 +1973,22 @@
                 }
             }
         }
-        s.isDone = true;
-        req.callReady();
+        req.resourcesReady(true);
     };
 
     /**
-     * Internal function that calls back any ready functions. If you are
-     * integrating RequireJS with another library without require.ready support,
-     * you can define this method to call your page ready code instead.
+     * Internal function that is triggered whenever all scripts/resources
+     * have been loaded by the loader. Can be overridden by other, for
+     * instance the domReady plugin, which wants to know when all resources
+     * are loaded.
      */
-    req.callReady = function () {
-        var callbacks = s.readyCalls, i, callback, contexts, context, prop;
-
-        if (s.isPageLoaded && s.isDone) {
-            if (callbacks.length) {
-                s.readyCalls = [];
-                for (i = 0; (callback = callbacks[i]); i++) {
-                    callback();
-                }
-            }
-
+    req.resourcesReady = function (isReady) {
+        var contexts, context, prop;
+
+        //First, set the public variable indicating that resources are loading.
+        req.resourcesDone = isReady;
+
+        if (req.resourcesDone) {
             //If jQuery with DOM ready delayed, release it now.
             contexts = s.contexts;
             for (prop in contexts) {
@@ -2024,62 +2003,23 @@
         }
     };
 
-    /**
-     * Registers functions to call when the page is loaded
-     */
-    req.ready = function (callback) {
-        if (s.isPageLoaded && s.isDone) {
-            callback();
-        } else {
-            s.readyCalls.push(callback);
-        }
-        return req;
+    //FF < 3.6 readyState fix. Needed so that domReady plugin
+    //works well in that environment, since require.js is normally
+    //loaded via an HTML script tag so it will be there before window load,
+    //where the domReady plugin is more likely to be loaded after window load.
+    req.pageLoaded = function () {
+        if (document.readyState !== "complete") {
+            document.readyState = "complete";
+        }
     };
-
     if (isBrowser) {
         if (document.addEventListener) {
-            //Standards. Hooray! Assumption here that if standards based,
-            //it knows about DOMContentLoaded.
-            document.addEventListener("DOMContentLoaded", req.pageLoaded, false);
-            window.addEventListener("load", req.pageLoaded, false);
-            //Part of FF < 3.6 readystate fix (see setReadyState refs for more info)
             if (!document.readyState) {
-                setReadyState = true;
                 document.readyState = "loading";
-            }
-        } else if (window.attachEvent) {
-            window.attachEvent("onload", req.pageLoaded);
-
-            //DOMContentLoaded approximation, as found by Diego Perini:
-            //http://javascript.nwbox.com/IEContentLoaded/
-            if (self === self.top) {
-                scrollIntervalId = setInterval(function () {
-                    try {
-                        //From this ticket:
-                        //http://bugs.dojotoolkit.org/ticket/11106,
-                        //In IE HTML Application (HTA), such as in a selenium test,
-                        //javascript in the iframe can't see anything outside
-                        //of it, so self===self.top is true, but the iframe is
-                        //not the top window and doScroll will be available
-                        //before document.body is set. Test document.body
-                        //before trying the doScroll trick.
-                        if (document.body) {
-                            document.documentElement.doScroll("left");
-                            req.pageLoaded();
-                        }
-                    } catch (e) {}
-                }, 30);
-            }
-        }
-
-        //Check if document already complete, and if so, just trigger page load
-        //listeners. NOTE: does not work with Firefox before 3.6. To support
-        //those browsers, manually call require.pageLoaded().
-        if (document.readyState === "complete") {
-            req.pageLoaded();
+                window.addEventListener("load", req.pageLoaded, false);
+            }
         }
     }
-    //****** END page load functionality ****************
 
     //Set up default context. If require was a configuration object, use that as base config.
     req(cfg);
@@ -2127,11 +2067,7 @@
 (function () {
 
     require.load = function (context, moduleName, url) {
-        //isDone is used by require.ready()
-        require.s.isDone = false;
-
         //Indicate a the module is in process of loading.
-        context.loaded[moduleName] = false;
         context.scriptCount += 1;
 
         load(url);
@@ -2144,6 +2080,7 @@
     } else if (env === 'node') {
         this.requirejsVars = {
             require: require,
+            requirejs: require,
             define: define,
             nodeRequire: nodeRequire
         };
@@ -2203,19 +2140,15 @@
     //API instead of the Node API, and it is done lexically so
     //that it survives later execution.
     req.makeNodeWrapper = function (contents) {
-        return '(function (require, define) { ' +
+        return '(function (require, requirejs, define) { ' +
                 contents +
-                '\n}(requirejsVars.require, requirejsVars.define));';
+                '\n}(requirejsVars.require, requirejsVars.requirejs, requirejsVars.define));';
     };
 
     req.load = function (context, moduleName, url) {
         var contents, err;
 
-        //isDone is used by require.ready()
-        req.s.isDone = false;
-
         //Indicate a the module is in process of loading.
-        context.loaded[moduleName] = false;
         context.scriptCount += 1;
 
         if (path.existsSync(url)) {
@@ -2464,6 +2397,7 @@
 
     file = {
         backSlashRegExp: /\\/g,
+        exclusionRegExp: /^\./,
         getLineSeparator: function () {
             return '/';
         },
@@ -2503,7 +2437,8 @@
             //summary: Recurses startDir and finds matches to the files that match regExpFilters.include
             //and do not match regExpFilters.exclude. Or just one regexp can be passed in for regExpFilters,
             //and it will be treated as the "include" case.
-            //Ignores files/directories that start with a period (.).
+            //Ignores files/directories that start with a period (.) unless exclusionRegExp
+            //is set to another value.
             var files = [], topDir, regExpInclude, regExpExclude, dirFileArray,
                 i, stat, filePath, ok, dirFiles, fileName;
 
@@ -2534,10 +2469,12 @@
                             ok = !filePath.match(regExpExclude);
                         }
 
-                        if (ok && !fileName.match(/^\./)) {
+                        if (ok && (!file.exclusionRegExp ||
+                            !file.exclusionRegExp.test(fileName))) {
                             files.push(filePath);
                         }
-                    } else if (stat.isDirectory() && !fileName.match(/^\./)) {
+                    } else if (stat.isDirectory() &&
+                              (!file.exclusionRegExp || !file.exclusionRegExp.test(fileName))) {
                         dirFiles = this.getFilteredFileList(filePath, regExpFilters, makeUnixPaths);
                         files.push.apply(files, dirFiles);
                     }
@@ -2551,6 +2488,11 @@
             //summary: copies files from srcDir to destDir using the regExpFilter to determine if the
             //file should be copied. Returns a list file name strings of the destinations that were copied.
             regExpFilter = regExpFilter || /\w/;
+
+            //Normalize th directory names, but keep front slashes.
+            //path module on windows now returns backslashed paths.
+            srcDir = frontSlash(path.normalize(srcDir));
+            destDir = frontSlash(path.normalize(destDir));
 
             var fileNames = file.getFilteredFileList(srcDir, regExpFilter, true),
             copiedFiles = [], i, srcFileName, destFileName;
@@ -2607,10 +2549,9 @@
 
             var text = fs.readFileSync(path, encoding);
 
-            //Looks like a weird bug in the native node.exe for windows,
-            //at least in 0.5.3, where UTF-8 BOM is being fed back.
-            //May be able to remove this after more node releases.
-            if (isWindows && text.indexOf('\uFEFF') === 0) {
+            //Hmm, would not expect to get A BOM, but it seems to happen,
+            //remove it just in case.
+            if (text.indexOf('\uFEFF') === 0) {
                 text = text.substring(1, text.length);
             }
 
@@ -2681,6 +2622,8 @@
     var file = {
         backSlashRegExp: /\\/g,
 
+        exclusionRegExp: /^\./,
+
         getLineSeparator: function () {
             return file.lineSeparator;
         },
@@ -2723,7 +2666,8 @@
             //summary: Recurses startDir and finds matches to the files that match regExpFilters.include
             //and do not match regExpFilters.exclude. Or just one regexp can be passed in for regExpFilters,
             //and it will be treated as the "include" case.
-            //Ignores files/directories that start with a period (.).
+            //Ignores files/directories that start with a period (.) unless exclusionRegExp
+            //is set to another value.
             var files = [], topDir, regExpInclude, regExpExclude, dirFileArray,
                 i, fileObj, filePath, ok, dirFiles;
 
@@ -2757,10 +2701,12 @@
                             ok = !filePath.match(regExpExclude);
                         }
 
-                        if (ok && !fileObj.getName().match(/^\./)) {
+                        if (ok && (!file.exclusionRegExp ||
+                            !file.exclusionRegExp.test(fileObj.getName()))) {
                             files.push(filePath);
                         }
-                    } else if (fileObj.isDirectory() && !fileObj.getName().match(/^\./)) {
+                    } else if (fileObj.isDirectory() &&
+                              (!file.exclusionRegExp || !file.exclusionRegExp.test(fileObj.getName()))) {
                         dirFiles = this.getFilteredFileList(fileObj, regExpFilters, makeUnixPaths, true);
                         files.push.apply(files, dirFiles);
                     }
@@ -3252,7 +3198,7 @@
         "||"
 ]);
 
-var WHITESPACE_CHARS = array_to_hash(characters(" \u00a0\n\r\t\f\v\u200b"));
+var WHITESPACE_CHARS = array_to_hash(characters(" \u00a0\n\r\t\f\u000b\u200b\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000"));
 
 var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:"));
 
@@ -3320,13 +3266,7 @@
         this.line = line;
         this.col = col;
         this.pos = pos;
-        /*
-        try {
-                ({})();
-        } catch(ex) {
-                this.stack = ex.stack;
-        };
-        */
+        this.stack = new Error().stack;
 };
 
 JS_Parse_Error.prototype.toString = function() {
@@ -3469,11 +3409,12 @@
                     case "r" : return "\r";
                     case "t" : return "\t";
                     case "b" : return "\b";
-                    case "v" : return "\v";
+                    case "v" : return "\u000b";
                     case "f" : return "\f";
                     case "0" : return "\0";
                     case "x" : return String.fromCharCode(hex_bytes(2));
                     case "u" : return String.fromCharCode(hex_bytes(4));
+                    case "\n": return "";
                     default  : return ch;
                 }
         };
@@ -3572,9 +3513,9 @@
                 return name;
         };
 
-        function read_regexp() {
+        function read_regexp(regexp) {
                 return with_eof_error("Unterminated regular expression", function(){
-                        var prev_backslash = false, regexp = "", ch, in_class = false;
+                        var prev_backslash = false, ch, in_class = false;
                         while ((ch = next(true))) if (prev_backslash) {
                                 regexp += "\\" + ch;
                                 prev_backslash = false;
@@ -3623,7 +3564,7 @@
                         S.regex_allowed = regex_allowed;
                         return next_token();
                 }
-                return S.regex_allowed ? read_regexp() : read_operator("/");
+                return S.regex_allowed ? read_regexp("") : read_operator("/");
         };
 
         function handle_dot() {
@@ -3654,8 +3595,8 @@
         };
 
         function next_token(force_regexp) {
-                if (force_regexp)
-                        return read_regexp();
+                if (force_regexp != null)
+                        return read_regexp(force_regexp);
                 skip_whitespace();
                 start_token();
                 var ch = peek();
@@ -3844,9 +3785,9 @@
         };
 
         var statement = maybe_embed_tokens(function() {
-                if (is("operator", "/")) {
+                if (is("operator", "/") || is("operator", "/=")) {
                         S.peeked = null;
-                        S.token = S.input(true); // force regexp
+                        S.token = S.input(S.token.value.substr(1)); // force regexp
                 }
                 switch (S.token.type) {
                     case "num":
@@ -3916,6 +3857,8 @@
                                 return as("switch", parenthesised(), switch_block_());
 
                             case "throw":
+                                if (S.token.nlb)
+                                        croak("Illegal newline after 'throw'");
                                 return as("throw", prog1(expression, semicolon));
 
                             case "try":
@@ -4291,7 +4234,7 @@
 
         function is_assignable(expr) {
                 if (!exigent_mode) return true;
-                switch (expr[0]) {
+                switch (expr[0]+"") {
                     case "dot":
                     case "sub":
                     case "new":
@@ -4365,7 +4308,7 @@
 };
 
 function slice(a, start) {
-        return Array.prototype.slice.call(a, start == null ? 0 : start);
+        return Array.prototype.slice.call(a, start || 0);
 };
 
 function characters(str) {
@@ -4404,28 +4347,55 @@
         warn = logger;
 };
 
-
-});
-define('uglifyjs/squeeze-more', ["require", "exports", "module", "./parse-js", "./process"], function(require, exports, module) {
+});define('uglifyjs/squeeze-more', ["require", "exports", "module", "./parse-js", "./process"], function(require, exports, module) {
 
 var jsp = require("./parse-js"),
     pro = require("./process"),
     slice = jsp.slice,
     member = jsp.member,
+    curry = jsp.curry,
+    MAP = pro.MAP,
     PRECEDENCE = jsp.PRECEDENCE,
     OPERATORS = jsp.OPERATORS;
 
 function ast_squeeze_more(ast) {
-        var w = pro.ast_walker(), walk = w.walk;
+        var w = pro.ast_walker(), walk = w.walk, scope;
+        function with_scope(s, cont) {
+                var save = scope, ret;
+                scope = s;
+                ret = cont();
+                scope = save;
+                return ret;
+        };
+        function _lambda(name, args, body) {
+                return [ this[0], name, args, with_scope(body.scope, curry(MAP, body, walk)) ];
+        };
         return w.with_walkers({
+                "toplevel": function(body) {
+                        return [ this[0], with_scope(this.scope, curry(MAP, body, walk)) ];
+                },
+                "function": _lambda,
+                "defun": _lambda,
+                "new": function(ctor, args) {
+                        if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) {
+                                if (args.length != 1) {
+                                        return [ "array", args ];
+                                } else {
+                                        return walk([ "call", [ "name", "Array" ], args ]);
+                                }
+                        }
+                },
                 "call": function(expr, args) {
                         if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
                                 // foo.toString()  ==>  foo+""
                                 return [ "binary", "+", expr[1], [ "string", "" ]];
                         }
+                        if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
+                                return [ "array", args ];
+                        }
                 }
         }, function() {
-                return walk(ast);
+                return walk(pro.ast_add_scope(ast));
         });
 };
 
@@ -4501,7 +4471,7 @@
 
 /* -----[ helper for AST traversal ]----- */
 
-function ast_walker(ast) {
+function ast_walker() {
         function _vardefs(defs) {
                 return [ this[0], MAP(defs, function(def){
                         var a = [ def[0] ];
@@ -4658,6 +4628,17 @@
                 }
         };
 
+        function dive(ast) {
+                if (ast == null)
+                        return null;
+                try {
+                        stack.push(ast);
+                        return walkers[ast[0]].apply(ast, ast.slice(1));
+                } finally {
+                        stack.pop();
+                }
+        };
+
         function with_walkers(walkers, cont){
                 var save = {}, i;
                 for (i in walkers) if (HOP(walkers, i)) {
@@ -4674,6 +4655,7 @@
 
         return {
                 walk: walk,
+                dive: dive,
                 with_walkers: with_walkers,
                 parent: function() {
                         return stack[stack.length - 2]; // last one is current node
@@ -4786,9 +4768,15 @@
                 if (!newMangle) return name;                      // not found and no mangling requested
                 return s.set_mangle(name, s.next_mangled());
         },
-        define: function(name) {
-                if (name != null)
-                        return this.names[name] = name;
+        references: function(name) {
+                return name && !this.parent || this.uses_with || this.uses_eval || this.refs[name];
+        },
+        define: function(name, type) {
+                if (name != null) {
+                        if (type == "var" || !HOP(this.names, name))
+                                this.names[name] = type || "var";
+                        return name;
+                }
         }
 };
 
@@ -4806,8 +4794,8 @@
                 return ret;
         };
 
-        function define(name) {
-                return current_scope.define(name);
+        function define(name, type) {
+                return current_scope.define(name, type);
         };
 
         function reference(name) {
@@ -4816,11 +4804,20 @@
 
         function _lambda(name, args, body) {
                 var is_defun = this[0] == "defun";
-                return [ this[0], is_defun ? define(name) : name, args, with_new_scope(function(){
-                        if (!is_defun) define(name);
-                        MAP(args, define);
+                return [ this[0], is_defun ? define(name, "defun") : name, args, with_new_scope(function(){
+                        if (!is_defun) define(name, "lambda");
+                        MAP(args, function(name){ define(name, "arg") });
                         return MAP(body, walk);
                 })];
+        };
+
+        function _vardefs(type) {
+                return function(defs) {
+                        MAP(defs, function(d){
+                                define(d[0], type);
+                                if (d[1]) reference(d[0]);
+                        });
+                };
         };
 
         return with_new_scope(function(){
@@ -4828,21 +4825,20 @@
                 var ret = w.with_walkers({
                         "function": _lambda,
                         "defun": _lambda,
+                        "label": function(name, stat) { define(name, "label") },
+                        "break": function(label) { if (label) reference(label) },
+                        "continue": function(label) { if (label) reference(label) },
                         "with": function(expr, block) {
                                 for (var s = current_scope; s; s = s.parent)
                                         s.uses_with = true;
                         },
-                        "var": function(defs) {
-                                MAP(defs, function(d){ define(d[0]) });
-                        },
-                        "const": function(defs) {
-                                MAP(defs, function(d){ define(d[0]) });
-                        },
+                        "var": _vardefs("var"),
+                        "const": _vardefs("const"),
                         "try": function(t, c, f) {
                                 if (c != null) return [
                                         this[0],
                                         MAP(t, walk),
-                                        [ define(c[0]), MAP(c[1], walk) ],
+                                        [ define(c[0], "catch"), MAP(c[1], walk) ],
                                         f != null ? MAP(f, walk) : null
                                 ];
                         },
@@ -4970,6 +4966,9 @@
                         }
                         return ast;
                 },
+                "label": function(label, stat) { return [ this[0], get_mangled(label), walk(stat) ] },
+                "break": function(label) { if (label) return [ this[0], get_mangled(label) ] },
+                "continue": function(label) { if (label) return [ this[0], get_mangled(label) ] },
                 "var": _vardefs,
                 "const": _vardefs,
                 "name": function(name) {
@@ -5016,10 +5015,12 @@
 }
 
 function aborts(t) {
-        if (t) {
-                t = last_stat(t);
-                if (t[0] == "return" || t[0] == "break" || t[0] == "continue" || t[0] == "throw")
-                        return true;
+        if (t) switch (last_stat(t)[0]) {
+            case "return":
+            case "break":
+            case "continue":
+            case "throw":
+                return true;
         }
 };
 
@@ -5046,21 +5047,6 @@
                  (expr[0] == "seq"
                   && boolean_expr(expr[expr.length - 1]))
                );
-};
-
-function make_conditional(c, t, e) {
-    var make_real_conditional = function() {
-        if (c[0] == "unary-prefix" && c[1] == "!") {
-            return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ];
-        } else {
-            return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ];
-        }
-    };
-    // shortcut the conditional if the expression has a constant value
-    return when_constant(c, function(ast, val){
-        warn_unreachable(val ? e : t);
-        return          (val ? t : e);
-    }, make_real_conditional);
 };
 
 function empty(b) {
@@ -5090,6 +5076,7 @@
                         switch (expr[1]) {
                             case "true": return true;
                             case "false": return false;
+                            case "null": return null;
                         }
                         break;
                     case "unary-prefix":
@@ -5112,6 +5099,7 @@
                             case "+"          : return evaluate(left) +          evaluate(right);
                             case "*"          : return evaluate(left) *          evaluate(right);
                             case "/"          : return evaluate(left) /          evaluate(right);
+                            case "%"          : return evaluate(left) %          evaluate(right);
                             case "-"          : return evaluate(left) -          evaluate(right);
                             case "<<"         : return evaluate(left) <<         evaluate(right);
                             case ">>"         : return evaluate(left) >>         evaluate(right);
@@ -5208,9 +5196,7 @@
                         var conditional = walk(fi[1]);
 
                         var e_body = statements.slice(i + 1);
-                        var e;
-                        if (e_body.length == 1) e = e_body[0];
-                        else e = [ "block", e_body ];
+                        var e = e_body.length == 1 ? e_body[0] : [ "block", e_body ];
 
                         var ret = statements.slice(0, i).concat([ [
                                 fi[0],          // "if"
@@ -5227,14 +5213,11 @@
 
         function redo_if_lambda(name, args, body) {
                 body = redo_if(body);
-                return [ this[0], name, args.slice(), body ];
+                return [ this[0], name, args, body ];
         };
 
         function redo_if_block(statements) {
-                var out = [ this[0] ];
-                if (statements != null)
-                        out.push(redo_if(statements));
-                return out;
+                return [ this[0], statements != null ? redo_if(statements) : null ];
         };
 
         return w.with_walkers({
@@ -5258,11 +5241,143 @@
         });
 };
 
+function for_side_effects(ast, handler) {
+        var w = ast_walker(), walk = w.walk;
+        var $stop = {}, $restart = {};
+        function stop() { throw $stop };
+        function restart() { throw $restart };
+        function found(){ return handler.call(this, this, w, stop, restart) };
+        function unary(op) {
+                if (op == "++" || op == "--")
+                        return found.apply(this, arguments);
+        };
+        return w.with_walkers({
+                "try": found,
+                "throw": found,
+                "return": found,
+                "new": found,
+                "switch": found,
+                "break": found,
+                "continue": found,
+                "assign": found,
+                "call": found,
+                "if": found,
+                "for": found,
+                "for-in": found,
+                "while": found,
+                "do": found,
+                "return": found,
+                "unary-prefix": unary,
+                "unary-postfix": unary,
+                "defun": found
+        }, function(){
+                while (true) try {
+                        walk(ast);
+                        break;
+                } catch(ex) {
+                        if (ex === $stop) break;
+                        if (ex === $restart) continue;
+                        throw ex;
+                }
+        });
+};
+
+function ast_lift_variables(ast) {
+        var w = ast_walker(), walk = w.walk, scope;
+        function do_body(body, env) {
+                var _scope = scope;
+                scope = env;
+                body = MAP(body, walk);
+                var hash = {}, names = MAP(env.names, function(type, name){
+                        if (type != "var") return MAP.skip;
+                        if (!env.references(name)) return MAP.skip;
+                        hash[name] = true;
+                        return [ name ];
+                });
+                if (names.length > 0) {
+                        // looking for assignments to any of these variables.
+                        // we can save considerable space by moving the definitions
+                        // in the var declaration.
+                        for_side_effects([ "block", body ], function(ast, walker, stop, restart) {
+                                if (ast[0] == "assign"
+                                    && ast[1] === true
+                                    && ast[2][0] == "name"
+                                    && HOP(hash, ast[2][1])) {
+                                        // insert the definition into the var declaration
+                                        for (var i = names.length; --i >= 0;) {
+                                                if (names[i][0] == ast[2][1]) {
+                                                        if (names[i][1]) // this name already defined, we must stop
+                                                                stop();
+                                                        names[i][1] = ast[3]; // definition
+                                                        names.push(names.splice(i, 1)[0]);
+                                                        break;
+                                                }
+                                        }
+                                        // remove this assignment from the AST.
+                                        var p = walker.parent();
+                                        if (p[0] == "seq") {
+                                                var a = p[2];
+                                                a.unshift(0, p.length);
+                                                p.splice.apply(p, a);
+                                        }
+                                        else if (p[0] == "stat") {
+                                                p.splice(0, p.length, "block"); // empty statement
+                                        }
+                                        else {
+                                                stop();
+                                        }
+                                        restart();
+                                }
+                                stop();
+                        });
+                        body.unshift([ "var", names ]);
+                }
+                scope = _scope;
+                return body;
+        };
+        function _vardefs(defs) {
+                var ret = null;
+                for (var i = defs.length; --i >= 0;) {
+                        var d = defs[i];
+                        if (!d[1]) continue;
+                        d = [ "assign", true, [ "name", d[0] ], d[1] ];
+                        if (ret == null) ret = d;
+                        else ret = [ "seq", d, ret ];
+                }
+                if (ret == null) {
+                        if (w.parent()[0] == "for-in")
+                                return [ "name", defs[0][0] ];
+                        return MAP.skip;
+                }
+                return [ "stat", ret ];
+        };
+        function _toplevel(body) {
+                return [ this[0], do_body(body, this.scope) ];
+        };
+        return w.with_walkers({
+                "function": function(name, args, body){
+                        for (var i = args.length; --i >= 0 && !body.scope.references(args[i]);)
+                                args.pop();
+                        if (!body.scope.references(name)) name = null;
+                        return [ this[0], name, args, do_body(body, body.scope) ];
+                },
+                "defun": function(name, args, body){
+                        if (!scope.references(name)) return MAP.skip;
+                        for (var i = args.length; --i >= 0 && !body.scope.references(args[i]);)
+                                args.pop();
+                        return [ this[0], name, args, do_body(body, body.scope) ];
+                },
+                "var": _vardefs,
+                "toplevel": _toplevel
+        }, function(){
+                return walk(ast_add_scope(ast));
+        });
+};
+
 function ast_squeeze(ast, options) {
         options = defaults(options, {
                 make_seqs   : true,
                 dead_code   : true,
-                keep_comps  : true,
                 no_warnings : false
         });
 
@@ -5281,13 +5396,11 @@
                         return best_of(not_c, [ "conditional", c[1], negate(c[2]), negate(c[3]) ]);
                     case "binary":
                         var op = c[1], left = c[2], right = c[3];
-                        if (!options.keep_comps) switch (op) {
+                        switch (op) {
                             case "<="  : return [ "binary", ">", left, right ];
                             case "<"   : return [ "binary", ">=", left, right ];
                             case ">="  : return [ "binary", "<", left, right ];
                             case ">"   : return [ "binary", "<=", left, right ];
-                        }
-                        switch (op) {
                             case "=="  : return [ "binary", "!=", left, right ];
                             case "!="  : return [ "binary", "==", left, right ];
                             case "===" : return [ "binary", "!==", left, right ];
@@ -5298,6 +5411,24 @@
                         break;
                 }
                 return not_c;
+        };
+
+        function make_conditional(c, t, e) {
+                var make_real_conditional = function() {
+                        if (c[0] == "unary-prefix" && c[1] == "!") {
+                                return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ];
+                        } else {
+                                return e ? best_of(
+                                        [ "conditional", c, t, e ],
+                                        [ "conditional", negate(c), e, t ]
+                                ) : [ "binary", "&&", c, t ];
+                        }
+                };
+                // shortcut the conditional if the expression has a constant value
+                return when_constant(c, function(ast, val){
+                        warn_unreachable(val ? e : t);
+                        return          (val ? t : e);
+                }, make_real_conditional);
         };
 
         function with_scope(s, cont) {
@@ -5322,15 +5453,14 @@
         function _lambda(name, args, body) {
                 var is_defun = this[0] == "defun";
                 body = with_scope(body.scope, function(){
-                        var ret = tighten(MAP(body, walk), "lambda");
-                        if (!is_defun && name && !HOP(scope.refs, name))
+                        var ret = tighten(body, "lambda");
+                        if (!is_defun && name && !scope.references(name))
                                 name = null;
                         return ret;
                 });
                 return [ this[0], name, args, body ];
         };
 
-        // we get here for blocks that have been already transformed.
         // this function does a few things:
         // 1. discard useless blocks
         // 2. join consecutive var declarations
@@ -5338,6 +5468,8 @@
         // 4. transform consecutive statements using the comma operator
         // 5. if block_type == "lambda" and it detects constructs like if(foo) return ... - rewrite like if (!foo) { ... }
         function tighten(statements, block_type) {
+                statements = MAP(statements, walk);
+
                 statements = statements.reduce(function(a, stat){
                         if (stat[0] == "block") {
                                 if (stat[1]) {
@@ -5365,7 +5497,17 @@
                 if (options.dead_code) statements = (function(a, has_quit){
                         statements.forEach(function(st){
                                 if (has_quit) {
-                                        if (member(st[0], [ "function", "defun" , "var", "const" ])) {
+                                        if (st[0] == "function" || st[0] == "defun") {
+                                                a.push(st);
+                                        }
+                                        else if (st[0] == "var" || st[0] == "const") {
+                                                if (!options.no_warnings)
+                                                        warn("Variables declared in unreachable code");
+                                                st[1] = MAP(st[1], function(def){
+                                                        if (def[1] && !options.no_warnings)
+                                                                warn_unreachable([ "assign", true, [ "name", def[0] ], def[1] ]);
+                                                        return [ def[0] ];
+                                                });
                                                 a.push(st);
                                         }
                                         else if (!options.no_warnings)
@@ -5389,27 +5531,38 @@
                                         prev = cur;
                                 }
                         });
+                        if (a.length >= 2
+                            && a[a.length-2][0] == "stat"
+                            && (a[a.length-1][0] == "return" || a[a.length-1][0] == "throw")
+                            && a[a.length-1][1])
+                        {
+                                a.splice(a.length - 2, 2,
+                                         [ a[a.length-1][0],
+                                           [ "seq", a[a.length-2][1], a[a.length-1][1] ]]);
+                        }
                         return a;
                 })([]);
 
-                if (block_type == "lambda") statements = (function(i, a, stat){
-                        while (i < statements.length) {
-                                stat = statements[i++];
-                                if (stat[0] == "if" && !stat[3]) {
-                                        if (stat[2][0] == "return" && stat[2][1] == null) {
-                                                a.push(make_if(negate(stat[1]), [ "block", statements.slice(i) ]));
-                                                break;
-                                        }
-                                        var last = last_stat(stat[2]);
-                                        if (last[0] == "return" && last[1] == null) {
-                                                a.push(make_if(stat[1], [ "block", stat[2][1].slice(0, -1) ], [ "block", statements.slice(i) ]));
-                                                break;
-                                        }
-                                }
-                                a.push(stat);
-                        }
-                        return a;
-                })(0, []);
+                // this increases jQuery by 1K.  Probably not such a good idea after all..
+                // part of this is done in prepare_ifs anyway.
+                // if (block_type == "lambda") statements = (function(i, a, stat){
+                //         while (i < statements.length) {
+                //                 stat = statements[i++];
+                //                 if (stat[0] == "if" && !stat[3]) {
+                //                         if (stat[2][0] == "return" && stat[2][1] == null) {
+                //                                 a.push(make_if(negate(stat[1]), [ "block", statements.slice(i) ]));
+                //                                 break;
+                //                         }
+                //                         var last = last_stat(stat[2]);
+                //                         if (last[0] == "return" && last[1] == null) {
+                //                                 a.push(make_if(stat[1], [ "block", stat[2][1].slice(0, -1) ], [ "block", statements.slice(i) ]));
+                //                                 break;
+                //                         }
+                //                 }
+                //                 a.push(stat);
+                //         }
+                //         return a;
+                // })(0, []);
 
                 return statements;
         };
@@ -5417,11 +5570,13 @@
         function make_if(c, t, e) {
                 return when_constant(c, function(ast, val){
                         if (val) {
+                                t = walk(t);
                                 warn_unreachable(e);
-                                return t;
+                                return t || [ "block" ];
                         } else {
+                                e = walk(e);
                                 warn_unreachable(t);
-                                return e;
+                                return e || [ "block" ];
                         }
                 }, function() {
                         return make_real_if(c, t, e);
@@ -5505,9 +5660,6 @@
                 });
         };
 
-        ast = prepare_ifs(ast);
-        ast = ast_add_scope(ast);
-
         return w.with_walkers({
                 "sub": function(expr, subscript) {
                         if (subscript[0] == "string") {
@@ -5521,13 +5673,13 @@
                 "if": make_if,
                 "toplevel": function(body) {
                         return [ "toplevel", with_scope(this.scope, function(){
-                                return tighten(MAP(body, walk));
+                                return tighten(body);
                         }) ];
                 },
                 "switch": function(expr, body) {
                         var last = body.length - 1;
                         return [ "switch", walk(expr), MAP(body, function(branch, i){
-                                var block = tighten(MAP(branch[1], walk));
+                                var block = tighten(branch[1]);
                                 if (i == last && block.length > 0) {
                                         var node = block[block.length - 1];
                                         if (node[0] == "break" && !node[1])
@@ -5539,13 +5691,21 @@
                 "function": _lambda,
                 "defun": _lambda,
                 "block": function(body) {
-                        if (body) return rmblock([ "block", tighten(MAP(body, walk)) ]);
+                        if (body) return rmblock([ "block", tighten(body) ]);
                 },
                 "binary": function(op, left, right) {
                         return when_constant([ "binary", op, walk(left), walk(right) ], function yes(c){
                                 return best_of(walk(c), this);
                         }, function no() {
-                                return this;
+                                return function(){
+                                        if(op != "==" && op != "!=") return;
+                                        var l = walk(left), r = walk(right);
+                                        if(l && l[0] == "unary-prefix" && l[1] == "!" && l[2][0] == "num")
+                                                left = ['num', +!l[2][1]];
+                                        else if (r && r[0] == "unary-prefix" && r[1] == "!" && r[2][0] == "num")
+                                                right = ['num', +!r[2][1]];
+                                        return ["binary", op, left, right];
+                                }() || this;
                         });
                 },
                 "conditional": function(c, t, e) {
@@ -5554,9 +5714,9 @@
                 "try": function(t, c, f) {
                         return [
                                 "try",
-                                tighten(MAP(t, walk)),
-                                c != null ? [ c[0], tighten(MAP(c[1], walk)) ] : null,
-                                f != null ? tighten(MAP(f, walk)) : null
+                                tighten(t),
+                                c != null ? [ c[0], tighten(c[1]) ] : null,
+                                f != null ? tighten(f) : null
                         ];
                 },
                 "unary-prefix": function(op, expr) {
@@ -5574,23 +5734,25 @@
                             case "false": return [ "unary-prefix", "!", [ "num", 1 ]];
                         }
                 },
-                "new": function(ctor, args) {
-                        if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) {
-                                if (args.length != 1) {
-                                        return [ "array", args ];
-                                } else {
-                                        return [ "call", [ "name", "Array" ], args ];
-                                }
-                        }
-                },
-                "call": function(expr, args) {
-                        if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
-                                return [ "array", args ];
-                        }
-                },
-                "while": _do_while
+                "while": _do_while,
+                "assign": function(op, lvalue, rvalue) {
+                        lvalue = walk(lvalue);
+                        rvalue = walk(rvalue);
+                        var okOps = [ '+', '-', '/', '*', '%', '>>', '<<', '>>>', '|', '^', '&' ];
+                        if (op === true && lvalue[0] === "name" && rvalue[0] === "binary" &&
+                            ~okOps.indexOf(rvalue[1]) && rvalue[2][0] === "name" &&
+                            rvalue[2][1] === lvalue[1]) {
+                                return [ this[0], rvalue[1], lvalue, rvalue[3] ]
+                        }
+                        return [ this[0], op, lvalue, rvalue ];
+                }
         }, function() {
-                return walk(ast);
+                for (var i = 0; i < 2; ++i) {
+                        ast = prepare_ifs(ast);
+                        ast = ast_add_scope(ast);
+                        ast = walk(ast);
+                }
+                return ast;
         });
 };
 
@@ -5609,7 +5771,7 @@
 
 function make_string(str, ascii_only) {
         var dq = 0, sq = 0;
-        str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029]/g, function(s){
+        str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0]/g, function(s){
                 switch (s) {
                     case "\\": return "\\\\";
                     case "\b": return "\\b";
@@ -5621,6 +5783,7 @@
                     case "\u2029": return "\\u2029";
                     case '"': ++dq; return '"';
                     case "'": ++sq; return "'";
+                    case "\0": return "\\0";
                 }
                 return s;
         });
@@ -5735,7 +5898,7 @@
                         // we're the first in this "seq" and the
                         // parent is "stat", and so on.  Messy stuff,
                         // but it worths the trouble.
-                        var a = slice($stack), self = a.pop(), p = a.pop();
+                        var a = slice(w.stack()), self = a.pop(), p = a.pop();
                         while (p) {
                                 if (p[0] == "stat") return true;
                                 if (((p[0] == "seq" || p[0] == "call" || p[0] == "dot" || p[0] == "sub" || p[0] == "conditional") && p[1] === self) ||
@@ -5753,8 +5916,13 @@
         function make_num(num) {
                 var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m;
                 if (Math.floor(num) === num) {
-                        a.push("0x" + num.toString(16).toLowerCase(), // probably pointless
-                               "0" + num.toString(8)); // same.
+                        if (num >= 0) {
+                                a.push("0x" + num.toString(16).toLowerCase(), // probably pointless
+                                       "0" + num.toString(8)); // same.
+                        } else {
+                                a.push("-0x" + (-num).toString(16).toLowerCase(), // probably pointless
+                                       "-0" + (-num).toString(8)); // same.
+                        }
                         if ((m = /^(.*?)(0+)$/.exec(num))) {
                                 a.push(m[1] + "e" + m[2].length);
                         }
@@ -5765,7 +5933,9 @@
                 return best_of(a);
         };
 
-        var generators = {
+        var w = ast_walker();
+        var make = w.walk;
+        return w.with_walkers({
                 "string": encode_string,
                 "num": make_num,
                 "name": make_name,
@@ -5774,7 +5944,7 @@
                                 .join(newline + newline);
                 },
                 "splice": function(statements) {
-                        var parent = $stack[$stack.length - 2][0];
+                        var parent = w.parent();
                         if (HOP(SPLICE_NEEDS_BRACKETS, parent)) {
                                 // we need block brackets in this case
                                 return make_block.apply(this, arguments);
@@ -5803,7 +5973,9 @@
                         return add_spaces([ "throw", make(expr) ]) + ";";
                 },
                 "new": function(ctor, args) {
-                        args = args.length > 0 ? "(" + add_commas(MAP(args, make)) + ")" : "";
+                        args = args.length > 0 ? "(" + add_commas(MAP(args, function(expr){
+                                return parenthesize(expr, "seq");
+                        })) + ")" : "";
                         return add_spaces([ "new", parenthesize(ctor, "seq", "binary", "conditional", "assign", function(expr){
                                 var w = ast_walker(), has_call = {};
                                 try {
@@ -5906,7 +6078,8 @@
                         //      we need to be smarter.
                         //      adding parens all the time is the safest bet.
                         if (member(lvalue[0], [ "assign", "conditional", "seq" ]) ||
-                            lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]]) {
+                            lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]] ||
+                            lvalue[0] == "function" && needs_parens(this)) {
                                 left = "(" + left + ")";
                         }
                         if (member(rvalue[0], [ "assign", "conditional", "seq" ]) ||
@@ -5939,16 +6112,17 @@
                         return hash + "[" + make(subscript) + "]";
                 },
                 "object": function(props) {
+                        var obj_needs_parens = needs_parens(this);
                         if (props.length == 0)
-                                return "{}";
-                        return "{" + newline + with_indent(function(){
+                                return obj_needs_parens ? "({})" : "{}";
+                        var out = "{" + newline + with_indent(function(){
                                 return MAP(props, function(p){
                                         if (p.length == 3) {
                                                 // getter/setter.  The name is in p[0], the arg.list in p[1][2], the
                                                 // body in p[1][3] and type ("get" / "set") in p[2].
                                                 return indent(make_function(p[0], p[1][2], p[1][3], p[2]));
                                         }
-                                        var key = p[0], val = make(p[1]);
+                                        var key = p[0], val = parenthesize(p[1], "seq");
                                         if (options.quote_keys) {
                                                 key = encode_string(key);
                                         } else if ((typeof key == "number" || !beautify && +key + "" == key)
@@ -5962,14 +6136,15 @@
                                                                  : [ key + ":", val ]));
                                 }).join("," + newline);
                         }) + newline + indent("}");
+                        return obj_needs_parens ? "(" + out + ")" : out;
                 },
                 "regexp": function(rx, mods) {
                         return "/" + rx + "/" + mods;
                 },
                 "array": function(elements) {
                         if (elements.length == 0) return "[]";
-                        return add_spaces([ "[", add_commas(MAP(elements, function(el){
-                                if (!beautify && el[0] == "atom" && el[1] == "undefined") return "";
+                        return add_spaces([ "[", add_commas(MAP(elements, function(el, i){
+                                if (!beautify && el[0] == "atom" && el[1] == "undefined") return i === elements.length - 1 ? "," : "";
                                 return parenthesize(el, "seq");
                         })), "]" ]);
                 },
@@ -5988,7 +6163,7 @@
                 "atom": function(name) {
                         return make_name(name);
                 }
-        };
+        }, function(){ return make(ast) });
 
         // The squeezer replaces "block"-s that contain only a single
         // statement with the statement itself; technically, the AST
@@ -5998,12 +6173,13 @@
         // to the inner IF).  This function checks for this case and
         // adds the block brackets if needed.
         function make_then(th) {
+                if (th == null) return ";";
                 if (th[0] == "do") {
                         // https://github.com/mishoo/UglifyJS/issues/#issue/57
                         // IE croaks with "syntax error" on code like this:
                         //     if (foo) do ... while(cond); else ...
                         // we need block brackets around do/while
-                        return make([ "block", [ th ]]);
+                        return make_block([ th ]);
                 }
                 var b = th;
                 while (true) {
@@ -6030,20 +6206,31 @@
                 return add_spaces([ out, make_block(body) ]);
         };
 
+        function must_has_semicolon(node) {
+                switch (node[0]) {
+                    case "with":
+                    case "while":
+                        return empty(node[2]); // `with' or `while' with empty body?
+                    case "for":
+                    case "for-in":
+                        return empty(node[4]); // `for' with empty body?
+                    case "if":
+                        if (empty(node[2]) && !node[3]) return true; // `if' with empty `then' and no `else'
+                        if (node[3]) {
+                                if (empty(node[3])) return true; // `else' present but empty
+                                return must_has_semicolon(node[3]); // dive into the `else' branch
+                        }
+                        return must_has_semicolon(node[2]); // dive into the `then' branch
+                }
+        };
+
         function make_block_statements(statements, noindent) {
                 for (var a = [], last = statements.length - 1, i = 0; i <= last; ++i) {
                         var stat = statements[i];
                         var code = make(stat);
                         if (code != ";") {
-                                if (!beautify && i == last) {
-                                        if ((stat[0] == "while" && empty(stat[2])) ||
-                                            (member(stat[0], [ "for", "for-in"] ) && empty(stat[4])) ||
-                                            (stat[0] == "if" && empty(stat[2]) && !stat[3]) ||
-                                            (stat[0] == "if" && stat[3] && empty(stat[3]))) {
-                                                code = code.replace(/;*\s*$/, ";");
-                                        } else {
-                                                code = code.replace(/;+\s*$/, "");
-                                        }
+                                if (!beautify && i == last && !must_has_semicolon(stat)) {
+                                        code = code.replace(/;+\s*$/, "");
                                 }
                                 a.push(code);
                         }
@@ -6083,20 +6270,6 @@
                 return name;
         };
 
-        var $stack = [];
-
-        function make(node) {
-                var type = node[0];
-                var gen = generators[type];
-                if (!gen)
-                        throw new Error("Can't find generator for \"" + type + "\"");
-                $stack.push(node);
-                var ret = gen.apply(type, node.slice(1));
-                $stack.pop();
-                return ret;
-        };
-
-        return make(ast);
 };
 
 function split_lines(code, max_line_length) {
@@ -6181,16 +6354,34 @@
 
 (function(){
         MAP = function(a, f, o) {
-                var ret = [];
-                for (var i = 0; i < a.length; ++i) {
+                var ret = [], top = [], i;
+                function doit() {
                         var val = f.call(o, a[i], i);
-                        if (val instanceof AtTop) ret.unshift(val.v);
-                        else ret.push(val);
-                }
-                return ret;
+                        if (val instanceof AtTop) {
+                                val = val.v;
+                                if (val instanceof Splice) {
+                                        top.push.apply(top, val.v);
+                                } else {
+                                        top.push(val);
+                                }
+                        }
+                        else if (val != skip) {
+                                if (val instanceof Splice) {
+                                        ret.push.apply(ret, val.v);
+                                } else {
+                                        ret.push(val);
+                                }
+                        }
+                };
+                if (a instanceof Array) for (i = 0; i < a.length; ++i) doit();
+                else for (i in a) if (HOP(a, i)) doit();
+                return top.concat(ret);
         };
         MAP.at_top = function(val) { return new AtTop(val) };
+        MAP.splice = function(val) { return new Splice(val) };
+        var skip = MAP.skip = {};
         function AtTop(val) { this.v = val };
+        function Splice(val) { this.v = val };
 })();
 
 /* -----[ Exports ]----- */
@@ -6198,6 +6389,7 @@
 exports.ast_walker = ast_walker;
 exports.ast_mangle = ast_mangle;
 exports.ast_squeeze = ast_squeeze;
+exports.ast_lift_variables = ast_lift_variables;
 exports.gen_code = gen_code;
 exports.ast_add_scope = ast_add_scope;
 exports.set_logger = function(logger) { warn = logger };
@@ -6208,9 +6400,7 @@
 // keep this last!
 exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more;
 
-});
-define('uglifyjs/index', ["require", "exports", "module", "./parse-js", "./process"], function(require, exports, module) {
-
+});define('uglifyjs/index', ["require", "exports", "module", "./parse-js", "./process"], function(require, exports, module) {
 
 //convienence function(src, [options]);
 function uglify(orig_code, options){
@@ -6230,9 +6420,7 @@
 
 module.exports = uglify
 
-
-});
-/**
+});/**
  * @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
  * Available via the MIT or new BSD license.
  * see: http://github.com/jrburke/requirejs for details
@@ -6337,30 +6525,132 @@
     }
 
     /**
+     * Gets dependencies from a node, but only if it is an array literal,
+     * and only if the dependency is a string literal.
+     *
+     * This function does not need to worry about comments, they are not
+     * present in this AST.
+     *
+     * @param {Node} node an AST node.
+     *
+     * @returns {Array} of valid dependencies.
+     * If null is returned, then it means the input node was not a valid
+     * array literal, or did not have any string literals..
+     */
+    function getValidDeps(node) {
+        var newDeps = [],
+            arrayArgs, i, dep;
+
+        if (!node) {
+            return null;
+        }
+
+        if (isObjectLiteral(node) || node[0] === 'function') {
+            return null;
+        }
+
+        //Dependencies can be an object literal or an array.
+        if (!isArrayLiteral(node)) {
+            return null;
+        }
+
+        arrayArgs = node[1];
+
+        for (i = 0; i < arrayArgs.length; i++) {
+            dep = arrayArgs[i];
+            if (dep[0] === 'string') {
+                newDeps.push(dep[1]);
+            }
+        }
+        return newDeps.length ? newDeps : null;
+    }
+
+    /**
      * Main parse function. Returns a string of any valid require or define/require.def
      * calls as part of one JavaScript source string.
+     * @param {String} moduleName the module name that represents this file.
+     * It is used to create a default define if there is not one already for the file.
+     * This allows properly tracing dependencies for builds. Otherwise, if
+     * the file just has a require() call, the file dependencies will not be
+     * properly reflected: the file will come before its dependencies.
+     * @param {String} moduleName
      * @param {String} fileName
      * @param {String} fileContents
+     * @param {Object} options optional options. insertNeedsDefine: true will
+     * add calls to require.needsDefine() if appropriate.
      * @returns {String} JS source string or null, if no require or define/require.def
      * calls are found.
      */
-    function parse(fileName, fileContents) {
+    function parse(moduleName, fileName, fileContents, options) {
+        options = options || {};
+
         //Set up source input
-        var matches = [], result = null,
-            astRoot = parser.parse(fileContents);
-
-        parse.recurse(astRoot, function () {
-            var parsed = parse.callToString.apply(parse, arguments);
-            if (parsed) {
-                matches.push(parsed);
+        var moduleDeps = [],
+            result = '',
+            moduleList = [],
+            needsDefine = true,
+            astRoot = parser.parse(fileContents),
+            i, moduleCall, depString;
+
+        parse.recurse(astRoot, function (callName, config, name, deps) {
+            //If name is an array, it means it is an anonymous module,
+            //so adjust args appropriately. An anonymous module could
+            //have a FUNCTION as the name type, but just ignore those
+            //since we just want to find dependencies.
+            if (name && isArrayLiteral(name)) {
+                deps = name;
+                name = null;
+            }
+
+            if (!(deps = getValidDeps(deps))) {
+                deps = [];
+            }
+
+            //Get the name as a string literal, if it is available.
+            if (name && name[0] === 'string') {
+                name = name[1];
+            } else {
+                name = null;
+            }
+
+            if (callName === 'define' && (!name || name === moduleName)) {
+                needsDefine = false;
+            }
+
+            if (!name) {
+                //If there is no module name, the dependencies are for
+                //this file/default module name.
+                moduleDeps = moduleDeps.concat(deps);
+            } else {
+                moduleList.push({
+                    name: name,
+                    deps: deps
+                });
             }
         });
 
-        if (matches.length) {
-            result = matches.join("\n");
-        }
-
-        return result;
+        if (options.insertNeedsDefine && needsDefine) {
+            result += 'require.needsDefine("' + moduleName + '");';
+        }
+
+        if (moduleDeps.length || moduleList.length) {
+            for (i = 0; (moduleCall = moduleList[i]); i++) {
+                if (result) {
+                    result += '\n';
+                }
+                depString = moduleCall.deps.length ? '["' + moduleCall.deps.join('","') + '"]' : '[]';
+                result += 'define("' + moduleCall.name + '",' + depString + ');';
+            }
+            if (moduleDeps.length) {
+                if (result) {
+                    result += '\n';
+                }
+                depString = moduleDeps.length ? '["' + moduleDeps.join('","') + '"]' : '[]';
+                result += 'define("' + moduleName + '",' + depString + ');';
+            }
+        }
+
+        return result ? result : null;
     }
 
     //Add some private methods to object for use in derived objects.
@@ -6399,7 +6689,7 @@
 
     /**
      * Finds require("") calls inside a CommonJS anonymous module wrapped in a
-     * define/require.def(function(require, exports, module){}) wrapper. These dependencies
+     * define(function(require, exports, module){}) wrapper. These dependencies
      * will be added to a modified define() call that lists the dependencies
      * on the outside of the function.
      * @param {String} fileName
@@ -6409,7 +6699,7 @@
      */
     parse.getAnonDeps = function (fileName, fileContents) {
         var astRoot = parser.parse(fileContents),
-            defFunc = this.findAnonRequireDefCallback(astRoot);
+            defFunc = this.findAnonDefineFactory(astRoot);
 
         return parse.getAnonDepsFromNode(defFunc);
     };
@@ -6441,11 +6731,11 @@
     };
 
     /**
-     * Finds the function in require.def or define(function (require, exports, module){});
+     * Finds the function in define(function (require, exports, module){});
      * @param {Array} node
      * @returns {Boolean}
      */
-    parse.findAnonRequireDefCallback = function (node) {
+    parse.findAnonDefineFactory = function (node) {
         var callback, i, n, call, args;
 
         if (isArray(node)) {
@@ -6455,18 +6745,21 @@
                 if ((call[0] === 'name' && call[1] === 'define') ||
                            (call[0] === 'dot' && call[1][1] === 'require' && call[2] === 'def')) {
 
-                    //There should only be one argument and it should be a function.
+                    //There should only be one argument and it should be a function,
+                    //or a named module with function as second arg
                     if (args.length === 1 && args[0][0] === 'function') {
                         return args[0];
+                    } else if (args.length === 2 && args[0][0] === 'string' &&
+                               args[1][0] === 'function') {
+                        return args[1];
                     }
-
                 }
             }
 
             //Check child nodes
             for (i = 0; i < node.length; i++) {
                 n = node[i];
-                if ((callback = this.findAnonRequireDefCallback(n))) {
+                if ((callback = this.findAnonDefineFactory(n))) {
                     return callback;
                 }
             }
@@ -6489,8 +6782,7 @@
         //calls. Can revisit later, but trying to build out larger functional
         //pieces first.
         var dependencies = parse.getAnonDeps(fileName, fileContents),
-            astRoot = parser.parse(fileContents),
-            i, dep;
+            astRoot = parser.parse(fileContents);
 
         parse.recurse(astRoot, function (callName, config, name, deps) {
             //Normalize the input args.
@@ -6499,12 +6791,8 @@
                 name = null;
             }
 
-            if (!(deps = validateDeps(deps)) || !isArrayLiteral(deps)) {
-                return;
-            }
-
-            for (i = 0; (dep = deps[1][i]); i++) {
-                dependencies.push(dep[1]);
+            if ((deps = getValidDeps(deps))) {
+                dependencies = dependencies.concat(deps);
             }
         });
 
@@ -6519,7 +6807,7 @@
                 call = node[1];
                 args = node[2];
 
-                if (call[0] === 'name' && call[1] === 'require') {
+                if (call && call[0] === 'name' && call[1] === 'require') {
                     moduleName = args[0];
                     if (moduleName[0] === 'string') {
                         deps.push(moduleName[1]);
@@ -6583,50 +6871,6 @@
         return false;
     };
 
-    function optionalString(node) {
-        var str = null;
-        if (node) {
-            str = parse.nodeToString(node);
-        }
-        return str;
-    }
-
-    /**
-     * Convert a require/require.def/define call to a string if it is a valid
-     * call via static analysis of dependencies.
-     * @param {String} callName the name of call (require or define)
-     * @param {Array} the config node inside the call
-     * @param {Array} the name node inside the call
-     * @param {Array} the deps node inside the call
-     */
-    parse.callToString = function (callName, config, name, deps) {
-        //If name is an array, it means it is an anonymous module,
-        //so adjust args appropriately. An anonymous module could
-        //have a FUNCTION as the name type, but just ignore those
-        //since we just want to find dependencies.
-        var configString, nameString, depString;
-        if (name && isArrayLiteral(name)) {
-            deps = name;
-            name = null;
-        }
-
-        if (!(deps = validateDeps(deps))) {
-            return null;
-        }
-
-        //Only serialize the call name, config, module name and dependencies,
-        //otherwise could get local variable names for module value.
-        configString = config && isObjectLiteral(config) && optionalString(config);
-        nameString = optionalString(name);
-        depString = optionalString(deps);
-
-        return callName + "(" +
-            (configString ? configString : "") +
-            (nameString ? (configString ? "," : "") + nameString : "") +
-            (depString ? (configString || nameString ? "," : "") + depString : "") +
-            ");";
-    };
-
     /**
      * Determines if a specific node is a valid require or define/require.def call.
      * @param {Array} node
@@ -6665,11 +6909,9 @@
 
                     return onMatch("require", null, null, deps);
 
-                } else if ((call[0] === 'name' && call[1] === 'define') ||
-                           (call[0] === 'dot' && call[1][1] === 'require' &&
-                            call[2] === 'def')) {
-
-                    //A define or require.def call
+                } else if (call[0] === 'name' && call[1] === 'define') {
+
+                    //A define call
                     name = args[0];
                     deps = args[1];
                     //Only allow define calls that match what is expected
@@ -6685,14 +6927,22 @@
                     if (((name[0] === 'string' || isArrayLiteral(name) ||
                           name[0] === 'function' || isObjectLiteral(name))) &&
                         (!deps || isArrayLiteral(deps) ||
-                         deps[0] === 'function' || isObjectLiteral(deps))) {
+                         deps[0] === 'function' || isObjectLiteral(deps) ||
+                         // allow define(['dep'], factory) pattern
+                         (isArrayLiteral(name) && deps[0] === 'name' && args.length === 2))) {
 
                         //If first arg is a function, could be a commonjs wrapper,
                         //look inside for commonjs dependencies.
+                        //Also, if deps is a function look for commonjs deps.
                         if (name && name[0] === 'function') {
                             cjsDeps = parse.getAnonDepsFromNode(name);
                             if (cjsDeps.length) {
                                 name = toAstArray(cjsDeps);
+                            }
+                        } else if (deps && deps[0] === 'function') {
+                            cjsDeps = parse.getAnonDepsFromNode(deps);
+                            if (cjsDeps.length) {
+                                deps = toAstArray(cjsDeps);
                             }
                         }
 
@@ -6723,10 +6973,10 @@
  * see: http://github.com/jrburke/requirejs for details
  */
 
-/*jslint regexp: false, strict: false  */
+/*jslint regexp: false, strict: false, plusplus: false  */
 /*global define: false */
 
-define('pragma', function () {
+define('pragma', ['parse', 'logger'], function (parse, logger) {
 
     function Temp() {}
 
@@ -6751,9 +7001,13 @@
     var pragma = {
         conditionalRegExp: /(exclude|include)Start\s*\(\s*["'](\w+)["']\s*,(.*)\)/,
         useStrictRegExp: /['"]use strict['"];/g,
-        hasRegExp: /has\s*\(\s*['"]([^'"]+)['"]\)/g,
+        hasRegExp: /has\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
         nsRegExp: /(^|[^\.])(requirejs|require|define)\s*\(/,
+        nsWrapRegExp: /\/\*requirejs namespace: true \*\//,
         apiDefRegExp: /var requirejs, require, define;/,
+        defineCheckRegExp: /typeof\s+define\s*===\s*["']function["']\s*&&\s*define\s*\.\s*amd/g,
+        defineJQueryRegExp: /typeof\s+define\s*===\s*["']function["']\s*&&\s*define\s*\.\s*amd\s*&&\s*define\s*\.\s*amd\s*\.\s*jQuery/g,
+        defineTernaryRegExp: /typeof\s+define\s*===\s*['"]function["']\s*&&\s*define\s*\.\s*amd\s*\?\s*define/,
 
         removeStrict: function (contents, config) {
             return config.useStrict ? contents : contents.replace(pragma.useStrictRegExp, '');
@@ -6763,6 +7017,21 @@
             if (ns) {
                 //Namespace require/define calls
                 fileContents = fileContents.replace(pragma.nsRegExp, '$1' + ns + '.$2(');
+
+
+                //Namespace define ternary use:
+                fileContents = fileContents.replace(pragma.defineTernaryRegExp,
+                                                    "typeof " + ns + ".define === 'function' && " + ns + ".define.amd ? " + ns + ".define");
+
+                //Namespace define jquery use:
+                fileContents = fileContents.replace(pragma.defineJQueryRegExp,
+                                                    "typeof " + ns + ".define === 'function' && " + ns + ".define.amd && " + ns + ".define.jQuery");
+
+                //Namespace define checks.
+                //Do this one last, since it is a subset of the more specific
+                //checks above.
+                fileContents = fileContents.replace(pragma.defineCheckRegExp,
+                                                    "typeof " + ns + ".define === 'function' && " + ns + ".define.amd");
 
                 //Check for require.js with the require/define definitions
                 if (pragma.apiDefRegExp.test(fileContents) &&
@@ -6773,11 +7042,27 @@
                                     ns + " === 'undefined') {\n" +
                                     ns + ' = {};\n' +
                                     fileContents +
-                                    "\n}\n" +
+                                    "\n" +
                                     ns + ".requirejs = requirejs;" +
                                     ns + ".require = require;" +
                                     ns + ".define = define;\n" +
-                                    "}());";
+                                    "}\n}());";
+                }
+
+                //Finally, if the file wants a special wrapper because it ties
+                //in to the requirejs internals in a way that would not fit
+                //the above matches, do that. Look for /*requirejs namespace: true*/
+                if (pragma.nsWrapRegExp.test(fileContents)) {
+                    //Remove the pragma.
+                    fileContents = fileContents.replace(pragma.nsWrapRegExp, '');
+
+                    //Alter the contents.
+                    fileContents = '(function () {\n' +
+                                   'var require = ' + ns + '.require,' +
+                                   'requirejs = ' + ns + '.requirejs,' +
+                                   'define = ' + ns + '.define;\n' +
+                                   fileContents +
+                                   '\n}());'
                 }
             }
 
@@ -6787,11 +7072,12 @@
         /**
          * processes the fileContents for some //>> conditional statements
          */
-        process: function (fileName, fileContents, config, onLifecycleName) {
+        process: function (fileName, fileContents, config, onLifecycleName, pluginCollector) {
             /*jslint evil: true */
             var foundIndex = -1, startIndex = 0, lineEndIndex, conditionLine,
                 matches, type, marker, condition, isTrue, endRegExp, endMatches,
-                endMarkerIndex, shouldInclude, startLength, lifecycleHas,
+                endMarkerIndex, shouldInclude, startLength, lifecycleHas, deps,
+                i, dep, moduleName,
                 lifecyclePragmas, pragmas = config.pragmas, hasConfig = config.has,
                 //Legacy arg defined to help in dojo conversion script. Remove later
                 //when dojo no longer needs conversion:
@@ -6824,79 +7110,99 @@
                 });
             }
 
+            if (!config.skipPragmas) {
+
+                while ((foundIndex = fileContents.indexOf("//>>", startIndex)) !== -1) {
+                    //Found a conditional. Get the conditional line.
+                    lineEndIndex = fileContents.indexOf("\n", foundIndex);
+                    if (lineEndIndex === -1) {
+                        lineEndIndex = fileContents.length - 1;
+                    }
+
+                    //Increment startIndex past the line so the next conditional search can be done.
+                    startIndex = lineEndIndex + 1;
+
+                    //Break apart the conditional.
+                    conditionLine = fileContents.substring(foundIndex, lineEndIndex + 1);
+                    matches = conditionLine.match(pragma.conditionalRegExp);
+                    if (matches) {
+                        type = matches[1];
+                        marker = matches[2];
+                        condition = matches[3];
+                        isTrue = false;
+                        //See if the condition is true.
+                        try {
+                            isTrue = !!eval("(" + condition + ")");
+                        } catch (e) {
+                            throw "Error in file: " +
+                                   fileName +
+                                   ". Conditional comment: " +
+                                   conditionLine +
+                                   " failed with this error: " + e;
+                        }
+
+                        //Find the endpoint marker.
+                        endRegExp = new RegExp('\\/\\/\\>\\>\\s*' + type + 'End\\(\\s*[\'"]' + marker + '[\'"]\\s*\\)', "g");
+                        endMatches = endRegExp.exec(fileContents.substring(startIndex, fileContents.length));
+                        if (endMatches) {
+                            endMarkerIndex = startIndex + endRegExp.lastIndex - endMatches[0].length;
+
+                            //Find the next line return based on the match position.
+                            lineEndIndex = fileContents.indexOf("\n", endMarkerIndex);
+                            if (lineEndIndex === -1) {
+                                lineEndIndex = fileContents.length - 1;
+                            }
+
+                            //Should we include the segment?
+                            shouldInclude = ((type === "exclude" && !isTrue) || (type === "include" && isTrue));
+
+                            //Remove the conditional comments, and optionally remove the content inside
+                            //the conditional comments.
+                            startLength = startIndex - foundIndex;
+                            fileContents = fileContents.substring(0, foundIndex) +
+                                (shouldInclude ? fileContents.substring(startIndex, endMarkerIndex) : "") +
+                                fileContents.substring(lineEndIndex + 1, fileContents.length);
+
+                            //Move startIndex to foundIndex, since that is the new position in the file
+                            //where we need to look for more conditionals in the next while loop pass.
+                            startIndex = foundIndex;
+                        } else {
+                            throw "Error in file: " +
+                                  fileName +
+                                  ". Cannot find end marker for conditional comment: " +
+                                  conditionLine;
+
+                        }
+                    }
+                }
+            }
+
+            //If need to find all plugin resources to optimize, do that now,
+            //before namespacing, since the namespacing will change the API
+            //names.
+            //If there is a plugin collector, scan the file for plugin resources.
+            if (config.optimizeAllPluginResources && pluginCollector) {
+                try {
+                    deps = parse.findDependencies(fileName, fileContents);
+                    if (deps.length) {
+                        for (i = 0; (dep = deps[i]); i++) {
+                            if (dep.indexOf('!') !== -1) {
+                                (pluginCollector[moduleName] ||
+                                 (pluginCollector[moduleName] = [])).push(dep);
+                            }
+                        }
+                    }
+                } catch (eDep) {
+                    logger.error('Parse error looking for plugin resources in ' +
+                                 fileName + ', skipping.');
+                }
+            }
+
             //Do namespacing
             if (onLifecycleName === 'OnSave' && config.namespace) {
                 fileContents = pragma.namespace(fileContents, config.namespace, onLifecycleName);
             }
 
-            //If pragma work is not desired, skip it.
-            if (config.skipPragmas) {
-                return pragma.removeStrict(fileContents, config);
-            }
-
-            while ((foundIndex = fileContents.indexOf("//>>", startIndex)) !== -1) {
-                //Found a conditional. Get the conditional line.
-                lineEndIndex = fileContents.indexOf("\n", foundIndex);
-                if (lineEndIndex === -1) {
-                    lineEndIndex = fileContents.length - 1;
-                }
-
-                //Increment startIndex past the line so the next conditional search can be done.
-                startIndex = lineEndIndex + 1;
-
-                //Break apart the conditional.
-                conditionLine = fileContents.substring(foundIndex, lineEndIndex + 1);
-                matches = conditionLine.match(pragma.conditionalRegExp);
-                if (matches) {
-                    type = matches[1];
-                    marker = matches[2];
-                    condition = matches[3];
-                    isTrue = false;
-                    //See if the condition is true.
-                    try {
-                        isTrue = !!eval("(" + condition + ")");
-                    } catch (e) {
-                        throw "Error in file: " +
-                               fileName +
-                               ". Conditional comment: " +
-                               conditionLine +
-                               " failed with this error: " + e;
-                    }
-
-                    //Find the endpoint marker.
-                    endRegExp = new RegExp('\\/\\/\\>\\>\\s*' + type + 'End\\(\\s*[\'"]' + marker + '[\'"]\\s*\\)', "g");
-                    endMatches = endRegExp.exec(fileContents.substring(startIndex, fileContents.length));
-                    if (endMatches) {
-                        endMarkerIndex = startIndex + endRegExp.lastIndex - endMatches[0].length;
-
-                        //Find the next line return based on the match position.
-                        lineEndIndex = fileContents.indexOf("\n", endMarkerIndex);
-                        if (lineEndIndex === -1) {
-                            lineEndIndex = fileContents.length - 1;
-                        }
-
-                        //Should we include the segment?
-                        shouldInclude = ((type === "exclude" && !isTrue) || (type === "include" && isTrue));
-
-                        //Remove the conditional comments, and optionally remove the content inside
-                        //the conditional comments.
-                        startLength = startIndex - foundIndex;
-                        fileContents = fileContents.substring(0, foundIndex) +
-                            (shouldInclude ? fileContents.substring(startIndex, endMarkerIndex) : "") +
-                            fileContents.substring(lineEndIndex + 1, fileContents.length);
-
-                        //Move startIndex to foundIndex, since that is the new position in the file
-                        //where we need to look for more conditionals in the next while loop pass.
-                        startIndex = foundIndex;
-                    } else {
-                        throw "Error in file: " +
-                              fileName +
-                              ". Cannot find end marker for conditional comment: " +
-                              conditionLine;
-
-                    }
-                }
-            }
 
             return pragma.removeStrict(fileContents, config);
         }
@@ -7150,6 +7456,8 @@
     }
 
     optimize = {
+        licenseCommentRegExp: /\/\*[\s\S]*?\*\//g,
+
         /**
          * Optimizes a file that contains JavaScript content. Optionally collects
          * plugin resources mentioned in a file, and then passes the content
@@ -7168,30 +7476,13 @@
             var parts = (config.optimize + "").split('.'),
                 optimizerName = parts[0],
                 keepLines = parts[1] === 'keepLines',
-                fileContents, optFunc, deps, i, dep;
+                licenseContents = '',
+                fileContents, optFunc, match, comment;
 
             fileContents = file.readFile(fileName);
 
             //Apply pragmas/namespace renaming
-            fileContents = pragma.process(fileName, fileContents, config, 'OnSave');
-
-            //If there is a plugin collector, scan the file for plugin resources.
-            if (config.optimizeAllPluginResources && pluginCollector) {
-                try {
-                    deps = parse.findDependencies(fileName, fileContents);
-                    if (deps.length) {
-                        for (i = 0; (dep = deps[i]); i++) {
-                            if (dep.indexOf('!') !== -1) {
-                                (pluginCollector[moduleName] ||
-                                 (pluginCollector[moduleName] = [])).push(dep);
-                            }
-                        }
-                    }
-                } catch (e) {
-                    logger.error('Parse error looking for plugin resources in ' +
-                                 fileName + ', skipping.');
-                }
-            }
+            fileContents = pragma.process(fileName, fileContents, config, 'OnSave', pluginCollector);
 
             //Optimize the JS files if asked.
             if (optimizerName && optimizerName !== 'none') {
@@ -7201,7 +7492,19 @@
                                     optimizerName +
                                     '" not found for this environment');
                 }
-                fileContents = optFunc(fileName, fileContents, keepLines,
+
+                //Pull out any license comments for prepending after optimization.
+                optimize.licenseCommentRegExp.lastIndex = 0;
+                while ((match = optimize.licenseCommentRegExp.exec(fileContents))) {
+                    comment = match[0];
+                    //Only keep the comments if they are license comments.
+                    if (comment.indexOf('@license') !== -1 ||
+                        comment.indexOf('/*!') === 0) {
+                        licenseContents += comment + '\n';
+                    }
+                }
+
+                fileContents = licenseContents + optFunc(fileName, fileContents, keepLines,
                                         config[optimizerName]);
             }
 
@@ -7330,6 +7633,30 @@
             oldDef,
             cachedFileContents = {};
 
+
+        /** Print out some extrs info about the module tree that caused the error. **/
+        require.onError = function (err) {
+
+            var msg = '\nIn module tree:\n',
+                standardIndent = '  ',
+                tree = err.moduleTree,
+                i, j, mod;
+
+            if (tree && tree.length > 0) {
+                for (i = tree.length - 1; i > -1 && (mod = tree[i]); i--) {
+                    for (j = tree.length - i; j > -1; j--) {
+                        msg += standardIndent;
+                    }
+                    msg += mod + '\n';
+                }
+
+                err = new Error(err.toString() + msg);
+            }
+
+            throw err;
+        };
+
+
         /** Reset state for each build layer pass. */
         require._buildReset = function () {
             var oldContext = require.s.contexts._;
@@ -7344,15 +7671,12 @@
                 buildPathMap: {},
                 buildFileToModule: {},
                 buildFilePaths: [],
-                loadedFiles: {},
+                pathAdded: {},
                 modulesWithNames: {},
+                needsDefine: {},
                 existingRequireUrl: "",
                 context: require.s.contexts._
             };
-
-            //Set up a per-context list of plugins/pluginBuilders.
-            layer.context.pluginBuilders = {};
-            layer.context._plugins = {};
 
             //Return the previous context in case it is needed, like for
             //the basic config object.
@@ -7377,26 +7701,36 @@
                    url.indexOf('empty:') !== 0;
         };
 
-        //Override require.def to catch modules that just define an object, so that
-        //a dummy require.def call is not put in the build file for them. They do
+        //Override define() to catch modules that just define an object, so that
+        //a dummy define call is not put in the build file for them. They do
         //not end up getting defined via require.execCb, so we need to catch them
-        //at the require.def call.
-        oldDef = require.def;
+        //at the define call.
+        oldDef = define;
 
         //This function signature does not have to be exact, just match what we
         //are looking for.
-        define = require.def = function (name, obj) {
-            if (typeof name === "string") {
+        define = function (name, obj) {
+            if (typeof name === "string" && !layer.needsDefine[name]) {
                 layer.modulesWithNames[name] = true;
             }
             return oldDef.apply(require, arguments);
         };
 
-        //Add some utilities for plugins/pluginBuilders
+        define.amd = oldDef.amd;
+
+        //Add some utilities for plugins
         require._readFile = file.readFile;
         require._fileExists = function (path) {
             return file.exists(path);
         };
+
+        function normalizeUrlWithBase(context, moduleName, url) {
+            //Adjust the URL if it was not transformed to use baseUrl.
+            if (require.jsExtRegExp.test(moduleName)) {
+                url = (context.config.dir || context.config.dirBaseUrl) + url;
+            }
+            return url;
+        }
 
         //Override load so that the file paths can be collected.
         require.load = function (context, moduleName, url) {
@@ -7404,11 +7738,8 @@
             var contents, pluginBuilderMatch, builderName;
 
             //Adjust the URL if it was not transformed to use baseUrl.
-            if (require.jsExtRegExp.test(moduleName)) {
-                url = context.config.dirBaseUrl + url;
-            }
-
-            context.loaded[moduleName] = false;
+            url = normalizeUrlWithBase(context, moduleName, url);
+
             context.scriptCount += 1;
 
             //Only handle urls that can be inlined, so that means avoiding some
@@ -7421,11 +7752,12 @@
 
                 if (moduleName in context.plugins) {
                     //plugins need to have their source evaled as-is.
-                    context._plugins[moduleName] = true;
+                    context.needFullExec[moduleName] = true;
                 }
 
                 try {
-                    if (url in cachedFileContents) {
+                    if (url in cachedFileContents &&
+                        (!context.needFullExec[moduleName] || context.fullExec[moduleName])) {
                         contents = cachedFileContents[url];
                     } else {
                         //Load the file contents, process for conditionals, then
@@ -7435,7 +7767,7 @@
 
                         //Find out if the file contains a require() definition. Need to know
                         //this so we can inject plugins right after it, but before they are needed,
-                        //and to make sure this file is first, so that require.def calls work.
+                        //and to make sure this file is first, so that define calls work.
                         //This situation mainly occurs when the build is done on top of the output
                         //of another build, where the first build may include require somewhere in it.
                         if (!layer.existingRequireUrl && parse.definesRequire(url, contents)) {
@@ -7456,8 +7788,10 @@
                         //Parse out the require and define calls.
                         //Do this even for plugins in case they have their own
                         //dependencies that may be separate to how the pluginBuilder works.
-                        if (!context._plugins[moduleName]) {
-                            contents = parse(url, contents);
+                        if (!context.needFullExec[moduleName]) {
+                            contents = parse(moduleName, url, contents, {
+                                insertNeedsDefine: true
+                            });
                         }
 
                         cachedFileContents[url] = contents;
@@ -7465,53 +7799,86 @@
 
                     if (contents) {
                         eval(contents);
-
-                        //Support anonymous modules.
+                    }
+
+                    //Need to close out completion of this module
+                    //so that listeners will get notified that it is available.
+                    try {
                         context.completeLoad(moduleName);
+                    } catch (e) {
+                        //Track which module could not complete loading.
+                        (e.moduleTree || (e.moduleTree = [])).push(moduleName);
+                        throw e;
                     }
 
-                } catch (e) {
-                    e.fileName = url;
-                    e.lineNumber = e.line;
-                    throw e;
-                }
-
-                // remember the list of dependencies for this layer.
-                layer.buildFilePaths.push(url);
+                } catch (eOuter) {
+                    if (!eOuter.fileName) {
+                        eOuter.fileName = url;
+                    }
+                    throw eOuter;
+                }
+            } else {
+                //With unsupported URLs still need to call completeLoad to
+                //finish loading.
+                context.completeLoad(moduleName);
             }
 
             //Mark the module loaded.
             context.loaded[moduleName] = true;
-
-            //Get a handle on the pluginBuilder
-            if (context._plugins[moduleName]) {
-                context.pluginBuilders[moduleName] = context.defined[moduleName];
-            }
-        };
-
-        //This method is called when a plugin specifies a loaded value. Use
-        //this to track dependencies that do not go through require.load.
-        require.onPluginLoad = function (context, pluginName, name, value) {
-            var registeredName = pluginName + '!' + (name || '');
-            layer.buildFilePaths.push(registeredName);
-            //For plugins the real path is not knowable, use the name
-            //for both module to file and file to module mappings.
-            layer.buildPathMap[registeredName] = registeredName;
-            layer.buildFileToModule[registeredName] = registeredName;
-            layer.modulesWithNames[registeredName] = true;
-        };
-
-        //Marks the module as part of the loaded set, and puts
-        //it in the right position for output in the build layer,
-        //since require() already did the dependency checks and should have
-        //called this method already for those dependencies.
+        };
+
+
+        //Called when execManager runs for a dependency. Used to figure out
+        //what order of execution.
+        require.onResourceLoad = function (context, map) {
+            var fullName = map.fullName,
+                url;
+
+            //Ignore "fake" modules, usually generated by plugin code, since
+            //they do not map back to a real file to include in the optimizer,
+            //or it will be included, but in a different form.
+            if (context.fake[fullName]) {
+                return;
+            }
+
+            //A plugin.
+            if (map.prefix) {
+                if (!layer.pathAdded[fullName]) {
+                    layer.buildFilePaths.push(fullName);
+                    //For plugins the real path is not knowable, use the name
+                    //for both module to file and file to module mappings.
+                    layer.buildPathMap[fullName] = fullName;
+                    layer.buildFileToModule[fullName] = fullName;
+                    layer.modulesWithNames[fullName] = true;
+                    layer.pathAdded[fullName] = true;
+                }
+            } else if (map.url && require._isSupportedBuildUrl(map.url)) {
+                //If the url has not been added to the layer yet, and it
+                //is from an actual file that was loaded, add it now.
+                if (!layer.pathAdded[url] && layer.buildPathMap[fullName]) {
+                    url = normalizeUrlWithBase(context, map.fullName, map.url);
+                    //Remember the list of dependencies for this layer.
+                    layer.buildFilePaths.push(url);
+                    layer.pathAdded[url] = true;
+                }
+            }
+        };
+
+        //Called by output of the parse() function, when a file does not
+        //explicitly call define, probably just require, but the parse()
+        //function normalizes on define() for dependency mapping and file
+        //ordering works correctly.
+        require.needsDefine = function (moduleName) {
+            layer.needsDefine[moduleName] = true;
+        };
+
+        //Marks module has having a name, and optionally executes the
+        //callback, but only if it meets certain criteria.
         require.execCb = function (name, cb, args, exports) {
-            var url = name && layer.buildPathMap[name];
-            if (url && !layer.loadedFiles[url]) {
-                layer.loadedFiles[url] = true;
+            if (!layer.needsDefine[name]) {
                 layer.modulesWithNames[name] = true;
             }
-            if (cb.__requireJsBuild || layer.context._plugins[name]) {
+            if (cb.__requireJsBuild || layer.context.needFullExec[name]) {
                 return cb.apply(exports, args);
             }
             return undefined;
@@ -7604,7 +7971,7 @@
          * Regexp for testing if there is already a require.def call in the file,
          * in which case do not try to convert it.
          */
-        defRegExp: /(require\s*\.\s*def|define)\s*\(/,
+        defRegExp: /define\s*\(\s*("|'|\[|function)/,
 
         /**
          * Regexp for testing if there is a require([]) or require(function(){})
@@ -7684,7 +8051,8 @@
          'env!env/load', 'requirePatch'],
 function (lang,   logger,   file,          parse,    optimize,   pragma,
           load,           requirePatch) {
-    var build, buildBaseConfig;
+    var build, buildBaseConfig,
+        endsWithSemiColonRegExp = /;\s*$/;
 
     buildBaseConfig = {
             appDir: "",
@@ -7694,8 +8062,24 @@
             optimizeCss: "standard.keepLines",
             inlineText: true,
             isBuild: true,
-            optimizeAllPluginResources: false
-        };
+            optimizeAllPluginResources: false,
+            //By default, all files/directories are copied, unless
+            //they match this regexp, by default just excludes .folders
+            dirExclusionRegExp: file.dirExclusionRegExp
+        };
+
+    /**
+     * Some JS may not be valid if concatenated with other JS, in particular
+     * the style of omitting semicolons and rely on ASI. Add a semicolon in
+     * those cases.
+     */
+    function addSemiColon(text) {
+        if (endsWithSemiColonRegExp.test(text)) {
+            return text;
+        } else {
+            return text + ";";
+        }
+    }
 
     /**
      * If the path looks like an URL, throw an error. This is to prevent
@@ -7708,7 +8092,8 @@
             throw new Error('Path is not supported: ' + path +
                             '\nOptimizer can only handle' +
                             ' local paths. Download the locally if necessary' +
-                            ' and update the config to use a local path.');
+                            ' and update the config to use a local path.\n' +
+                            'http://requirejs.org/docs/errors.html#pathnotsupported');
         }
     }
 
@@ -7722,9 +8107,18 @@
 
     //Method used by plugin writeFile calls, defined up here to avoid
     //jslint warning about "making a function in a loop".
-    function writeFile(name, contents) {
-        logger.trace('Saving plugin-optimized file: ' + name);
-        file.saveUtf8File(name, contents);
+    function makeWriteFile(anonDefRegExp, namespaceWithDot, layer) {
+        function writeFile(name, contents) {
+            logger.trace('Saving plugin-optimized file: ' + name);
+            file.saveUtf8File(name, contents);
+        }
+
+        writeFile.asModule = function (moduleName, fileName, contents) {
+            writeFile(fileName,
+                build.toTransport(anonDefRegExp, namespaceWithDot, moduleName, fileName, contents, layer));
+        };
+
+        return writeFile;
     }
 
     /**
@@ -7902,7 +8296,7 @@
         //Run CSS optimizations before doing JS module tracing, to allow
         //things like text loader plugins loading CSS to get the optimized
         //CSS.
-        if (config.optimizeCss && config.optimizeCss !== "none") {
+        if (config.optimizeCss && config.optimizeCss !== "none" && config.dir) {
             optimize.css(config.dir, config);
         }
 
@@ -8019,7 +8413,10 @@
                                     moduleMap.prefix,
                                     moduleMap.name,
                                     require,
-                                    writeFile,
+                                    makeWriteFile(
+                                        config.anonDefRegExp,
+                                        config.namespaceWithDot
+                                    ),
                                     context.config
                                 );
                             }
@@ -8051,6 +8448,20 @@
 
         return '';
     };
+
+    /**
+     * Converts command line args like "paths.foo=../some/path"
+     * result.paths = { foo: '../some/path' } where prop = paths,
+     * name = paths.foo and value = ../some/path, so it assumes the
+     * name=value splitting has already happened.
+     */
+    function stringDotToObj(result, prop, name, value) {
+        if (!result[prop]) {
+            result[prop] = {};
+        }
+        name = name.substring((prop + '.').length, name.length);
+        result[prop][name] = value;
+    }
 
     /**
      * Converts an array that has String members of "name=value"
@@ -8088,14 +8499,8 @@
                 value = value.split(",");
             }
 
-            if (prop.indexOf("paths.") === 0) {
-                //Special handling of paths properties. paths.foo=bar is transformed
-                //to data.paths = {foo: 'bar'}
-                if (!result.paths) {
-                    result.paths = {};
-                }
-                prop = prop.substring("paths.".length, prop.length);
-                result.paths[prop] = value;
+            if (prop.indexOf("paths.") === 0 || prop.indexOf("wrap.") === 0) {
+                stringDotToObj(result, prop.split('.')[0], prop, value);
             } else {
                 result[prop] = value;
             }
@@ -8134,6 +8539,8 @@
         lang.mixin(config, buildBaseConfig);
         lang.mixin(config, cfg, true);
 
+        absFilePath = file.absPath('.');
+
         if (config.buildFile) {
             //A build file exists, load it to get more config.
             buildFile = file.absPath(config.buildFile);
@@ -8159,22 +8566,16 @@
             //Re-apply the override config values, things like command line
             //args should take precedence over build file values.
             lang.mixin(config, cfg, true);
-        } else {
-            if (!config.out && !config.cssIn) {
-                throw new Error("ERROR: 'out' or 'cssIn' option missing.");
-            }
+        } else if (config.cssIn) {
             if (!config.out) {
                 throw new Error("ERROR: 'out' option missing.");
             } else {
                 config.out = config.out.replace(lang.backSlashRegExp, "/");
             }
-
-            if (!config.cssIn && !cfg.baseUrl) {
-                throw new Error("ERROR: 'baseUrl' option missing.");
-            }
-
-            //In this scenario, the absFile path is current directory
-            absFilePath = file.absPath('.');
+        }
+
+        if (!config.cssIn && !config.baseUrl) {
+            throw new Error("ERROR: 'baseUrl' option missing.");
         }
 
         if (config.out && !config.cssIn) {
@@ -8254,11 +8655,48 @@
             }
         }
 
+        //Get any wrap text.
+        try {
+            if (config.wrap) {
+                if (config.wrap === true) {
+                    //Use default values.
+                    config.wrap = {
+                        start: '(function () {',
+                        end: '}());'
+                    };
+                } else {
+                    config.wrap.start = config.wrap.start ||
+                            file.readFile(build.makeAbsPath(config.wrap.startFile, absFilePath));
+                    config.wrap.end = config.wrap.end ||
+                            file.readFile(build.makeAbsPath(config.wrap.endFile, absFilePath));
+                }
+            }
+        } catch (wrapError) {
+            throw new Error('Malformed wrap config: need both start/end or ' +
+                            'startFile/endFile: ' + wrapError.toString());
+        }
+
+
+        //Set up proper info for namespaces and using namespaces in transport
+        //wrappings.
+        config.namespaceWithDot = config.namespace ? config.namespace + '.' : '';
+        config.anonDefRegExp = build.makeAnonDefRegExp(config.namespaceWithDot);
+
         //Do final input verification
         if (config.context) {
             throw new Error('The build argument "context" is not supported' +
                             ' in a build. It should only be used in web' +
                             ' pages.');
+        }
+
+        //Set file.fileExclusionRegExp if desired
+        if ('fileExclusionRegExp' in config) {
+            file.exclusionRegExp = config.fileExclusionRegExp;
+        } else if ('dirExclusionRegExp' in config) {
+            //Set file.dirExclusionRegExp if desired, this is the old
+            //name for fileExclusionRegExp before 1.0.2. Support for backwards
+            //compatibility
+            file.exclusionRegExp = config.dirExclusionRegExp;
         }
 
         return config;
@@ -8373,6 +8811,7 @@
         var buildFileContents = "",
             namespace = config.namespace ? config.namespace + '.' : '',
             context = layer.context,
+            anonDefRegExp = config.anonDefRegExp,
             path, reqIndex, fileContents, currContents,
             i, moduleName,
             parts, builder, writeApi;
@@ -8405,14 +8844,16 @@
             //Figure out if the module is a result of a build plugin, and if so,
             //then delegate to that plugin.
             parts = context.makeModuleMap(moduleName);
-            builder = parts.prefix && context.pluginBuilders[parts.prefix];
+            builder = parts.prefix && context.defined[parts.prefix];
             if (builder) {
                 if (builder.write) {
                     writeApi = function (input) {
-                        fileContents += input;
+                        fileContents += "\n" + addSemiColon(input);
                     };
                     writeApi.asModule = function (moduleName, input) {
-                        fileContents += "\n" + build.toTransport(namespace, moduleName, path, input, layer);
+                        fileContents += "\n" +
+                                        addSemiColon(
+                                            build.toTransport(anonDefRegExp, namespace, moduleName, path, input, layer));
                     };
                     builder.write(parts.prefix, parts.name, writeApi);
                 }
@@ -8423,9 +8864,11 @@
                     currContents = pragma.namespace(currContents, config.namespace);
                 }
 
-                currContents = build.toTransport(namespace, moduleName, path, currContents, layer);
-
-                fileContents += "\n" + currContents;
+                currContents = build.toTransport(anonDefRegExp, namespace, moduleName, path, currContents, layer);
+
+                //Semicolon is for files that are not well formed when
+                //concatenated with other content.
+                fileContents += "\n" + addSemiColon(currContents);
             }
 
             buildFileContents += path.replace(config.dir, "") + "\n";
@@ -8451,26 +8894,53 @@
         }
 
         return {
-            text: fileContents,
+            text: config.wrap ?
+                    config.wrap.start + fileContents + config.wrap.end :
+                    fileContents,
             buildText: buildFileContents
         };
     };
 
-    //This regexp is not bullet-proof, and it has one optional part to
-    //avoid issues with some Dojo transition modules that use a
-    //define(\n//begin v1.x content
-    //for a comment.
-    build.anonDefRegExp = /(^|[^\.])(require\s*\.\s*def|define)\s*\(\s*(\/\/[^\n\r]*[\r\n])?(\[|f|\{)/;
-
-    build.toTransport = function (namespace, moduleName, path, contents, layer) {
+    /**
+     * Creates the regexp to find anonymous defines.
+     * @param {String} namespace an optional namespace to use. The namespace
+     * should *include* a trailing dot. So a valid value would be 'foo.'
+     * @returns {RegExp}
+     */
+    build.makeAnonDefRegExp = function (namespace) {
+        //This regexp is not bullet-proof, and it has one optional part to
+        //avoid issues with some Dojo transition modules that use a
+        //define(\n//begin v1.x content
+        //for a comment.
+        return new RegExp('(^|[^\\.])(' + (namespace || '').replace(/\./g, '\\.') +
+                          'define|define)\\s*\\(\\s*(\\/\\/[^\\n\\r]*[\\r\\n])?(\\[|f|\\{|["\']([^"\']+)["\'])(\\s*,\\s*f)?');
+    };
+
+    build.leadingCommaRegExp = /^\s*,/;
+
+    build.toTransport = function (anonDefRegExp, namespace, moduleName, path, contents, layer) {
+
         //If anonymous module, insert the module name.
-        return contents.replace(build.anonDefRegExp, function (match, start, callName, possibleComment, suffix) {
-            layer.modulesWithNames[moduleName] = true;
+        return contents.replace(anonDefRegExp, function (match, start, callName, possibleComment, suffix, namedModule, namedFuncStart) {
+            //A named module with either listed dependencies or an object
+            //literal for a value. Skip it. If named module, only want ones
+            //whose next argument is a function literal to scan for
+            //require('') dependecies.
+            if (namedModule && !namedFuncStart) {
+                return match;
+            }
+
+            if (layer) {
+                layer.modulesWithNames[moduleName] = true;
+            }
+
+            var deps = null;
 
             //Look for CommonJS require calls inside the function if this is
-            //an anonymous define/require.def call that just has a function registered.
-            var deps = null;
-            if (suffix.indexOf('f') !== -1) {
+            //an anonymous define call that just has a function registered.
+            //Also look if a named define function but has a factory function
+            //as the second arg that should be scanned for dependencies.
+            if (suffix.indexOf('f') !== -1 || (namedModule)) {
                 deps = parse.getAnonDeps(path, contents);
 
                 if (deps.length) {
@@ -8484,7 +8954,7 @@
 
             return start + namespace + "define('" + moduleName + "'," +
                    (deps ? ('[' + deps.toString() + '],') : '') +
-                   suffix;
+                   (namedModule ? namedFuncStart.replace(build.leadingCommaRegExp, '') : suffix);
         });
 
     };
@@ -8528,7 +8998,8 @@
             var runBuild = function (build, logger) {
                 //Make sure config has a log level, and if not,
                 //make it "silent" by default.
-                config.logLevel = config.logLevel || logger.SILENT;
+                config.logLevel = config.hasOwnProperty('logLevel') ?
+                                  config.logLevel : logger.SILENT;
 
                 var result = build(config);
 
@@ -8549,6 +9020,8 @@
             }, ['build', 'logger'], runBuild);
         };
 
+        requirejs.define = define;
+
         module.exports = requirejs;
         return;
     }
@@ -8575,7 +9048,10 @@
     baseUrl: require.s.contexts._.config.baseUrl,
     //Use a separate context than the default context so that the
     //build can use the default context.
-    context: 'build'
+    context: 'build',
+    catchError: {
+        define: true
+    }
 },       ['env!env/args', 'build'],
 function (args,            build) {
     build(args);

comments