Bug fixes and small changes to windows build.

Review URL: https://codereview.appspot.com/149390043