CArchive update

* remove duplicated code
* add error checking
* reduce header include