This whole method can be implemented more efficiently. I have it in a branch on Mac. Do you want me to copy it over... or... something else?