Add module tracking

This is very early, incomplete and unpolished version that works only on simple files.