Nearly complete rewrite of trail. Again. :D