Fix several different coverity warnings relating to the new gallery code