resources are now correctly freed on dispose