Bug fixes after refactoring, further implementation of the new model (element-module relationship etc)