Sorry, just woke up. The attached patch corrects the logic of the first one.