Some bug fixes

Change-Id: I274c2b626f1bbec0610e224f8e226739c8b973e7
Signed-off-by: Iain O'Farrell <iain.o-farrell@sap.com>