clean up the demo, fix some bugs