Always define global. Don't check define.amd, only if define is a function. Any questions? See the comments in the code.