Separating out stateful code; improving options