Fix bugs in ingest