Change to use of objects instead of nested lists to clarify code.