Added a history saving mechanism, but haven't tested it yet.