move trajectories code into a separate package