Save/load REPL state

Old thread of mine on this topic.