Bugfixes.

Several bugfixes concerning the error handling of the previous commits.