Remove unused CSS and refactor shared JS output