Ugh.  Two globals... Aesthetically bothers me but after looking at this code I guess this is okay...