Refactor code for node structs in puzzle