First cut at a working version.