more small sql scripts bugfixes