Gallery: updates, cleaning and bug fixes