Bunch of bug fixes,  added archive functions to the API.