Eliminate two potential race conditions.

1. Create fail, followed by delete, then update fails silently.
2. Use sub-query to do /stats.

Change-Id: Iee8648f3e1524f2a29b11d24f883377be31d2e84