Some improvements to gallery, layout, and jQuery