VE-1598: Switch to using Gallery class directly (without GalleryController)

On the way fixed bunch of problems with rendering galleries and organized the code.