Added AMD support.
Boilerplate code copied from: https://github.com/umdjs/umd/blob/master/amdWeb.js