CMT tracking with arbitrary shape

- code cleanup
- arbitrary shape
- some corrections