fixed all bugs reported by the static analyzer

mostly dead-store and "potential" access to uninitialized variables