Rework build system.

Should now build on windows.