Split platform specific implementation into separate files.
Fix probles with Mac code caused by last commit.
Fix incorrect include preventing compiling on Windows.