Add module tracking

This is very early, incomplete and unpolished version that works only on simple files.
First step on the road to #37.