Reorganized the snapshot logic a bit