Bug fixes and compression improvements in gallery.js