Added support for require.js and fixed some issues with the connection process.