Atomic save

New Pull request to replace #511 which linked to `master` instead of a dedicated branch