Compilation fixes and build script improvements for Windows

Change-Id: I33e0acd4a7447c5de53beeabdbc91b98ce49c2bd