Fix a handful of bugs in trajectory code.