Cleanup. Better exception logging. Add 'sort_reverse' option to global and per-gallery config.