Refactor datastore client and improve task service