Fix for reference check in core

Reference sentinel was hardcoded in core, replaced it with
proper counting of actual sentinels that are present in
settings.
3 files changed