I took a swing at implementing this exact library.
I have to say youre version is MUCH cleaner! Thanks for sharing