Improved the demo example. Also, did some more cleanup of the code.