Now a working Node module. Still needs cleanup, but it works properly.