Fixed gallery layout bug