Moved resolveModule to a util module.
Simplified logic for #set a bit more.