Fixed a couple of bugs in the demo() function.
Fixes for python3