cherrypick random buildfixes from sandsmark

cherrypick random buildfixes from sandsmark