Suggested improved error handling

The error return value from various function calls was ignored in several cases.