I'll work on these changes over the weekend and see how far I can get. Using the STL stuff will be something new to learn but the rest of it seems straightforward. Thanks for the feedback on my rusty c skills
Will post a new diff when I have another draft ready.