Merge work from the demo branch

The `demo` branch now contains fixes and implementation that should be in `master`. I'll mainline it as soon as it builds on Travis.