I'll simplify this and then merge.