Added support for different types of modules and made some fixes