Much improved gallery. Some minor fixes and refactoring.