C: make sure to release everything