added history saving/loading, fixed minor things