added restore feature, bug fixes