Revert "Revert "Some fixes""

This reverts commit 8f0837966b083719b79588a8d43ea9bd919a9b83.