larger rewrite, doing stuff quite differently to prepare for map integration