freeze and thaw functions

Here are the freeze and thaw functions as discussed in issue #4.