Added before and after functions. Added global each() access
Updated each function, added before and after functions