A bunch of minor fixes. Not initialized variables, useless variables, reduced scope and similar stuff.