Fix some error handling bugs (those could lead to a crash in some edge cases)
Fix some error handling bugs (those could lead to a crash in some edge cases)

tversity/appflinger-go,tversity/appflinger-go,tversity/appflinger-go