Rework to use promise instead of events; Optionally defining AMD; Remove unnecessary dependencies