Newly written program.  Much cleaner. Appears to actually work