this is fantastic, i wish i had your example when i worked on mine (closed source)... it was the same for me, total brute force
... and apples examples are in c++ but i ended up doing it using straight c out of frustration since thier (c++) examples were so convoluted