Windows-specifc fixes (forward port) + rewrite TypeDeclarationBuilder