Added require.js

Added require.js and made minor changes to corresponding js. Some changes like use of 'use strict' and changing to proper AMD is still pending.