+ issue #31: changed scope database check.
+ added debug messages for scope calculation.