Optimisation/caching

Removed $.each, cached some selectors.