Changed core to use AMD or CommonJS where available