file i/o and snapshot implementation