Merged Dave's Gallery2plus code