Minor fixes for exeptions found while testing