Fix bad names, and move non-demo code from demo/ to the actual code.