Misc fixes and result checks

more checks of return values