Initial port of needle.js script