Warning fixes

Please, see each commit for a more detailed explanation.