[TASK] Fix several bugs mentioned by scrutinizer

Releases: 2.0.0
Change-Id: I045170a1368bfac6b0c291af896c904e66236163