Refactor code (split in core and extra)