Fixed all outstanding compiler warnings and static analyzer issues, except one noted by todo.