Add hat
Add trajectory
Some refactoring