Port of beta fixes and a few extra ones.