Cleans code and comments, fixes archiving function and adds logs