Added Debug-Switch and Bugfixes if DB is empty