Some small refactorings I spotted while porting this to Node.