Lots of fixes to photo gallery