Fixed warnings

The static analyzer found some memory issues.