lots of work on reading trail data from the db and rebuilding data structures.