added restore.js
Refactoring to make things more node like.