I took the liberty of continuing to work on this after chatting with Nathan.
I've attached the updated patch with some improvements.
Thanks.
--Anthony LeungAmazon Web Services: https://aws.amazon.com