Numerous minor tweaks and level 4 warning fixes