Revert the last few commits

They're causing trouble with sqlite3 locking; needs investigation.