Fix error message when archive handle isnt allocated and fix cast