All,
Here's an updated version of the patch which cleans up a couple of the previous issues, including addressing some of the free'ing issues.
Looking forward to comments.
Thanks,
Stephen