swap roles around slightly so that the driving end always looks at its table first and sends key ranges rather than count for hash (as for rows); saves one round-trip per table and makes it easier to do some other improvements later
disable referential integrity while syncing
remove unused file
use the database-specific functions for quoting values to insert
add an option to turn on the OS X malloc checks
tidy some more error messages and SQL