Refactor js with IIFE to avoid polluting global ns; tighten config