Add cloneState function
Create sub-array; cloneState gets state as arg
Fix mistakes