several bugfixes in SQL script and pgModeler file