Some cleanup and a fix of demo.c