3.6/f/fix warnings

Rebase a couple of warning fixes from master to 3.6/master. It has already passed review, the only change is that it was backported to 3.6