Refactoring, making it more node.js'y