some bug fixes etc

Change-Id: Ie66716aebd2a474a3d4e7d1c39554cd43aff489d