BinaryGallery and jsonGallery logic cleanup