Fix compilation on gcc by replacing size_t with std::size_t and removing targetver.h.
Organize #includes.
Code reorganization.