Refactored some modules to be functions instead of objects thus avoiding singleton related issues