First piecemeal working version of the port from ruby -> node