Fixed some bugs when there no modules