Fix bugs

Fix a bunch of bugs I found when I ran this against 360 projects.