Migration to Require.js + major cleanups and feature additions