AMD compatibility

source: https://github.com/umdjs/umd
minor tweaks