small refactoring in core and demo