re-organize compute code, clean control code