Bug fixes to previous giant commit.