move some stuff out of Gallery.cb