unified module loading code a little