Bug 1064600 - [Gallery] preliminary modularization before full gallery refresh

Rebased djf's original PR