Simplified and fixed printf code.  Now works significantly better.