Optimization and comments

Optimized for the g++ compiler instead of VC++
Added comment for the final #endif for clarity