Tons of changes to clean up build. Fixes to get unit test building on windows.