Revert "Revert "bugfixes""

This reverts commit c78c65d717be8caee31baa0c81c216a79425dcac.