Lots of small changes to make ingest work

Bug fixes mostly