Refactored code, added code to generate archive