reorder tests to prevent stack overflow in IE, switch from Zepto to jQuery

Why flatten??