implemented better error logging (closes #1382 #1420)