Fix duplicate load bug.

Also fixed half a dozen other bugs with the SQL loader.