Optimize for $each and $event and add AMD