Minor tweaks and fixes to archive function