Bugfixes for cross-platform use.