Improving getModuleId and adding setModuleId.

This makes it easier to add hooks into other script loaders in the
future.