add error checks for previously ignored error return values
Changes to conform with golint