Bug fixes, refactored demo a bit