More bug fixes from previous merge.