Added lazy creation of traj
Some updates from Patrick.

Also some additional style tweaks.