Port of Sparky from app.js 0.2.