Added upsert, returns books json and minro cleanup