#184 Review PR

This PR is created for initial reviewing of the changes of #184 because #184 includes many external changes and hard to review.
It's not actually platform-specific. It was using a gcc-specific feature to allocate dynamic length array and is not portable.

Should replace them all to dynamically allocated style, instead of just for Win