Rewrite the snapshots code