Some fixes and refactoring for the demo.