Make module scan/reloading more generic

fixes #382