bugfixes, script improvements