refactored module array holding and added shutdown module hook