Revert "- assortment of bugfixes found by coverity scan"

This reverts commit a84c50683af8aeb84d8f67b4351b862f614861ad.
Revert "- further bugfixes from coverity"

This reverts commit 8416e233cbeeea428ae9983b3efe5fccb91fe61d.
- fixed coverity bugfixes