Refactoring for cleanliness and proper use of exports/module.exports