Fixed further resource leaks

This commit fixes further resource leaks.

Best regards and many thanks for consider merging

Martin Ettl