lots of fixes for module loading and init