Improve error checking and logging.  Make it so that sanity is called
on SQL failure.
Make it so that this only happens in developer mode.