Fixed DB problems after creating a new gallery.