Updated source code in original post for anyone interested in poking around in it.