Refactored main JS into separate file.
Refactored backup to use stdlib more