Some code cleanup in modules