significant cleanup of "set patterns" and better handling of module loading