Bugfixes for MacOSX

Some hot-bugfixes for MacOSX.

See the individual commits for the details.