Added snapshot code

WIP