Complete rewrite of the Squartle code