Initial setup, code "borrowed" from AtmosphereJS.