The code needs a rewrite: - use a piece list rather than a square list; - reduce the abundance of shared pointers; - make code easier to read; - use better modern C++ practices.