Bugfixes, mostly for OS X compat.