Fixed several small bugs found by static code analysis
Merge pull request #103 from MarcelNehring/staticanalysis

static code analysis