Added analytics custom events, improved gallery FOUC