Fix mishandling of incomplete, inverted masks.