Using trees for state instead of lists

As it is now, the program probably won't run since the I/O expects lists
but I set everything to return dictionaries.