refactor various platform functions and includes