(cherry picked from commit 92ea719804)
92ea719804
Trying to keep platform dependency on the headers and clean the main code a little bit.