Some refactoring, changes to demo