Cleaned up unused code. Added trajectory support (untested).