Improved free functions