minor bug fixes suggested by Scrutinizer

Change-Id: If3ed077874cbf3d9c8c1352cecb33d3e6b048d33