Initial platform abstractions.
Fixes for Linux problems introduced during refactoring.
Fixing basic FreeBSD support.