Fix #89 resource leak