Added AMD-compatability; stylistic improvements (JSHint-approved)