Use `path` instead of `module.id` and check if modules are used
Make use of path methods and remove extension more securely
Build path in one place