Changed caching and filtering of modules

Fixes #152
Fixes #149
Fixes #140