Misc. warning fixes

Just a few random fixes, please review each commit.