BUG 1855
Error handling fixes and refactor

Change-Id: Iead5da76cdc8ed68e81d565e250aad5274ae8d6c
Signed-off-by: Peter Mellquist <peter.mellquist@hp.com>