Initial state preservation, no collections
State preservation with collections
cleaned up code