Fix typo
Replace manual saves with periodic background saving
Atomically save the metadata json file
Clean up some error handling
Add a /metricz route for introspecting the db