Copied remotely
Moved variable definitions to top of functions (variables can, only be defined partway thru in C++ not C)
fix compile errors
fix incorrect use of NULL
fixed build errors
fixed build errors
added msv and csv into the build
removed compiler warning