refactored core archive code into a lib