bugfixes: numerous bugs in error propagation found by clang