Drop safecopy dependency.
Add missing index.
Fix SQL bug.