fixing a bunch of analyzer warnings + a little cleanup