#3265: Bug fixes, remove debugging messages, clean up error reporting.