add an option to turn on the OS X malloc checks
tidy some more error messages and SQL