added update-from-scratch option, refactoring