Ensured that all database operations are atomic (closes #16).