fix various compilation warnings

Mostly taken from the changes in #1849