merge some fixes back into branch

was working on master by mistake.