Bugfixes and more by @igk1972
issue #303