Started refactoring

Switched from storing the grid in a 2-D array to a graph.