More improved error handling

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Whitespace fixes

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>