This is basically junk.  Will rewrite something cleaner.