Complete rewrite with pretty functions.  Change name of file.  No more infinite loop...